Ho scale railroad project
PROJECT
HI,
· I HAVE AN HO SCALE RAILROAD ON A 4X8 FT TABLE WITH MANY TRACK SWITCHES,·A TURN TABLE, NUMEROUS SIDE TRACKS AND A·4 TRACK SWITCH YARD. AFTER GETTING INTERESTED IN AND LEARNING MORE ABOUT THE BS2 STAMP BY GOING THROUGH THE STAMPWORKS LAB AND THE BOE-BOT KIT, I DECIDED TO SEE WHAT I COULD DO WITH APPLYING·MY NEWLY GAINED AND·ELEMENTRY KNOWLEDGE OF A MICROCONTROLLER TO THE HO RAILROAD.
·· AFTER SEVERAL MONTHS OF TRIAL AND ERROR AND REWRITING A LOT OF CODE TO GET AN UNDERSTANDING OF WHAT'S HAPPENING, HERE'S A SIMPLE EXAMPLE OF WHAT I CAN DO AT THIS POINT.
···
···ENGINE LEAVES A SIDE TRACK AT ONE END OF THE·TABLE AND MAKES A COMPLETE ROUND (OR AS MANY AS YOU WANT)·-- THEN ENTERS A SIDE TRACK AT THE OPPOSITE END·-- WAITS A FEW SECONDS THEN BACKS OUT ONTO THE MAIN LINE,· REVERSES DIRECTION, MAKES ANOTHER COMPLETE TRIP (OR AS MANY AS YOU WANT)·AROUND THE TABLE ,STOPS, REVERSES·BACK INTO THE ORIGINAL SIDE TRACK.····· ·AFTER THIS SIMPLE TRIP THE POSSIBILITIES ARE UNLIMITED.
··· THIS LITTLE TRIP ENVOLVES WRITING CODE TO HANDLE A MOTOR CONTROLLER, TWO TRACK SWITCHES, AND TWO SETS OF (INFRED EMITTER & DETECTOR PAIRS).
··· WHAT I'M SORT OF PROUD OF IN THIS PROJECT IS THAT I HAD TO DESIGN A CIRCUIT MYSELF TO CONTROL THE TRACK SWITCHES, UTILIZING WHAT IS KNOWN AS A "DARLINGTON PAIR" OF TRANSISTORS AND SOME TRICKY CODE WRITING TO KEEP FROM BURNING THE SWITCHES OUT.· I ONLY BURNT UP ONE SWITCH BEFORE I FIGURED OUT WHAT I WAS DOING WRONG.
THE HARDWARE I AM USING TO RUN THE PROJECT IS AS FOLLOWS:
NX-1000 STAMPWORKS LAB BOARD
MOTOR MIND B·· MOTOR CONTROLLER -- FOR THE ENGINE
NPN TRANSISTORS -- FOR THE TRACK SWITCHES
INFRED EMITTER & DETECTOR PAIRS -- WHERE'S MY ENGINE?
··· NEXT I THINK I'LL TRY TEACHING MY ENGINE TO LEAVE IT'S SIDETRACK, WIND IT'S WAY THROUGH A BUNCH OF TRACK SWITCHES TO THE TURNTABLE, SWITCH ENGINES, AND BRING THE NEW ONE BACK TO THE ORIGINAL SIDE TRACK OR ANY OTHER SIDE TRACK BUT I'LL HAVE TO GET A BS2P40 WHICH HAS 32 PINS. I ONLY HAVE TWO PINS LEFT TO USE ON MY POOR LITTLE OLD BS2.
ATTACHED IS THE CODE THAT RUNS THE ENGINE THROUGH IT'S SIMPLE LITTLE TRIP AS MENTIONED ABOVE.
FEEL FREE TO SEND ME AN E-MAIL FOR ANY QUESTIONS OR ANY SUGGESTIONS THAT WOULD IMPROVE THIS PROJECT.
KLATUGORT@CHARTER.NET
TOMXX
·······
Post Edited By Moderator (Chris Savage (Parallax)) : 11/19/2005 5:44:54 AM GMT
HI,
· I HAVE AN HO SCALE RAILROAD ON A 4X8 FT TABLE WITH MANY TRACK SWITCHES,·A TURN TABLE, NUMEROUS SIDE TRACKS AND A·4 TRACK SWITCH YARD. AFTER GETTING INTERESTED IN AND LEARNING MORE ABOUT THE BS2 STAMP BY GOING THROUGH THE STAMPWORKS LAB AND THE BOE-BOT KIT, I DECIDED TO SEE WHAT I COULD DO WITH APPLYING·MY NEWLY GAINED AND·ELEMENTRY KNOWLEDGE OF A MICROCONTROLLER TO THE HO RAILROAD.
·· AFTER SEVERAL MONTHS OF TRIAL AND ERROR AND REWRITING A LOT OF CODE TO GET AN UNDERSTANDING OF WHAT'S HAPPENING, HERE'S A SIMPLE EXAMPLE OF WHAT I CAN DO AT THIS POINT.
···
···ENGINE LEAVES A SIDE TRACK AT ONE END OF THE·TABLE AND MAKES A COMPLETE ROUND (OR AS MANY AS YOU WANT)·-- THEN ENTERS A SIDE TRACK AT THE OPPOSITE END·-- WAITS A FEW SECONDS THEN BACKS OUT ONTO THE MAIN LINE,· REVERSES DIRECTION, MAKES ANOTHER COMPLETE TRIP (OR AS MANY AS YOU WANT)·AROUND THE TABLE ,STOPS, REVERSES·BACK INTO THE ORIGINAL SIDE TRACK.····· ·AFTER THIS SIMPLE TRIP THE POSSIBILITIES ARE UNLIMITED.
··· THIS LITTLE TRIP ENVOLVES WRITING CODE TO HANDLE A MOTOR CONTROLLER, TWO TRACK SWITCHES, AND TWO SETS OF (INFRED EMITTER & DETECTOR PAIRS).
··· WHAT I'M SORT OF PROUD OF IN THIS PROJECT IS THAT I HAD TO DESIGN A CIRCUIT MYSELF TO CONTROL THE TRACK SWITCHES, UTILIZING WHAT IS KNOWN AS A "DARLINGTON PAIR" OF TRANSISTORS AND SOME TRICKY CODE WRITING TO KEEP FROM BURNING THE SWITCHES OUT.· I ONLY BURNT UP ONE SWITCH BEFORE I FIGURED OUT WHAT I WAS DOING WRONG.
THE HARDWARE I AM USING TO RUN THE PROJECT IS AS FOLLOWS:
NX-1000 STAMPWORKS LAB BOARD
MOTOR MIND B·· MOTOR CONTROLLER -- FOR THE ENGINE
NPN TRANSISTORS -- FOR THE TRACK SWITCHES
INFRED EMITTER & DETECTOR PAIRS -- WHERE'S MY ENGINE?
··· NEXT I THINK I'LL TRY TEACHING MY ENGINE TO LEAVE IT'S SIDETRACK, WIND IT'S WAY THROUGH A BUNCH OF TRACK SWITCHES TO THE TURNTABLE, SWITCH ENGINES, AND BRING THE NEW ONE BACK TO THE ORIGINAL SIDE TRACK OR ANY OTHER SIDE TRACK BUT I'LL HAVE TO GET A BS2P40 WHICH HAS 32 PINS. I ONLY HAVE TWO PINS LEFT TO USE ON MY POOR LITTLE OLD BS2.
ATTACHED IS THE CODE THAT RUNS THE ENGINE THROUGH IT'S SIMPLE LITTLE TRIP AS MENTIONED ABOVE.
FEEL FREE TO SEND ME AN E-MAIL FOR ANY QUESTIONS OR ANY SUGGESTIONS THAT WOULD IMPROVE THIS PROJECT.
KLATUGORT@CHARTER.NET
TOMXX
·······
Post Edited By Moderator (Chris Savage (Parallax)) : 11/19/2005 5:44:54 AM GMT
Comments
Also, you should title your post to something like "HO model railroad controller"
Other than that, nice job on your project!
Have you thought of using a few 74HC595 Shift registers? And if you need input you can use a 74hc597.
They are awesome, fast, and can increase your outputs 100 fold.
Check out the "expanding outputs further" stampworks file.
www.parallax.com/dl/docs/books/sw/exp/sw23b.pdf
Also checkout expanding INPUTS further to detect many infared and other INPUTS!!!
www.parallax.com/dl/docs/books/sw/exp/sw24b.pdf
If you use the two chips together you can achieve an amazing amount of input and output combinations.
There is ALOT of info here on shift registers, just do a forum search on 595, and 165 or 597
The 74hc595's title is a "serial input, parallel output shift register"
The 74hc597's title is a "parallel input, serial output shift register" ----> many on this forum also use the 74hc165 instead of the 74hc597.
Also if your using alot of darlington's up in your project, you might be able to get away with using a IC pack of them, the ULN2003 chips have 7 TTL input, darlington output transistors. Depending on the amperage you use of coarse. Just review the datasheet, and attach a IC heatsink if your near the limits of the IC. Plus they are cheap if you fry a few in the testing phase.
I have a bunch of 595's 597's and uln2003's It seems these 3 chip types are almost limitless in their use when it comes to project design with stamps.
Have fun!
Post Edited (BPM) : 11/19/2005 6:37:56 AM GMT
It is a 8 channel darlington array that only requires 4 pins to operate in latched mode. There is also the possibility of using 2 of them whose inputs are directed by a 595, this would give you 16 darlington outputs using only 3 pins on the stamp (Serial, Clock, Latch), by cascading multiple 595s you could practically have as many darlington outputs using still only 3 pins on the stamp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Thank you for your post on the HO railroad controller - - quite a project to say the least.
This February I started a HO switching project i using the OEM BS-2, an·IR Detection system as outlined in the
Boe-Bot manual.··Direction is controlled with an "H" bridge and·the turnouts controlled by·servos,
but, it appears that the dual-coil switch machines are going to be the answer.
Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike2545
This message sent to you on 100% recycled electrons.
Actually I started this little switching layout after my wife and I worked·the NMRA Booth and our Club Booth at·the·local train show·in late·January '09.
I was amazed at the number of people that would stand and watch a train on our 42" x 72" club oval.· That
started me thinking about how interesting it would be if a 12" x 60" switching and uncoupling network could
be built.
After spending two to three weeks reading the Parallax Manuals, plus roaming around the web, the questions and uncertainty I had were being answered.
Completion is almost at hand.· There are three electromagnetic uncouplers to wind, a 74C4049 Hex Inverter to add after moving the emitters from a reflective configuration to a "break-beam" method.· (I found the relflective method did not always react to the dark locomotives).
Then, then only the really·hard part is left........programming!!
By the way, do you know of any programming books that provide an outline or logic layout for a program?
Over the years I have read the QBasic programming manual published by Que, as well as IBM Basic.
I think my problem with some of the programming is in the layout of the program itself.
Regards,
Jim
No, no, no. You've got it all wrong (stretch out the 'all' and roll the head) Programming is the easy part! [noparse]:)[/noparse]
Anyway, what you're looking for is how to design algorithms. In essence, that's what a computer science degree (should) teach the graduates: how to solve a problem. People dedicate their whole lives to the topic, but for your project you could probably get by with a couple of weeks.
Here's how I like to program:
When you're somewhere where you have to be but don't really want to be (history class for me, or the bus, or the train, etc.) have a pencil and paper handy. Write out your entire program or the pseudo code for your program, and try to think of everything that might break it (bad inputs getting it stuck). Make sketches of the flow, what happens when, what is connected to what, etc. The important part is to figure out (nearly) everything before you go to the computer and start programming.
I hope this method helps.
Cheers.
Thank you for your reply - - I started doing that this morning based upon Tomxx's original post.··
I printed his program and began·studying the structure and discovered that·my attempt has been
to put too many activities into the original premises.· It appears that most of the control activities, at least in this case, is generously using·the sub-routines.
It appears to me that most of the program, at least in this project, would reside in the sub-routines
until the logic changes a given state.
I appreciate the help - - Since my Majors were Business and Economics, programming and electronics
are quite divergent, except my hobby over the past 53 years has been Ham Radio.
Regards,
Jim
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Manetheren
For what it's worth, I wrote up an article on a circuit I designed called The TrainSaver- a Parallax BS-1 powered train controller that was designed to reduce the wear and tear on a G scale train running around the inside perimeter of a local BBQ restaurant here in Austin. The article, complete with lots of pictures, source code and a logic flow chart was published in the July 2006 issue of Nuts and Volts magazine. You can read the article here if you like.
Vern
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Vern Graner) : 5/18/2009 10:23:04 PM GMT
Excellent job on the documentation in your program!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Shawn Lowe
When all else fails.....procrastinate!