Sunday, July 12, 2020

Checking the Code For the Level Crossing Actuator


Well I checked the code on my level crossing actuator system last Sunday night, and the code seemed correct.  The issue that occurred the previous weekend should not have occurred.  But if I put a delay of 50 milliseconds between one “do while” Loop and the second “do while” Loop the code now waits until the train passes the detector.  Without the delay statement, it just falls through the code.  It shouldn’t.  I can live with the 50 millisecond delay between checks for when the train reaches the detector on the other side of the crossing, and until the detector is clear.    Oh well.  It seems to work now.  I put this down to a sensor de-bounce occurring in the actuation.  However upon further testing later in teh week, on Friday and Saturday afternoon, the turning off of the sensors on a long train was causing some more issues.  So I added some specific debounce code to cater for wagons with an open underframe that seem to produce a 'no wagon' reading sensor result when there is actually a wagon there - sitting over the sensor.  So after lots more testing, it now seems to be running quite well.  There were some more tweaks undertaken after I added the sensor debounce code, as this tight loop, stopped the crossing lights from flashing as quickly as they should.  So this was easily fixed in the code.

A video of the train operating across the Bruxner Highway level crossing.

I had been studying the various photos that I had of the level crossings I am installing on the layout.  While they show that there are one set of level crossing flashers on each side of the track, each have flashing lights showing in each direction.  Most of the level crossing lights you get only show lights in one direction.  Given that my lights are all LED lit, I thought that I might have been able to just solder an LED onto the back of the existing lights and then build up some light shrouds from 4mm styrene tube and a round backing plate.  So on Monday night I soldered a second LED to back of each of the existing LED’s so the flashing lights are bi directional.  I did this to two sets of flashing lights. 

On Tuesday after work, I made a quick trip to Jaycar to pick up a couple more red LEDs, to finish the last set of flashing lights.  That was completed later that night.  But after installing the second LED to the rear of the existing LEDs, a couple of the original stopped working.

So on Wednesday I bit the bullet and removed the original LEDs that were no longer working and new LEDs were filed down to fit into the existing brass light housings and then the LED leads were soldered to the new LEDs and low and behold it was just like a bought one.  Earlier on Wednesday I was thinking about how I was to make a round disk behind the light housing for the rear facing LEDs.  I initially thought that I’d use a piece of styrene and drilling a 3mm hole in the middle.  Getting a round piece of styrene was problematic, as well as getting the hole dead in the middle.  Hmmmmm.  I thought that I must have some small metal washers, and sure enough, and they already had a large enough hole.  So I painted them black and left them to dry overnight.

On Thursday I cut down the rear light housings to a tapered shape and then painted them black.  Once dry everything was glued together and was then ready to place on the layout.  I just haven’t done it yet.

So on Saturday I commenced the installation of the second set of level crossing flashers - this one on Hotham Street, by drilling holes for the sensors and the level crossing lights.  So today I did a bit more work on the crossing, but I started by fixing up some layout fascia in that area and made a small shelf to install the Arduino on.  I have run the wires for half the sensors and I will complete the installation next weekend.

Another thing I did on Saturday evening was to update the code for my Arduino traffic light project.  This now triggers the various red, yellow and green lights.  This is also intended to be have installation commence next weekend as well.

2 comments:

  1. wow Craig - you really have been very industrial this week! Good work on the crossing lights as well. Interesting about the skeleton container wagons and the sensor not detecting!
    Regards

    ReplyDelete
  2. Well done Mr Mackie. It looks schmick!

    ReplyDelete