'***************************************************************************
'Galil Motion Control Sample DMC Code
'***************************************************************************
'Description:
'Application program to create s-curve profile
'in contour mode.
'Total variable is total number of samples for move
'Dist variable is distance to travel
'***************************************************************************
total= 100;   'must be even number
dist= 25000
samples= total/2
split1= (total/4)
split2= ((total/4)*3)
'triangular accel value
d1= 2*(dist/2)
d2= (samples/2)*(samples/2)
triac= d1/d2
e1= (triac*samples)/2
e2= (e1*4)/samples
jerk = e2/total
'MG "Jerk=",Jerk
DA *[]
DM b[total],c[total],d[total]
i= 0
#jerk
b[i]= jerk
i= i+1
JP #jerk,i<split1
#jerk1
b[i]= jerk*-1
i= i+1
JP #jerk1,i<split2
#jerk2
b[i]= jerk
i= i+1
JP #jerk2,i<total
i= 0
c[i]= b[i]
i= i+1
#acc
c[i]= b[i]+c[i-1]
i= i+1
JP #acc,i<total
i= 0
d[i]= c[i]
i= i+1
#vel
d[i]= c[i]+d[i-1]
i= i+1
JP #vel,i<total
#go
i= 0
'for accelera - the WC is not valid due to the contour buffer
CM A
DT 2;   'sets speed of playback
'CD @RND[D[I]]
#loop
CD @RND[d[i]];
'WC;    'Econo & Optima Only - uncomment
i= i+1
JP #loop,i<total
'Comment out next two lines for Econo & Optima
#l2
JP #l2,_CM<>511;  'waits for contour move complete (Accelera only)
CD 0;DT 0
EN