Sunday, June 21, 2020

Moving on to Another Project


So on Friday this week and today, Sunday, I have been concentrating on writing code on my Arduino Uno for a level crossing detector circuit.  I have two level crossings on my layout that I want to have working crossing lights.  These are located either side of Cassino station.  One is located on the Bruxner Highway south of Cassino and the other is located on the north side of Cassino at Hotham Street.  These are the two level crossing that I want to be working models.  There just happens to be another level crossing east of Cassino at West Street (go figure?) which is on the way to Old Cassino.  There is one other major level crossing just south of Fairy Hill Loop, which I am calling Fairy Lane.  I am undecided if I will also implement a working level crossing at these other locations, or just have stop signs or give way signs.  Time will tell.

So I have been undertaking some testing with four infrared detectors and the onboard LED on the Arduino to simulate the level crossing lights activating and I can say it works like a charm for the purpose I intend to use it.  It is written for bi-directional single track.  It uses 4 detectors, two for the UP direction and 2 for the DOWN direction.  The concept is that independent of direction, there is an outer detector to trigger the detector to initiate the flashing of the level crossing lights when the train is still some distance away, and an inner detector that turns off the flashing lights as the last wagon has left the crossing.  It then has code to ignore the outer detector in the opposite direction and once the train has cleared that point, the detector is then read to detect another cycle of train movement.  I’m very impressed that I have not lost my code writing mojo.  I haven’t really written code for quite some years.  Voila level crossing detector!

Now I do not know if there is any need to write some additional code to reset the detector in case it gets itself into a knot.  Something to issue a reset if the train goes missing between the detectors, like if it derails and I remove it from the layout.  I will think about that, and maybe work on how I would do that.  I’m sure the Arduino code could be modified quite easily to cater for two uni-directional tracks on a double track mainline as well, but I do not have any need for this myself.

So this code is available to anyone who wishes to run their own level crossing detection circuit for single bi-directional track for free, if anyone wants it.  You just need, four infrared detectors from eBay for about $4 each and 4 LEDs to act as two level crossing lights, your own ARDUINO (approx $11 for a UNO from eBay), and maybe you may need to alter the code for your preferred Arduino model, given the number of ports available on your model etc.  You are also free to modify it for double track if that suits you.  Just contact me via the Blog and give me your email address, or send me an email.

I still need to do some testing as to how I would install the detectors between the rails, but that is next weekend’s job.

Now I still have an aim to build a better version of ‘Shelton the Photographer’.  Marcus keeps improving on the electronics in his version to make it a self-contained unit.  I went to Jaycar today and purchased some of the items that the new circuit developed by Marcus required, but I have not yet assembled all the components yet.  I was too busy with the level crossing detector.  Did I mention I’m rapped with that circuit and code? 

Yesterday I jumped in a car with Dazza and Geoff and then we picked up Brendan and then went for a visit to Toowoomba about 150km away for the day.  We initially went to Bill’s place and there we met up with Bazz, Smithy and Steve.  After lunch we went to Steve’s place and then returned home safely just after 6:00pm last night with Dazza driving – thanks mate.  It was a very good day indeed and perhaps we were able to help Bill make some decisions about the design of his next layout.  Thanks everyone.

So next week, there will be some modelling on Saturday and a birthday party on Sunday.  I might also be able to have a half day on Friday to do some more modelling.  I’m still looking for that elusive Lotto win that will allow me to give up work.

1 comment:

  1. Interesting, I too will eventually be building a level crossing with a detection circuit powered by an arduino - I did begin looking into it but lost interest - so looking forward to see how you go with yours.

    ReplyDelete