Hi Henrik ;
Why are you not sure about the code line ;
duty=duty+pid_Out
CCP1CON.4=DUTY.0
CCP1CON.5=DUTY.1
CCPR1L=DUTY>>2
Since we're trying to reach to a setpoint and that is the RPM in our case , The only way to keep the motor speed/RPM stable is giving an actual duty cycle command with an additional (positive or negative ) error dependant variable which is duty=duty+pid_Out ...
In such an equation in case we calculate a "zero" error , our duty doesn't need to change and keeps its duty as long as the error is zero , but when the error changes pid_out variable contributes to the next duty cycle with a positive or negative value depending the errors sign ... (I interpret and speak through the code you and Darrel created)
Let's take your code part which is applying the code directly to the registers as it is ...
HPWM 1 , pid_out,10000
pause 10 '''''''' this delay must be the lag , dead time I suppose , which I find very accurate for the slow responsing systems but I can't say the same for fast responsing systems ..
Well ... Now let's say we're at the desired RPM level for the motor , then what ? , pid_out is gonna be zero since there is no error ? Which means unpowering the motor for a short time or loosing the voltage on the motor till the balance condition breaks ...
I may be wrong with all those thoughts since I am a newbie engineering student ... Please enlighten and correct me if I'm wrong with those written above ..
Regards
Thanks for your counsel ..
Bookmarks