News:

;) This forum is the property of Proton software developers

Main Menu

PID examples

Started by JonW, Mar 21, 2022, 09:30 AM

Previous topic - Next topic

JonW

Take a look at https://www.kickstarter.com/?ref=nav.  You apply for an account, create the template of the work etc and off you go

midali

   I tried to use the PID routine on a gps RC car, to move alone between 2 points. I calculated the angle between those 2 points , but car rotates in a circle, because if the real angle is equal to the calculated angle, the servo moves either to the left or to the right, isn't stay in the middle.
   Can you help me set PID parameters, please?  or should the PID routine be changed?

Include "PID.inc"                           ' Load the PID routine into the program

    Dim MyInput As Word                         
    Dim MyRequired As Word                     
    Dim MyOutput As Word                       

'------------------------------------------------------------------------
' The main program loop starts here
'
Main:
' Setup the PID parameters
'    PID_Setup(  10,  3,    1,       9,             1,           0,        1023)
'            (  pKP, pKI, pKD, pMaxCorrection, pMaxError, pMinOutput, pMaxOutput)
'                                               
    PID_Setup(  10,   0,    10,       100,           10,        1000,        2000  )

    Do
        MyRequired = angle_calculated               
        MyInput    = angle_real                 
        MyOutput = PID_Compute(MyInput, MyRequired) ' MyOutput is value in us for servo driving
       
        HSerOut [  Dec MyOutput ,10]                                     

    Loop                                            ' Do it forever