I have no idea why, but I found it important to report.
global variable:
long int time=0;
float ki=0;
void function (void)
{
float delta_error, speed;
speed = delta_error* kd/time;
}
This two should have the same result as far as I know.
global variable:
long int time=0;
float ki=0;
void function (void)
{
float delta_error, speed;
speed = ((delta_error/time) * kd );
}
This program is written in C, the important part is that for the first cycle the speed is 2147483647 for the first version. It should be zero. The interesting part is that second version shows the value of speed equal to 0. I have used code vision is my compiler and I ran this on my Atmega 1280. Anyone knows why?
later on I tried with this delta_error/time * kd and the resualt is as same as second version.
Hint: signed int in my compiler has the range -2147483648 to 2147483647
No comments:
Post a Comment