Sunday, June 28, 2020

New Priorities


So on Friday I was down the shed in the afternoon trying to take some photos for a project.  Not sure if it was a success.  Saturday morning I made it to the hobby shops looking for something, which no one seemed to have.  In the afternoon I spent time on two activities.  The first was making up a little cross section of track that I will be using to test options for mounting my infrared detectors on for my level crossing.  The other activity was spending some time doing some fencing around a house in 80 Canterbury Street that backs onto the station at Cassino.  I also got out a few detail items from my collection to add to the backyard of this locations.  Well we needed a clothes line, an outdoor dunny and I had to find a garage to put beside the house.  A few trees were found and allowed to grow in the yard.  Of course the rubbish bins had to go out the front, the mower was left out the back and a outdoor setting was put in the back yard.  A water tank was also added behind one of the sheds.  I do have some mailboxes somewhere, I just need to find them to put them on the layout, out the front of the Canterbury Street house.

Now fencing had to go around the house on all 4 sides.  The fence besides the track was always there, but never installed, so that was glued down.  I needed to build some fences to add around the other three sides of the house.  So they are just sitting there at this stage, not permanently installed as yet.  I am undecided if concrete car tracks will be installed into the garage.

Also on Saturday afternoon, there was an NMRA Div 1 meeting online that features Luke Towan the fantastic diorama modeller from YouTube fame, then at night there was the NMRA-X presentation.  Adam Wuiske gave a great presentation.

Maybe I will get back on track next weekend and try and tidy up a couple of projects that I have on the go.

Sunday was my daughter's 18th birthday party so I was offline for most of the day, except for getting away to post this blog.


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.

Sunday, June 14, 2020

Someone Should Blow Electronics Up


Well I had great plan for this weekend.  I had been planning on getting my ‘Shelton the Photographer’ to take a few photos on my layout.  I had some great help from a couple of blokes down in NSW and I thought I followed the diagrams correctly.  But….

The saga started when I was told to wire my bridge rectifier differently to what I wrote about the other week.  So I did that.  But for me, I was thinking that I wanted to take the implementation of this new circuit slowly, I thought instead of wiring my 4N25 directly into the circuit with a parallel resistor, I’d firstly put a LED into the circuit in place of the 4N25.  Now we all know what a 4N25 is don’t we?  Of course not.  It is an optocoupler that will basically transfer an electrical signal between two circuits by using light - all inside the 4N25.  If current is flowing through pins 1 and 2 in the 4N25, that is where my LED is in my test circuit, then the output of the 4N25 on pins 4 and 5 will allow current to flow on the other circuit.

Well when I installed my LED in place of the 4N25 when I ran a loco over the trigger section of track, I got the smallest amount of flash from the LED.  So it seemed to be working.  I then replaced the LED with the 4N25 and connected up the other side of the circuit into my Arduino.  I was tracking what it was getting on the input pin into the Arduino on pin 5 of the 4N25 which was connected to pin 4 in my Arduino.  It was getting a HIGH input signal on the circuit with no train on the trigger track.  The circuit was set up to produce a LOW signal when a train was on the trigger section.  So I ran a train onto the trigger track and I still got a HIGH signal. I could not get it to work.

I scratched my head, I was starting to pull out what left over hair I had.  People were starting to call me 'Geoff'!

I had given up for the weekend.  I sat down to write this blog.  I then realized that I did not have the two input jumpers from the trigger track in pins 1 and 2.  I had them in pins 2 and 3.  Absolute Dork!  Now you could call me 'PK'!

So back down to the shed to test again.  Moved the pins from pins 2 and 3 to pins 1 and 2 and fired up the layout and a throttle.  Train ran onto the trigger and Yes - It works!  Well eventually.  Who would want to muck around with electronics for a living designing circuits?  Well not this little black duck, I can tell you.

To prove that it did work, and I can now deploy 'Shelton the Photographer' around the layout, please see the attached video.


I really must thank Marcus Ammann and Andrew King for their patience in helping a Luddite like me succeed with this first version of this little gadget.  I did have to make some changes to the Arduino side of the circuit as the Arduinos can be set to have a pull up resistor defined in the pin definition.  This meant that I did not have to put one into the circuit as per the original diagram proposed by the two gurus.  I went out on a limb here on my own by not installing it.  Now there will be version two of this circuit in the near future.  I just need a few components.  It does not require an Arduino.  Marcus has made one for his layout and hopefully his blog will show the results very soon.  Who knows, there might now be an influx of 'Shelton the Photographers' around lots of layouts very soon.  He will be up in lights - so to speak.  Not sure if Shelton needs to isolate for 14 days, given that he was on the Short North in NSW yesterday and he is now in Queensland.

I am happy to revert back to very basic layout wiring for a while now.  As my T-shirts say - 'Mainframes Rule' and 'Never trust a computer you can lift'.

Sunday, June 7, 2020

Moving into the 21st Century


So what happened this week?  Apart from spending quite a bit of time online, starting with our Tuesday Nighter get together with a few people, followed by a couple of hours on Saturday afternoon with the NMRA Div 1 on zoom, followed by a short online session with Darren and Brad..  This was followed up by a 90 minute Operations Session streamed live to Facebook from the Onondaga Cuttoff.  The Facebook streaming was viewed by over 200 people at its peak.

Now apart from that type of online work, I did some eBay buying.  Well I ordered an Arduino Uno online early in the week.  It turned up in the mail on Friday.  

While waiting for the Arduino to arrive, on other evenings during the week, I found some Arduino programming tutorials online.  They are very good.  So I followed along with some programming 101 sessions.  Well I do have a Bachelor Degree in Computing, so it was pretty easy.

After work on Friday I then went down to Jaycar in the afternoon and found a simple set of breadboard, jumper leads and a power supply, to help supplement my Arduino to help with my learning.  Unfortunately I had nothing to power the power supply with.  So that meant that I needed to head back to Jaycar on Saturday morning and pick up a USB A to USB A cable.  So that plugs straight in to the wall, or laptop and the other end into my power supply and voila 5V or 3.3V to my breadboard.  

So the first thing I did was wire in a LED with a 1K resistor.  Yes I got the LED to light using my power supply, so magic occurred.  I thought, I can do better than that.  I can power the LED from my Arduino.  I did that - more magic.  I then wrote some code on my Arduino, and actually had it loading into the Arduino and then I had the Arduino flashing the LED.  That worked as well.  More magic.  The next test was to simulate a detection and then flash the LED.  I even got that to work.  Extreme magic.

My next task is now to get a couple more things in my kitbag.  I need a switch for the breadboard, so I do not have to cross two jumper outputs to simulate a switch activating.  Next is to then work on some form of optocoupler.  I want this optocoupler to interface with my track detection circuit on my layout which I know works, and will then trigger my Arduino.  I just have to work out where to get one, and what model to use and then connect that up next weekend.

Once I get this all working, I will potentially deploy ‘Shelton the Photographer’ or heaven forbid, lots of them, to the layout.