I am trying to get an 08M2 to send and receive commands to an 18M2 which has two stepper motors wired.
The test code below works perfectly, turning each motor (1 to 4) a set number of pulses.(25 in this example)
The first few lines of the 18M2 are:
SERIN C.2,N2400,B20,B21
IF B20=1 THEN GOSUB MOTOR_1_CW
IF B20=2 THEN GOSUB MOTOR_1_CCW
IF B20=3 THEN GOSUB MOTOR_2_CW
IF B20=4 THEN GOSUB MOTOR_2_CCW
What i would like to do is replace the "Pause 4000" commands with Serin and have the 18M2 send a "finished moving" command each time the stepper has completed it's move.
I have tried using Serout,pin.baud,("go") on the 18M2 and Serin,pin,baud,("go") on the 08M2 but all I achieve is the 08M2 missing out one instruction and moving on to the next. It is not waiting at the Serin command.
The test code below works perfectly, turning each motor (1 to 4) a set number of pulses.(25 in this example)
The first few lines of the 18M2 are:
SERIN C.2,N2400,B20,B21
IF B20=1 THEN GOSUB MOTOR_1_CW
IF B20=2 THEN GOSUB MOTOR_1_CCW
IF B20=3 THEN GOSUB MOTOR_2_CW
IF B20=4 THEN GOSUB MOTOR_2_CCW
What i would like to do is replace the "Pause 4000" commands with Serin and have the 18M2 send a "finished moving" command each time the stepper has completed it's move.
I have tried using Serout,pin.baud,("go") on the 18M2 and Serin,pin,baud,("go") on the 08M2 but all I achieve is the 08M2 missing out one instruction and moving on to the next. It is not waiting at the Serin command.
Code:
#PICAXE 08M2
#NO_DATA
INIT:
PAUSE 1000
MAIN:
SEROUT C.2,N2400,(1,25)
PAUSE 4000
MOTOR_1_CCW:
SEROUT C.2,N2400,(2,25)
PAUSE 500
MOTOR_2_CW:
SEROUT C.2,N2400,(3,25)
PAUSE 4000
MOTOR_2_CCW:
SEROUT C.2,N2400,(4,25)
PAUSE 4000
GOTO MAIN