stevecoulson
New Member
Hi, I have written a simple motor control program that uses a magnetic sensor. I have written the program and run it on the simulator and all seems fine. When I try it in the Picaxe 14M though nothing happens. I have tried 3 different 14Ms, all the same. I have made a copy of the circuit in breadboard and it still does nothing. When I run the program in 'Simulation' I sometimes get a pop up that says 'Gosub stack too large' but reducing the Gosub commands by 2 made no difference.
This is the code:
The final subroutine (TumbrelStart) is a signal back to the 28M2 to continue with it's program. I thought that using Output0 might be a problem as this is the
Serial Out pin but moving it made no difference.
I am not an experienced programmer and placing everything in a Gosub stack seemed like an easy way to do things. Have I done wrong somewhere? SC
This is the code:
Code:
'variables
symbol Go = Input4
symbol MagSen = Input3
Main:
Gosub WaitForSignal
Gosub TableClockWise
Gosub TableGo
Gosub SensorWait
Gosub TableStop
Gosub TableTarry
Gosub TableAntiClockwise
Gosub TableGo
Gosub TumbrelStart
Gosub SensorWait
Gosub TableStop
Gosub Main
'Subroutines
WaitForSignal:
If Go = 0 then WaitForSignal
Return
TableClockWise:
High 1 'sets the H bridge clockwise
Low 2
Return
TableGo:
High 0
return
SensorWait:
If Magsen = 0 then SensorWait
Return
TableStop:
Low 0
Return
TableTarry:
Pause 4000
Return
TableAntiClockwise:
Low 1
High 2
Return
TumbrelStart:
High 5
Pause 300
Low 5
Return
Serial Out pin but moving it made no difference.
I am not an experienced programmer and placing everything in a Gosub stack seemed like an easy way to do things. Have I done wrong somewhere? SC
Last edited by a moderator: