stevecoulson
New Member
Hi, I have been struggling with this for some days now so, with tears of frustration rolling down my cheeks I turn to the Picaxe forum.
I am trying to control a device that displays model figures one at a time in sequence. It is a motor switching program. A large table rotates and pause 8 times allowing one, and then another and another, of the 8 tables positioned around it's periphery to be displayed. These smaller tables also rotate, clockwise and anticlockwise. The large table is called a Tumbrel (made up name) and rotates clockwise only. It is controlled by a Picaxe 28X2. The smaller ones are simply called Tables and each is controlled by a 14M2.
One of the Tables operates only when the Tumbrel is inactive and it rotates back and forth switched by a PIR sensor. This is called the ComeOn table. As soon as the Go button is pressed the ComeOn goes into ParkAnd Wait mode.
I have written a program to control all this and it works fine but only once. After the Tumbrel has gone through it's sequence (indexing round 8 times and coming to a halt with the ComeOn back at the front) everything goes dead. The Go button does nothing and the ComeOn no longer responds to the PIR sensor. If I switch off the power and then on again all is well but only for one more cycle. It seems that the program has got stuck. It does not go to PreMain as I tell it to in:-
If eCount = 8 then Goto PreMain
Can anyone tell me what I have done wrong?
Here is the program:-
I am trying to control a device that displays model figures one at a time in sequence. It is a motor switching program. A large table rotates and pause 8 times allowing one, and then another and another, of the 8 tables positioned around it's periphery to be displayed. These smaller tables also rotate, clockwise and anticlockwise. The large table is called a Tumbrel (made up name) and rotates clockwise only. It is controlled by a Picaxe 28X2. The smaller ones are simply called Tables and each is controlled by a 14M2.
One of the Tables operates only when the Tumbrel is inactive and it rotates back and forth switched by a PIR sensor. This is called the ComeOn table. As soon as the Go button is pressed the ComeOn goes into ParkAnd Wait mode.
I have written a program to control all this and it works fine but only once. After the Tumbrel has gone through it's sequence (indexing round 8 times and coming to a halt with the ComeOn back at the front) everything goes dead. The Go button does nothing and the ComeOn no longer responds to the PIR sensor. If I switch off the power and then on again all is well but only for one more cycle. It seems that the program has got stuck. It does not go to PreMain as I tell it to in:-
If eCount = 8 then Goto PreMain
Can anyone tell me what I have done wrong?
Here is the program:-
Code:
#picaxe 28X2
#no_data
#no_table
#terminal off
'======Variables======
symbol ButPush = pinA.1 ' leg 3
symbol SenA = pinA.0 'leg 2
symbol TableSig = pinA.2 ' leg 4
symbol eCount = b0 ' variable
symbol Carousel = b1' variable
'=============Initialisation==============
let dirsb = %11111111 ' set port B as outputs
'============= Program=================
PreMain:
eCount = 0
Carousel = %00000010
High C.5 'this tells the ComeOn to go into action
Pause 300
Low C.5
Goto WaitForPush
Main:
High C.1
Gosub TableStart
Pause 1500 ' allows the magnetic sensor to escape the magnet
Gosub WaitForSensorA 'wait for magnetic sensor on Tumbrel
Low C.1
Gosub WaitForTable 'wait for the active Table to signal.
eCount=eCount+1
If eCount=8 then goto PreMain
Carousel = Carousel*2
Goto Main
'=============Sub-Routines=============
WaitForPush:
If ButPush = 0 then WaitForPush'active High
High C.4 'tells the ComeOn to go into park mode
Pause 200
Low C.4
Goto Main
WaitForSensorA:
If SenA = 1 then WaitForSensorA 'active Low
Return
WaitForTable:
If TableSig = 0 then WaitForTable 'this line is active High.
Return
TableStart:
Let OutpinsB = Carousel
Pause 300
Let OutpinsB = $00
Return
Last edited by a moderator: