Event Counting - HO Railroad
DataJ
Posts: 23
Attached is the code from the original testing,·"IR Switching Display Detect",·used to determine if the IR Detectors, H Bridge and servos would work as planned, and, they do.
The second attachment·is the program code, "Event Counting,·in attempt to program some form of accountable control over the entire action on the layout.· (The basis for this code is from the StampWorks Manual).
The third attachment is the track schematic, pin identification, label names, etc., which help clarify what
is to be accomplished.
Thank you
The second attachment·is the program code, "Event Counting,·in attempt to program some form of accountable control over the entire action on the layout.· (The basis for this code is from the StampWorks Manual).
The third attachment is the track schematic, pin identification, label names, etc., which help clarify what
is to be accomplished.
Thank you
Comments
For example, we both need a way to either count the cars or the events and then do something or go
to a pre-defined sub-routine.
However, as the reference manual indicates, that Stamp runs through the program, looking for whatever
is true and responds accordingly to that input.· However, when a second event occurs on that very same
detector there is no way I have found for it to recognize that as a second event.
It seems to me that what is needed·is a means to hold·an event or count·in "memory" until triggered
by the next event or count, and again, counted and held, pending the next event or count, and so on.
Then, for example, if the events or the count equal some number, then there would be a program
instruction to would direct the·Stamp to the proper sub-routine.
A potential option·might be·to use a microcontroller capable of handling "interrupts".· However, from what I
read, an interrupt, when triggered, stops the current program, drops to a pre-defined sub-routine, and then
returns where it left off.
That might work, but, my knowledge with this equipment is limited - - we both may need a computer to handle these kinds of activities.
I have searched all over the web and have few articles dealing with controlling model trains solely
with a microcontroller.· That·almost leads me to the conclusion that it simply cannot be accomplished.
By the way, here·are a couple of interesting model train sites you might enjoy:··JLCEnterprises.com and the other is Model Electronic Railway Group, or MERG.org.uk
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Manetheren
or "land" area.
The servos are mounted beneath the 3/16" hardboard top; actuaction is handled by a model aircraft·clevis fitting attached to the servo horn with a 2-56 threaded rod extending beneath the throwbar.· The throwbar has a .035" hole drilled in the throwbar,·thrrough which the .035 music wire extends.
The·transformers·are attached along the inside·perimeter of the 1 x 4's.
I tried sending attaching a .jpg of the trackplan that I canned, but, the website timed-out.
By the way, Page 105 of the Stampworks Manual lists code for counting external events, however, they are
using a pulse generator.
This is where things began to get confusing.
By the way, the Stampworks manual is available for downloads at Parallax, Store, Books, Stampworks Manual.
·
For example, we both need a way to either count the cars or the events and then do something or go
to a pre-defined sub-routine.
·
However, as the reference manual indicates, that Stamp runs through the program, looking for whatever
is true and responds accordingly to that input.· However, when a second event occurs on that very same
detector there is no way I have found for it to recognize that as a second event.
Here try these two routine and see if you can get this to work for you
Chg··· PIN··· 0·········· You would use this instead of IN0
cntr·· VAR··· Word
· cntr = 0
· DO
··· ' do other loop stuff
··· cntr = cntr + 1 * Chg············ 'If input stays HIGH· then EXIT
··· IF (cntr = 300) THEN EXIT······ 'The (cntr = 300) will need to be ADJ for how long it that the car to pass
· LOOP·····································'·the IR detector
············································· OR
Chg··· PIN··· 0························ 'You could use this to count the pauses between cars
cntr·· VAR··· Word
·cntr = 0
· DO
··· ' do other loop stuff
··· cntr = cntr + 1 * (1 - Chg)······· 'If input stays LOW then EXIT
··· IF (cntr = 300) THEN EXIT
· LOOP
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 4/28/2009 1:37:45 AM GMT
Manthern, radridz and I are looking for.
I will give it a try·- - it will probably take me quite a while to wander through this and experiment.
Regards,
Jim