Galil Motion Control DMC-21 5 Series User Manual page 117

Table of Contents

Advertisement

Example - Position Follower (Point-to-Point)
The motor must follow an analog signal. When the analog signal varies by 10V, motor must move 10000 counts.
Read the analog input and command A to move to that point.
#points;
SP
7000;
AC
80000;
DC
80000;
SH
A;
#loop;
vp=@AN[1]*1000;
PA
vp;
BG
A;
AM
A;
JP
#loop;
EN;
Example - Position Follower (Continuous Move)
Read the analog input, compute the commanded position and the position error. Command the motor to run at a
speed in proportions to the position error.
#cont;
AC
80000;
DC
80000;
SH
A;
JG
0;
BG
A;
#loop;
vp=@AN[1]*1000;
ve=vp-_TPA;
vel=ve*20;
JG
vel;
JP
#loop;
EN;
Example – Low Pass Digital Filter for the Analog inputs
Because the analog inputs on the Galil controller can be used to close a position loop, they have a very high
bandwidth and will therefor read noise that comes in on the analog input. Often when an analog input is used in a
motion control system, but not for closed loop control, the higher bandwidth is not required. In this case a simple
digital filter may be applied to the analog input, and the output of the filter can be used for in the motion control
application. This example shows how to apply a simple single pole low-pass digital filter to an analog input. This
code is commonly run in a separate thread
#filt;
an1=@AN[1];
k1=32/64;
k2=32/64;
AT
0;
#loop;
an1=(k1*@AN[1])+(k2*an1);
AT
-2,1;
JP
#loop;
EN;
Chapter 7 Application Programming ▫ 112
'label for main program
'define speed
'define acceleration
'define deceleration
'enable A axis
'label for loop
'read analog input, compute position and store
'define absolute position move
'start motion
'wait for motion to finish
'jump back to loop label
'end program
'label for main program
'define acceleration
'define deceleration
'enable A axis
'define jog speed of 0 cts/s
'begin motion, motion is commanded to speed of 0
'label for loop
'compute desired position
'calculate error
'compute velocity
'set new speed
'jump back to loop label
'end program
(XQ#filt,1
– example of executing in thread 1).
'label for main program
'set initial value
'increase k1 for less filtering
'increase k2 for more filtering
'set initial time reference
'label for loop
'calculate filtered input
'wait 2 samples from last reference
'jump back to loop label
'end program
DMC-21x5 User Manual 1.0a1

Advertisement

Table of Contents
loading

Table of Contents