Hi, Daaan
I use such a routine to drive cooling flaps of an engine cowl ... ( of course with temp. as input ... lol )
no problems just change the lines :
Code:
Direction = pid_Out.15 'Set direction pin accordning to sign
pid_Out = ABS pid_Out 'Convert from two's comp. to absolute
HPWM 1, pid_Out, 10000 'Set PWM output
Pause 10 'Wait....
to drive a servo and not a " Bridge driven " DC motor.
Did not understand your linearity problems ... IF you use the servo within its NORMAL RANGE ( say 800 - 2200 µs ) linearity is fine - Whatever its brand ( humour !!! )
Moreover, ... as it's a closed control loop with Integral action, your servo HAS to reach the required position ... more or less qickly !!!
But, might be, your project is only a PROPORTIONNAL regulator ... This could easily explain never reaching the setpoint ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks