Society of Robots - Robot Forum
Software => Software => Topic started by: robota on August 19, 2008, 07:39:54 AM
-
I have a differential equation and I want to implement this in C code
I know that I need to use loops and I know how to implements loop in C code
but I don't know how to do the differential equation
I will be glad to receive any information
Thanks
robota
-
ouch....
did you check math.h?
is there a simpler way for you approximate the solution? Use some fancy algerbra, you know that stuff you learn in highschool?
-
show us the differential equation. Most of the time, you don't even need loops.
It's implentation is fairly simple:
int i = 0;
i++; //i is now 1;
i += i // i is now 2;
i += i // i is now 4;
Or with loops:
int power(int value, int loops)
{
int numloop;
int finalvalue = 0;
if (loops > 0) {
finalvalue = 1;
for (numloop = 0; numloop < loops; numloop++) {
finalvalue *= value;
}
}
return finalvalue;
}
what is the equation you're talking about? I could help you further if I know it. (some background info would be nice too ::))
-
Hallow friends
Iron man I will glad if you can give me more details
Madmax I don't understand the differential equation that your code can solve
I have some differential equation that I want to put in C code and solve it
Like the PID differential equation
Or like other Transfer function
Thanks
robota
-
I put a better picture
-
well, the definition of a differential equation is: a functions that modifies the original variable inputted. So I understood you wrong.
I do not know what the function does exactly, what are you trying to calculate?
Do you want to retrieve constants from this equation, or should this equation be recalculated every iteration.
Could you provide more information?
For example:
What is Mk or Kp?
Is (K - 1) a timestep?
Do you have any information about the variables in your equation?
-
The PID differential equation is a bad example because I know all the PID "K"s
But the Transfer function example is a good example
I need to find all "y" and all "X" that solve this equation
-
You can't solve it like this. I need to know a certain relation between x and Y.
Please, I need to know what these variables are. How did you come up with this equation?
are x and y places on a plane? I need to know the relation between these two.
Also, how does K+2 modify x or y, where is it refering to.
In physics, this subscript is used to specify where you are talking about,
force is specified by the letter F, if you're talking about gravity, you specify
the force as Fg.
Do you understand why I'm confused?
-
math.h is a header file that you can
#include "math.h"
it helps do many basic functions that allow for easier manipulation of numbers without writing your own functions.
-
Are you trying to differentiate an equation, or solve an equation thats been differentiated?
Unless you are designing a calculator, I don't see why you'd want to do the first option . . . the second option is something you can do by hand or using math software . . .
If I was doing calculus on my microcontroller, I'd solve the equation before even programming it in . . .
-
Madmax I know that I need the initial conditions
But I don't know how to receive this
This differential equation I receive from the transfer function of all the system
But I don't know how I to receive the initial conditions
Iron man I have two big books in C language but in this books I don't have information about math.h
I will glad if there is anybody that have one awesome link that explain math.h to write The link here
Admin this equation have infinite solutions
y0, y1, y2, y3, y4,,,,,
x0, x1, x2, x3, x4,,,,,
therfore i need to use a math software
robota
-
allright, you state that this equation has infinite solutions.
This means you want to put a computer in an everlasting loop... Or... you need some human like Einstein to solve it for you.
You cannot solve your equation like this, because you do not know what the variables are and you also don't know the relation between x and y
-
http://en.wikipedia.org/wiki/Math.h
standard library,
i don't know how much it will be needed, but if there is an trig involved or w/e. idk just throwing it out there.
-
Can you show the equation?