Sunday, July 5, 2020

Installing the Flashing Level Crossing Lights on the Bruxner Highway


The first task after work on Friday afternoon was installing one of my infrared (IR) detectors under the baseboard in a section of test track and determining if they will trigger the Arduino circuit, when nestled down below the track.  So that was tested and it proved successful.  I just need the LED’s top to just protrude above the ballast.  I then moved onto improving and writing some more code for my various Arduino projects.  First I improved my level crossing circuit, by adding a reset button and logic throughout the code.  Basically if we lose a train somewhere in the circuit, or someone accidentally triggers the level crossing by their hand moving over a detector, we now have a way of turning the level crossing circuit off and allowing it to sit and wait for a real train trigger event.  The reset feature seemed to work well in my testing. 

The next project I started to work on was the traffic light code for my Arduino.  So I wrote that and tested it just with print statements to track what it was doing.  It seems to work well.  My set of “traffic lights” code has a random length of time set for the main road to have a green light followed by another random shorter length of time for the side road ‘T’ intersection to have its turn at a green light.  The logic also has a random yellow flash sequence, for a random duration of time, that can pop up occasionally to amuse people looking at the set of traffic lights.  I have some traffic signals on order, and they might get here by August sometime.   This will be another fun project to implement.  Next weekend I will replace the print statements with actual triggering of the various LED outputs in the program in readiness for the arrival of the lights.  I have a selection of red, green and yellow LEDs that I can wire up on my breadboard to test the two directions at the set of lights.  I just need to find a few 1K ohm resistors.

So Saturday morning was spent trying to find what sort of level crossing lights I might have around to install.  I found the first two crossing lights, and after about another 30 minutes of looking, I confirmed my suspicion that I indeed did have another 2 crossing lights hidden in the shed.  Now I looked at the lights but I could not work out if they had LEDs or miniature light bulbs in them.  My Arduino is only supposed to power LEDs.  I wanted to be sure what they were LEDs.  I was scratching my head, then I realised, of course it is easy to determine if they were LEDs or globes.  LED’s only conduct power in one direction.  So I got out a 3V battery power supply and connected up the flashing lights in the level crossing.  Yes they only lit in one direction and not when I reversed the power to them.  So they were LEDs.  That is a good start.

I then drilled my first hole in the baseboard for the’ Up Outer’ detector for the Bruxner Highway level crossing.  I then realised that next three detectors will be difficult to install.  I have a section of track below them, so I can’t get my drill underneath to drill out the hole for the detector. I had a think about the installation method over lunch.  So after lunch I reverted to the drill from the top in all different angles to make a hole larger underneath.  Basically I used the drill as a bit of a saw.  I test fitted the detectors and they all fitted with the detectors just having their LEDs protruding through the ballast.

So this morning, I was again scratching my head as to where to put the Arduino for the Bruxner Highway level crossing?  I decided I’d make a little shelf about 4” square for the Arduino.  I then started laying wires from each of the detectors back to the shelf.  I soldered all the GND and positive power cables for the detectors to a single point, and then back to the Arduino.  I then wired all the IR trigger connections back to separate points and then from there to the Arduino.  Then I connected the level crossing lights to the Arduino.  Everything seemed to be travelling smoothly.  Oh look, there is Mr Murphy.

Then came the test.  My bad soldering caused a short to the Arduino.  So I used a sharp knife blade to ensure that there was bridging causing the short between two solder pads on my distribution PC board, and then we had a wire come loose on the PC board.  So after fixing this, the detectors came live.  But my level crossing would not flash.  I realised that I had the common wire from the LEDs connected to the GND terminal and not the 5V positive.  So that was fixed and magic!

I actually ran a wagon through the crossing and it worked.  I then set about studying the implementation a bit closer.  I appears that I may have a bit of a logic bug in my crossing code.  Instead of the inner detectors once triggering to signify that the train has reached the opposite side of the crossing, it does not then wait until that trigger has stopped (i.e. the whole train has passed that detector).  So in my case I turn off the flashing lights as soon at the nose of the train gets to the other side of the crossing.  So later tonight I will add another “do … while” loop to the code to cater for this oversight.

So next Friday I will take the Arduino back down to the shed with my upgraded code and give it another test.  I might even take a video.

Today I have ordered another two Arduino’s, so if I am still motivated, I might look at the installation of the crossing lights at Hotham Street level crossing as my next project.  The issue with this project is that I had a set of point very close to the level crossing at both ends.  I will need to ensure that I can trigger the activation from the track that had the points set for it.  So I might need multiple detectors at each end.  Then I will have to work out if I am going to also install another set of flashing level crossing lights (which I don’t have) on the Fairy Lane level crossing.  I haven’t spent any time thinking about this as yet.  If I do, I am going to require a few more Infrared detectors from eBay.

1 comment:

  1. Well done Craig - what is the part number or link that you used for the infrared leds?
    Shelton

    ReplyDelete