Sunday, July 19, 2020

Some Success


Well I did get to the shed on Friday afternoon and today.  Saturday was filled up with a hobby shop visit in the morning, Barnacle Bob's after that, followed by Soccer and a surprise birthday party for my sister.  

On Friday afternoon I completed the level crossing detectors for Hotham Street on the northern side of Cassino.  I do have one LED not flashing, so that will be a dry solder joint.  I will eventually get around to fix that.  I am having some trouble with the bypass switch to be used at the Cassino Meatworks Siding.  I have configured it to cut out the track detection when someone is shunting in the siding – usually doing a run around maneuver.  However, when the detector is switched back in, sometimes it triggers the level crossing sequence.  So I will actually do the sending of the signal from the bypass switch to the Arduino, via an AND gate.  I will AND the detector output and the output of the bypass switch together, and send that output to the Arduino.  So I will play with that one afternoon this week.  I will make a trip to Jaycar to pick up an AND gate Chip for $1.25 and $0.40 for a 14 pin socket.  We will see if I can avoid having to change the level crossing detector code in the Arduino, which I can easily do, but I just want to make the Arduino code generic.

Given that I had everything sorted with that level crossing, it meant that today I pushed ahead with the installation of the traffic lights on the southern side of Lismore Station.  On Thursday at work, PK dropped by and handed over three sets of traffic lights that I got him to add to an order he was making from the US.  It almost arrived in record time.  So I tested them on Friday evening and drilled out some 3mm styrene tube with a drill bit so the four wires (red, yellow, green and common) could fit through from the light heads.  The drilling made a larger whole through the center of the styrene tube.  I did not have any brass wire, so I thought this was the easiest method to create some light posts.  The styrene tube was painted silver for my traffic lights poles.  I attached a 1000 Ohm resistor to the common wire, as there was always going to be only one LED lit at any point in time.

So today I built a shelf under the layout for the Arduino to sit on.  This was right under the traffic lights.  Just 30cm from the Arduino was a 4 output power board with two free sockets, so the Arduino had power.  I drilled four holes through the baseboard and fed my light poles with their wires through.  I added a pin connection to every wire from the light poles to plug into the Arduino and held my breath as I powered it on.  It was lighting up multiple lights, but the sequence seemed to be sort of working.  I attached my PC to the Arduino and went through the code again.  I had attached the Common leads to the 5V pin in the Arduino.  I was thinking that a HIGH output was to light one of the outputs.  But a LOW setting of the pin, was lighting them.  Thus one was off and two were on.  What a Dork!  I have many of these occurrences.  I could have just pulled my 5V common pin out of the Arduino and plugged that pin into the Ground pin of the Arduino.  But I thought I would change the code to swap the outputs, so LOW was a lit LED and HIGH was a turned off LED.  I also had to add code to endure that on power up, all the red lights were on and everything else was turned off.

So after compiling that changed Arduino code again, and sending it to the Arduino, the traffic light controller works like a bought one.  It just sits there churning through light sequences, and even throws in a random all yellow flash sequence, because I can.  Videoing this would create a very large video file, that would take quite some time to upload.  So I haven’t done a video yet.  Maybe next week.

No comments:

Post a Comment