New Decoder Variants
Hi all,
Even though I originally never had any consideration for putting these decoders into rail cars, I had a recent request to implement the 17 LED decoder with directional sensitivity for LED control. The folder and Arduino sketch can be downloaded here:
http://model-railroad-hobbyist.com/sites/model-railroad-hobbyist.com/files/users/geoffb/decoder_dirfade.zip
This sketch provides a DCC LED light decoder with fade and directional capability.
It is configured by editing the following list in the sketch:
/ The following list defines how each of the 17 function pins operate:
// a 0 allows for normal On/Off control with fade on and fade off
// a 1 allows for normal control when the decoder sees a forward speed setting, reverse turns the LED off, with fade on and fade off
// a 2 allows for normal control when the decoder sees a reverse speed setting, forward turns the LED off, with fade on and fade off
byte led_direction [ ] = {0,1,2,0,1,1,1,1,2,2,2,2,0,0,0,0,0}; //0=On/Off, 1=On Forward, 2=On Reverse
If you missed the post in SMA12, there is another new decoder version which will control 3 Groups of 5 I/O pins (as in for LEDs), with each lighting group having a configurable pin pattern, and each function having a configurable set of lights to turn on and off. When any of the lights/LEDs turn on or off they will do so with a gradual fade, rather than instantaneously.
The folder and Arduino sketch can be downloaded here:
http://model-railroad-hobbyist.com/sites/model-railroad-hobbyist.com/files/users/geoffb/decoder_sma12_led_groups.zip
After unzipping, place the folder into your Arduino folder on your computer, start the Arduino IDE/Editor and load it into your decoder.
In the sketch/program you will find:
byte FPins_Assigned [12][5] = { // This array defines the pins controlled by each function
{3,4,5,6,7}, // F0
{3,4,5,6,7}, // F1
{3,4,5,6,7}, // F2
{3,4,5,6,7}, // F3
{8,9,10,11,12}, // F4
{8,9,10,11,12}, // F5
{8,9,10,11,12}, // F6
{8,9,10,11,12}, // F7
{13,14,15,16,17}, // F8
{13,14,15,16,17}, // F9
{13,14,15,16,17}, // F10
{13,14,15,16,17} // F11
Each group specifies the actual IO pins that the respective function will control.
And this:
byte Function_Lites [12][5] = { // This array defines the Lights/LEDs controlled in each light group per function
{1,1,0,0,0}, // F0 Hp0
{0,0,1,0,0}, // F1 Hp1
{0,0,1,0,1}, // F2 Hp2
{0,0,1,1,0}, // F3 Sh1
{1,1,0,0,0}, // F4 Hp0
{0,0,1,0,0}, // F5 Hp1
{0,0,1,0,1}, // F6 Hp2
{0,0,1,1,0}, // F7 Sh1
{1,1,0,0,0}, // F8 Hp0
{0,0,1,0,0}, // F9 Hp1
{0,0,1,0,1}, // F10 Hp2
{0,0,1,1,0} // F11 Sh1
Each group here defines which Pins/LEDs will be turned ON/OFF by the respective Function.
When each LED comes ON or turns OFF it will fade On or Fade Off respectively.
Note Bene: Turn Off all functions in a group before turning the next Function in the same group ON.
Change one function at a time. I did not bother with any special overlapping timing here.
The preset configuration should match the German Signaling configuration Loeter had asked for, but
this Decoder can be used and configured to control any groupings you want (within the limits of the definition).
So, in summary... there are 3 groups of 5 pins controlled by 4 functions each. (Loeter requested a function (mobile decoder) configuration too). The fading is (by my eye) a bit better than my last attempt, too.
Both of these were suggestions for use by fellow Modelers Loeter and Yuri.
I list them here because other modelers may benefit from them too.
Have fun!
Best regards,
Geoff Bunza