My application is just a development from largedemo.
I have two potentiometers with the idea of developing a controller.
These are named reference and feedback.
volatile uint16_t reference;
volatile uint16_t feedback;
volatile uint16_t error;
// this works
if (reference > feedback) set_pwm(pwm + 1);
if (reference < feedback) set_pwm(pwm - 1);
// this does not work
error = reference - feedback;
if (error > 0) set_pwm(pwm + 1);
if (error < 0) set_pwm(pwm -1);
In the later case error can take positive or negative values.
In the former case only positive values are involved.
Would someone be as good as to send me the correct syntax
for a comparisson with negative numbers.
John
_______________________________________________
AVR-chat mailing list
AVR-chat@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-chat