Railway Traverser

jamesrj

New Member
Hello Forum.
Can you help an oldboy new to the picaxe world??
Years ago I constructed a railway traverser, which carried 4 tracks, powered by a DC motor driving a screwed rod, a limit switch at the ends changed over the direction via relays, and using just 1 push to make switch in the control circuit ( like a two way lighting circuit). Motor turns were counted by a hard wired up/down counter some logic
via an opto switch on the shaft. Every push of the button would move the table 1 track at a time,stop after a preset count.
Now with the aid of a picaxe 18x, 2 *12v Bipolar steppers (Rapid) working in tandam each with its own driver chip.
I am using the codes from the manual,but, I am having a problem remembering my Basic ( ZX81 )!!!of how I can use that 1 push button to make the table reverse after it has reached the 4th track, (lstep:) and on the 7th push to (rstep:)
(ie: every 3rd push of the button would reverse the table ). ( No problem with 2 buttons 1 for each direction.)
The distances between tracks are the same so I can enter the same 2 byte variable code w0.
Would it be some kind of count code with goto's, but I can't see it..
Thank you in advance if you can put me on the right track. no pun intended..................rj
 

hwholmes

Member
( No problem with 2 buttons 1 for each direction.)
.....Would it be some kind of count code with goto's, but I can't see it..
If you have the code for two push buttons then all you need is to determine where you are in the count sequence.

If you use a MOD 6 (ring) counter:

cnt = cnt + 1 % 6

then cnt will go from 0 to 5 and repeat 0....5,0,...5,0 etc.

Now decide if cnt >= 3.

False use code for one direction (as if using that push button) and True goes the other way.

Note: check the direction before incrementing the counter.
 
Last edited:

jamesrj

New Member
Thanks for your reply,but as a newbe where would I find this info in the manual
Mod6 (ring) counter, is there any other way??
Like the tag..
rj
 

hwholmes

Member
Mod6 (ring) counter, is there any other way??
This has the same effect as:

Code:
cnt = cnt + 1
if cnt = 6 then
  cnt = 0
endif
Which may be easier for someone who is not familiar with the MOD (also sometimes called remainder) operator.
 
Top