#MOVE8 'label
KD=3300 'derivative vaslue modified from default value of 64
KP=610 'gain value modified from default value of 6
KI=10 'integral value modified from default value of 0
i=0 'set counter to zero
#LOOP 'label
DPX=0 'define intial position to be zero on the X-axis
PRX=1000 'set the relative position to be 1000 counts on the X-axis
SP=6000 'set the speed to 6000
AC=50000 'set the acceleration to 50000
DC=50000 'set the deceleration to 50000
BGX 'begin motion on X-axis (start motor)
AMX 'await end of motion on X-axis
WT 200 'wait 200 ms
PRX=-500 'set relative distance on the X-axis to be 500 counts CCW
SP=6000 'set speed to 6000 counts per second
AC=50000 'set acceleration to 50000 counts per second squared
DC=50000 'set decleration
BGX 'begin motion on X-axis
AMX 'await end of motion on X-axis
WT 200 'wait 200 ms
i=i+1 'increment counter by one
JP#LOOP,i<5      'jump to"#LOOP" ifi<5 else drop down to following instruction
MG "DONE" 'print "DONE"
EN 'end of program


This program provides these below results.

Move X
x-axis-----> 0, 500, 1000, 15000, 2000, 2500 milliseconds (1000 ms = 1 second)
y-axis-----> counts



#MOVE10       'label
KD3366 'set derivative to 3366
KP334 'set gain to 334
KI30 'set integral to 30
i=0 'set counter to zero
#LOOP 'label
PA5000 'set absolute distance to 5000
SP100000 'set speed to 100000
AC100000 'set acceleration to 100000
DC100000 'set deceleration to 100000
BGX 'begin motion
AMX 'await end of motion
WT1000 'wait one second
PA0 'set the final position (absolute position)
BGX 'begin motion
AMX 'await end of motion
WT1000 'wait one second
i=1+1 'increment counter
JP#LOOP,i<3 'jump to "#LOOP" if i<3 (else done)
EN 'end program


This program provides these below results.

Move 10


The above graphs show the effect of adjusting the values of KD, KP and KI (the PID. To give these graphs a little content the following two diagrams are presented. The first one shows an equation of a simple hypothetical system:


K1/s[s+K2/K1]

Here the “s” is the derivative (KD), the “K1” is the gain (KP) and the “1/s” is the integral (KI). Note that the gain “K1” causes the system to remain constant as the frequency increases while the integral “1/s” results in a decrease in the gain as the frequency increases and the derivative “s” causes an increase in gain with increasing frequency. The net result as frequency increases provides a more detailed view of the effect of varying the derivative (damping KD). The gain KP generates the torque to move the motor and the integral (KI) accumulates the net errors to provide accuracy. The second diagram below shows that the optimal damping ratio “zeta” (actual damping/critical damping) is 0.7. A value of 0.9 is over damped and a value of 0.5 is under damped.






Back