Skip to main content
Submitted by granular78 on Wed, 04/20/2016 - 05:01

I want to move a motor forward and backward at a constant speed. Then, I want to increase the speed by 5000 and repeat. Simple shearing motion.
What is wrong with my code? Please help

DPX= 0;'Defines position of the X axis to zero'
#init
i= 0
s=0;
#loop; 'This is a label that defines the start of a subroutine
^s= ^s+5000;
speedx= _s
SP speedx;
PA=1000
BG X; 'Begin motion
AM X; 'Wait for motion to complete
WT 10000; 'Wait 1 second

PA=-1000
BG X; 'Begin motion
AM X; 'Wait for motion to complete
WT 10000; 'Wait 1 second
i= i+1; 'Increment the variable i
JP #loop,i<10; 'Jump to the #LOOP label while i is less than 5
MG "DONE"; 'Output a message when you are finished
EN;

Comments 1

AndrewS on 08/30/2016 - 09:45

Hi Amani,
There seems to be some syntax errors in your variables. Remember that you can't use special characters such as ^ or _ in variables.

Here's how I would suggest writing it:
[code]
i=0
#loop
'insert all the commands to move axis
SPA=_SPA+5000;' increase current speed by 5000
JP#loop,(i<10)
EN
[/code]
Regards,
Andrew