This project control the points/turnouts of a model train layout. There are 6 control panels where the user can request one of the various track options. On each panel there will be 4 options for the possible routes. Note due to the physical payout of the track, specifically the "wye" connection the 4 options on each board will be different.
Also on the control panel are a set of 4 LEDs that indicate the active routes. For the 6 boards there will only be 2 LEDs active. One on panel A for example representing that route to B is active. Then panel B will have the LED representing that the route to A is active. On the remaining 4 panels there will be no active LEDs. This page develops a class/library Wye_Control_LEDs that takes an input byte and turn on the appropriate LEDs
The basic circuit of the controller and one control panel is shown. The 165 device is the point selection component of the control panel and is the subject of another page.
The 164 device drives the LEDs to indicate the chosen point selection. There are 4 LEDs. Only one is shown, the remainer are wired to 164 pins 4 5 and 6.
The 164 clock is wired to pin D2 of the micro controller while the serial data for the device shown comes from pin D3 of the microcontroller. There are 5 other control panels all being clocked via pin D2 with the data pins being D4, D5, D6, D9 and D10
The software structure is illustrated.
There are 6 memory locations known as Main_data through Pommy_data where the LED patterns will be stored. These labels correspond to locations on the original train layout.
The firmware:
Initialises the memory to the required LED patterns
Places bit 0 of all the memory on microcontroller output pins Main_pin .. Pommy_pin
Clocks all the shift registers to ripple the data on the output pins into the shift registers on the boards Main_board .. Pommy_Board.
Shift the memory data one bit right and repeat the above process.
The software consists of three files
The header file "Wye_LEDs.h" that creates the class and defines all definitions
The implementation file "Wye_LEDs.cpp" and
The test or client code "Wye_LEDs.ino" that will not be part of the final library but will be used for testing and illustrating how the library might be used.
The header file will need to be expanded as the project progresses.
Open collapsible box for more complete file to this point.
The lower trace captures the 4 clock pulses at the Microprocessor output pin D2.
The other wave forms are at pins 3 through 10. These waveforms indicate the pins 3 through 10 being set high in turn. Pins 4 and 7 are not part of the LED circuitry so they show no activity.
The trace has captured outputting 0xA to all the channels. With 0xA bit 0 is initially zero so the output pins are all low. The first clock pulse will transfer a zero to all channels.
For 0xA the firmware ripples the second bit (a high) to the output pins which the next clock pulse will load into the shift registers that drive the LEDS.
The sequences repeats for the 4 clock pulses.
With each clock the data is rippled across at an invisible rate . Ater 4 clock pulses the outputs will be stable and the LEDs steady.
The existing code for testing places a bit pattern into all memory locations. In the final product the memory is an image of the LED displays.
The header file is enhanced to include the different bit patterns. For example, sending the code 0x18 will indicate that there has been a request from the MAIN panel to set the points for the HARD station. The 0x10 portion is user defined while the 0x80 takes into account how the control panel is wired.
The header file will contain the following definitions:
At this point the operation has been verified by using different combinations in the client code. A complete testing will be performed when it is integrated with other modules.
Using a logic analyzer the time required for the dump_LED() routine was approximately 120uS.