JOHN BRYAN
My interests include trains, model railways, performing music, electronics, computing, cooking and gardening.
Friday, May 24, 2019
Tuesday, May 21, 2019
ARDUINO - PART TWO: STARTING OUT
So, you have bought your first ARDUINO UNO R3 or one of its many clones.
You also have a USB cable so that you can plug it in to your computer.
Let's get under way.
You need to arm yourself with some software.
[CLICK ON AN IMAGE IF YOU WISH TO ENLARGE IT]
[HIT ESCAPE TO RETURN TO THE BLOG]
Search in your browser for ARDUINO and visit the website by directly clicking on <Software>
Navigate to this page and DOWNLOAD the IDE which matches your operating system and if you speak English - the appropriate language version.
Once downloaded, install the ARDUINO IDE software on your computer, and see if you are able to open a page where a new 'SKETCH' might begin. We will begin our ARDUINO journey here in a little while...
While you are online you might also check out the ARDUINO site itself starting from the HOME page. The WHAT IS ARDUINO? tab explains the history and some FAQ about the boards and what they do, and how to use them.
The drop down menu at the RESOURCES TAB has many interesting things...
A PRODUCTS TAB gives a brief description of each product and suggests possible uses for each device.
A GETTING STARTED TAB outlines how to start using any of the products in a very straight-forward step-by-step explanation.
A TUTORIALS TAB gives you access to examples of how to use and program your ARDUINO, again in simple language.
A REFERENCE TAB is like a dictionary, explaining how each programming word works, and giving tiny examples of how to use it.
AND if you search in the COMMUNITY TAB you will find libraries of programs you can copy or adapt.
AND the TUTORIAL section also contains its own library of programs which in ARDUINO LAND we call SKETCHES.
[THIS IS THE END OF THE STARTING OUT PAGE]
[LOOK OUT FOR OTHER POSTS WHERE YOU WILL FIND BEGINNER SKETCHES]
[SO: MORE TO COME]
You also have a USB cable so that you can plug it in to your computer.
Let's get under way.
You need to arm yourself with some software.
[CLICK ON AN IMAGE IF YOU WISH TO ENLARGE IT]
[HIT ESCAPE TO RETURN TO THE BLOG]
Search in your browser for ARDUINO and visit the website by directly clicking on <Software>
Navigate to this page and DOWNLOAD the IDE which matches your operating system and if you speak English - the appropriate language version.
Once downloaded, install the ARDUINO IDE software on your computer, and see if you are able to open a page where a new 'SKETCH' might begin. We will begin our ARDUINO journey here in a little while...
While you are online you might also check out the ARDUINO site itself starting from the HOME page. The WHAT IS ARDUINO? tab explains the history and some FAQ about the boards and what they do, and how to use them.
The drop down menu at the RESOURCES TAB has many interesting things...
A PRODUCTS TAB gives a brief description of each product and suggests possible uses for each device.
A GETTING STARTED TAB outlines how to start using any of the products in a very straight-forward step-by-step explanation.
A TUTORIALS TAB gives you access to examples of how to use and program your ARDUINO, again in simple language.
A REFERENCE TAB is like a dictionary, explaining how each programming word works, and giving tiny examples of how to use it.
AND if you search in the COMMUNITY TAB you will find libraries of programs you can copy or adapt.
AND the TUTORIAL section also contains its own library of programs which in ARDUINO LAND we call SKETCHES.
[THIS IS THE END OF THE STARTING OUT PAGE]
[LOOK OUT FOR OTHER POSTS WHERE YOU WILL FIND BEGINNER SKETCHES]
Monday, May 20, 2019
ARDUINO - PART ONE: A TASTER - BOUNCING SIGNALS & SPEED TRAP, AND SOME SHOPPING
In this post I am only going to put up the videos of my two ARDUINO demonstrations, and provide images of the products used, as they are currently available at JAYCAR. Prices are at today's prices in Australian dollars. I will go into depth about programming the ARDUINO in following postings.
[CLICK THE BOX IN THE LOWER RIGHT CORNER TO WATCH VIDEOS FULL SCREEN][CLICK AGAIN IN THAT BOX TO RETURN TO THE BLOG]
In this video we witness my mock-up of a NSW 3-aspect upper-quadrant signal. There were many of them used in the Newcastle district. In the final version, the signal arm will be 3D-printed, there will be LED illumination behind the spectacle plate, the signal mast will be much finer scale [!], and the servo will be mounted below the baseboard.
The cat fur is NOT prototypical!
The signal can be programmed to drop prototypically to DANGER as a train passes it, and then after a time delay, rise to the CAUTION indication, before finally rising to CLEAR after a further delay. Signals bounce because their weight (or their counterweight in the case of lower quadrant signals) contains stored energy, which is released upwards again on impact, in ever diminishing amounts, like a tennis or basketball. I have tried to program this reaction to gravity into this signal. To see the real thing in action, try this link.
https://www.youtube.com/watch?v=_JmoeKavzII
VIDEO CREDIT: Bevan Wall [bwDVD]
These are the components in this demonstration.
[CLICK ON THE IMAGES TO SEE THEM FULL SCREEN]
The speed trap.
This program is a lap timer and runs continuously giving a read-out of the time taken and the speed in kph. It could just as easily be programmed to give mph. The ARDUINO is shown in the demonstration as a stand-alone operating under battery power. If connected to your PC or laptop, it can print the times and speeds to your computer screen, and the LCD display would not be required.
While you are on the job, if you do not already have your own leads on hand, you may consider getting these. The mixed set of breadboard leads is probably a good starter set. Over time I find the most useful types being the male/male and the male/female; as opposed to the female/female leads I hardly ever use. It is worth paying extra and getting the heavy duty alligator leads.
You may also find it useful to acquire a breadboard to help with some of our experiments. They come in various sizes, and all are useful. Here is a small one.
We are also going to need a cable such as this one to connect our ARDUINO to our computer for programming. You may already own one as it came/comes supplied with many devices such as printers and scanners.
If you are also thinking of building the speed trap laptimer you might consider getting a circle of track such as this from BACHMANN. Shown is a pack of 18" radius EZ TRACK containing 4 pieces - you will need 3 packs.
[CLICK THE BOX IN THE LOWER RIGHT CORNER TO WATCH VIDEOS FULL SCREEN][CLICK AGAIN IN THAT BOX TO RETURN TO THE BLOG]
In this video we witness my mock-up of a NSW 3-aspect upper-quadrant signal. There were many of them used in the Newcastle district. In the final version, the signal arm will be 3D-printed, there will be LED illumination behind the spectacle plate, the signal mast will be much finer scale [!], and the servo will be mounted below the baseboard.
The cat fur is NOT prototypical!
The signal can be programmed to drop prototypically to DANGER as a train passes it, and then after a time delay, rise to the CAUTION indication, before finally rising to CLEAR after a further delay. Signals bounce because their weight (or their counterweight in the case of lower quadrant signals) contains stored energy, which is released upwards again on impact, in ever diminishing amounts, like a tennis or basketball. I have tried to program this reaction to gravity into this signal. To see the real thing in action, try this link.
https://www.youtube.com/watch?v=_JmoeKavzII
VIDEO CREDIT: Bevan Wall [bwDVD]
These are the components in this demonstration.
[CLICK ON THE IMAGES TO SEE THEM FULL SCREEN]
[HIT ESCAPE TO RETURN TO THE BLOG]
The speed trap.
This program is a lap timer and runs continuously giving a read-out of the time taken and the speed in kph. It could just as easily be programmed to give mph. The ARDUINO is shown in the demonstration as a stand-alone operating under battery power. If connected to your PC or laptop, it can print the times and speeds to your computer screen, and the LCD display would not be required.
While you are on the job, if you do not already have your own leads on hand, you may consider getting these. The mixed set of breadboard leads is probably a good starter set. Over time I find the most useful types being the male/male and the male/female; as opposed to the female/female leads I hardly ever use. It is worth paying extra and getting the heavy duty alligator leads.
You may also find it useful to acquire a breadboard to help with some of our experiments. They come in various sizes, and all are useful. Here is a small one.
We are also going to need a cable such as this one to connect our ARDUINO to our computer for programming. You may already own one as it came/comes supplied with many devices such as printers and scanners.
NOSE-TO-TAIL STORAGE/STAGING - PART TWO
We are running DCC trains on our layout and we have them in a storage system that runs them nose-to-tail. Can we do this with TWO or more NCE MINI PANEL micro-controllers?
Thomas along with Annie and Clarabel have run into our storage system. They ran up to our blue sensor and were held there for a while by the red MINI PANEL conroller. Now it is time for them to run out onto the mainline, and run at faster speeds controlled by a second MINI PANEL that we will call green. In this image Thomas is crossing over from one section to the other. If this were a DC world, we could accept this practice. For a brief moment there is a blip while the locomotive straddles both sections and some of the higher voltage green section bleeds back into our lower powered storage section. It does not create too much fuss.
BUT, in a DCC world, while Thomas is straddling the two sections, and allowing the digital commands to mix, another locomotive being held in storage may have seen a command issued by the green controller for it to run faster. Once Thomas leaves the section, that locomotive may continue to hold-on to that erroneous command, and 'run-away' at faster speed into the back of another stored train. Obviously we cannot allow this to happen!
So we need to factor in a 'handover' period where the red controller takes charge of part, or ALL of the mainline for a long enough period so all locomotives in the train reach the mainline section, before the green controller takes over.
It is possible to have a short section of mainline track wired to accommodate this HANDSHAKE period, long enough to accept the length of your 'head-end' power [one, two, three or four engines]. Including this section of handover-track, avoids having to give control of ALL the mainline to the red controller.
However, some layouts will feature trains with helper or bank engines spread throughout the train, or bankers on the rear; in which case the delay will need to be much longer, until ALL of the train has passed the sensor; and then allowing a further few more seconds grace period after that. If you have a handover section, that may need to be long enough to accept your longest train.
Consider that some passenger trains may also have power units front, middle and/or rear, AND the wheels/tyres of some coaches with lighting will also manage to straddle the gap between sections, creating the same cross-contamination. My XPT will keep oscillating. It will have power at the front-of-the-train one trip, and rear-of-the-train on the next outing.
Success! Thomas has made it safely into the new section. The HANDSHAKE is over, the green controller is fully in charge now, and Thomas may now run at mainline speed, and he won't be meddling with the decoders of any other engine held in the storage sidings.
[CLICK ON EACH IMAGE TO SEE IT FULL SCREEN]
[HIT ESCAPE TO RETURN TO THE BLOG]
BUT, in a DCC world, while Thomas is straddling the two sections, and allowing the digital commands to mix, another locomotive being held in storage may have seen a command issued by the green controller for it to run faster. Once Thomas leaves the section, that locomotive may continue to hold-on to that erroneous command, and 'run-away' at faster speed into the back of another stored train. Obviously we cannot allow this to happen!
So we need to factor in a 'handover' period where the red controller takes charge of part, or ALL of the mainline for a long enough period so all locomotives in the train reach the mainline section, before the green controller takes over.
It is possible to have a short section of mainline track wired to accommodate this HANDSHAKE period, long enough to accept the length of your 'head-end' power [one, two, three or four engines]. Including this section of handover-track, avoids having to give control of ALL the mainline to the red controller.
However, some layouts will feature trains with helper or bank engines spread throughout the train, or bankers on the rear; in which case the delay will need to be much longer, until ALL of the train has passed the sensor; and then allowing a further few more seconds grace period after that. If you have a handover section, that may need to be long enough to accept your longest train.
Consider that some passenger trains may also have power units front, middle and/or rear, AND the wheels/tyres of some coaches with lighting will also manage to straddle the gap between sections, creating the same cross-contamination. My XPT will keep oscillating. It will have power at the front-of-the-train one trip, and rear-of-the-train on the next outing.
Success! Thomas has made it safely into the new section. The HANDSHAKE is over, the green controller is fully in charge now, and Thomas may now run at mainline speed, and he won't be meddling with the decoders of any other engine held in the storage sidings.
[CLICK ON EACH IMAGE TO SEE IT FULL SCREEN]
[HIT ESCAPE TO RETURN TO THE BLOG]
Sunday, May 19, 2019
NOSE-TO-TAIL STORAGE/STAGING - PART ONE
To control my trains in the spiral staging I need a means of keeping them apart. If I were running a purely DC layout, I might arrange electrical blocks, with gaps cut in the track. My trains would be running at low speed, but even so, when they reached an infra-red sensor (or any type of sensor for that matter - reed switch, photoresistor, LDR, light dependent resistor), when they reached that sensor and the relay opened they would come to a shuddering halt. When power is restored, the train will lurch off, and go on its merry way.
I am not being overly critical - that is how it is. It works! Since it is in a fiddleyard, the public will not see this unprototypical behaviour. The system will also run DCC, but again when the relay is triggered the train will come to an abrupt stop - more gentle if a stay-alive is fitted - and care must be exercised, that such locos do not over-run into the next section. Set the speed of locos in staging slow enough, so this does not occur. Leave sufficient gap between the sensor and the next section. Also, the sound (if fitted) will stop - the DCC train will be effectively dead. If the same DCC feed is then restored to the tracks, the train will take off, as it would following a power drop-out due to a short-circuit.
Here is an infra-red sensor from Heathcote Electronics in the UK...
http://www.heathcote-electronics.co.uk/
Heathcote Electronics products are imported and promoted in Australia by Warren Herbert and his company Gwydir Valley Models, from Glen Innes, NSW.
http://www.gwydirvalleymodels.com/
Most devices come under the title IRDOT - Infra-Red-Detection-Of-Trains.
Here is one such product - an IRDOT 2 - and on the right hand side, two black boxes marked OKO. These are the relays. Each one is a single-pole-double-throw relay, but together they represent a DPDT switch (which comes standard with most DC controllers to allow locomotives to be reversed).
[CLICK ON THE IMAGES TO SEE THEM FULL SCREEN]
With an IRDOT 2 (with relays) in conjunction with an IRDOT 1 (which has no relays) placed a distance apart on a section of track, it is possible to run a locomotive or train backwards and forwards between the two sensors in a shuttle operation. At each end, the train can be held stationary for a controllable period of time, then the DPDT switching by the relays will reverse the current, and the train will head off in the opposite direction and continue indefinitely doing the same thing at either end of the track. Here is a simple demonstration of that operation on a section of test track and a DC locomotive.
[CLICK THE BOX IN THE LOWER RIGHT CORNER TO WATCH VIDEOS FULL SCREEN] [CLICK AGAIN IN THAT BOX TO RETURN TO THE BLOG]
Using the same section of test track, and just two sensors (we do not need the relays on this occasion) wired to an NCE MINI PANEL we can control a DCC locomotive to run with far greater subtlety. We can do slow starts, we can brake gently to a stop - no jerks - and we can include whistles, lights and bells (if available and required).
In this image we can see the two wires running back to the MINI PANEL from the sensors, then a spiral cable connecting the MINI PANEL to a SB5 smart booster, that is actually controlling the train, with the commands coming from the MINI PANEL.
When more trains enter storage, they close-up nose-to-tail behind trains that have previously entered staging. BLUE Thomas is already being held. If he were to leave, both relays would close, and power from the second relay would energize PINK Thomas to move up. That is NOT going to happen just now, we want to see what happens to GREEN Thomas. He is receiving power because the green relays are closed. Not only does he have power in the section he is in, but also in the section ahead of him. He will run all the way up to the green sensor, open those relays and stop. If BLUE Thomas is released, the other two will advance, in that ABRUPT manner I have been speaking about, until they are also waiting, ready for their turn on the layout.
I am not being overly critical - that is how it is. It works! Since it is in a fiddleyard, the public will not see this unprototypical behaviour. The system will also run DCC, but again when the relay is triggered the train will come to an abrupt stop - more gentle if a stay-alive is fitted - and care must be exercised, that such locos do not over-run into the next section. Set the speed of locos in staging slow enough, so this does not occur. Leave sufficient gap between the sensor and the next section. Also, the sound (if fitted) will stop - the DCC train will be effectively dead. If the same DCC feed is then restored to the tracks, the train will take off, as it would following a power drop-out due to a short-circuit.
Here is an infra-red sensor from Heathcote Electronics in the UK...
http://www.heathcote-electronics.co.uk/
Heathcote Electronics products are imported and promoted in Australia by Warren Herbert and his company Gwydir Valley Models, from Glen Innes, NSW.
http://www.gwydirvalleymodels.com/
Most devices come under the title IRDOT - Infra-Red-Detection-Of-Trains.
Here is one such product - an IRDOT 2 - and on the right hand side, two black boxes marked OKO. These are the relays. Each one is a single-pole-double-throw relay, but together they represent a DPDT switch (which comes standard with most DC controllers to allow locomotives to be reversed).
[CLICK ON THE IMAGES TO SEE THEM FULL SCREEN]
[HIT ESCAPE TO RETURN TO THE BLOG]
With an IRDOT 2 (with relays) in conjunction with an IRDOT 1 (which has no relays) placed a distance apart on a section of track, it is possible to run a locomotive or train backwards and forwards between the two sensors in a shuttle operation. At each end, the train can be held stationary for a controllable period of time, then the DPDT switching by the relays will reverse the current, and the train will head off in the opposite direction and continue indefinitely doing the same thing at either end of the track. Here is a simple demonstration of that operation on a section of test track and a DC locomotive.
[CLICK THE BOX IN THE LOWER RIGHT CORNER TO WATCH VIDEOS FULL SCREEN] [CLICK AGAIN IN THAT BOX TO RETURN TO THE BLOG]
Using the same section of test track, and just two sensors (we do not need the relays on this occasion) wired to an NCE MINI PANEL we can control a DCC locomotive to run with far greater subtlety. We can do slow starts, we can brake gently to a stop - no jerks - and we can include whistles, lights and bells (if available and required).
In this image we can see the two wires running back to the MINI PANEL from the sensors, then a spiral cable connecting the MINI PANEL to a SB5 smart booster, that is actually controlling the train, with the commands coming from the MINI PANEL.
This is the beast doing all the heavy-lifting - an NCE MINI PANEL. In a future post I will describe how to program this device.
Returning to our DC fiddleyard - let's try to store a train. Thomas approaches with Annie and Clarabel, and runs all the way through the yard to the blue sensor. We want him to wait here, so when the relays open he stops, with a bit of a shudder. If we want him to go onto the mainline and do some work, we press the blue button, which supplies some power, and Thomas lurches off with his coaches onto the layout.
When more trains enter storage, they close-up nose-to-tail behind trains that have previously entered staging. BLUE Thomas is already being held. If he were to leave, both relays would close, and power from the second relay would energize PINK Thomas to move up. That is NOT going to happen just now, we want to see what happens to GREEN Thomas. He is receiving power because the green relays are closed. Not only does he have power in the section he is in, but also in the section ahead of him. He will run all the way up to the green sensor, open those relays and stop. If BLUE Thomas is released, the other two will advance, in that ABRUPT manner I have been speaking about, until they are also waiting, ready for their turn on the layout.
It is possible to program the same thing into a MINI PANEL and run a nose-to-tail storage yard with DCC. [Again, I will describe the programming of MINI PANELs in a separate post.] In the following video we see three locos being controlled, and there are three IRDOT sensors set up as well. One locomotive enters the mainline and runs through our beautifully landscaped layout and returns to the fiddleyard behind the scenes - the yard is full - so it is held short of the entry point. The next loco then moves up, and the third, making way for the waiting engine to go into storage. Once this happens, the lead engine can take to the layout and do its tour of duty.
We can observe one of the downsides to this system - the MINI PANEL is quite linear - it does not do well at multi-tasking - it can only take on one job at a time. It can only run one engine at a time. In fairness, it does a great job at this, gently accelerating and braking our locomotives. We could have this system running out on the mainline in public view, stopping trains very gently at signals and starting them again, (also very gently) when the line is clear. I am sure the public and occasional visitor would be impressed. [In a future post, I will discuss how this is achieved.]
BUT... if we want to have one MINI PANEL controlling the yard, and one MINI PANEL controlling the mainline, the two controllers are going to have to HANDSHAKE. There is a problem running a loco between two controllers. When it crosses over from one to the other, the engine's wheels allow signals to cross-contaminate section A and section B. So during the electronic handshake, we build in a delay, allowing the train leaving section A to completely leave that section before the possibly FASTER power for section B is applied. The handshake will also have to be applied when the loco leaves the mainline section and returns to the yard.
This operation too will be the subject of a future post.
Subscribe to:
Posts (Atom)
ARDUINO - PART THREE: FIRST STEPS
[THIS SERIES COMING SOON]
-
Here is my current design for a Newcastle layout drawn using AnyRail. It is based on the 1937 track plan you can see below. The station t...
-
We are running DCC trains on our layout and we have them in a storage system that runs them nose-to-tail. Can we do this with TWO or more NC...
-
This is how my spiral is designed. It is flat in the middle which makes it easy for a person to reach in and adjust any equipment that need...