Trains4Africa
Because all Boys (and some girls) love Trains

Function Decoder

Function  Decoder.

Project Credits:   Paul Harman and Jeff Hughes

This Project is essentially the same as the Accessory Decoder, same circuit, but with a different firmware.

Many people are already using DIY function decoders on spare loco addresses to operate accessories around the layout and in many situations this is the best way to do it.

Project Files:

 

Function Only Decoder.

Low Power.

Can drive up to 25mA per output at 5V (most LEDs only need 2mA to 5mA for normal brightness). Load can be connected between output and 0V or output and 5V or both (single output will drive both headlight and tail light for example). Bi-colour LEDs can be driven by connecting them between a pair of outputs (ideal for class 121 bubble cars etc. where head and tail light are in the same lens). Total decoder load should not exceed 90mA. Main advantages of this version are that it can be made smaller and there will be less heat dissipated, there is the potential of more efficient use of the outputs and more efficient use of the function buttons when driving complex lighting scenarios (such as the class 170 example with day and night lights as well as parking). This version will provide constant brightness of the LEDs regardless of track voltage (even when running on DC once the track voltage gets to 5.5V). The low power outputs are the same as the extra outputs C and D on the Zimo MX620 (or E and F on the MX63/64). Outputs are overload protected

High Power.

Can drive up to 200mA per output at full track voltage against the blue wire. Outputs can be on or off. Outputs are suitable for driving bulbs, smoke units, couplings, motors or anything else that you would normally connect to the function output of a decoder. Total decoder load should not exceed 2A. The main advantage of this version is that it can be used anywhere that is DCC ready and has a decoder socket. Outputs are not overload protected.

The choice of decoder should be made based on the following:-

Q. Will I be connecting the decoder to a NMRA/NEM decoder socket? If yes use a high power output decoder.

Q. Will I be driving 12V devices? If yes use a high output power decoder.

Q. Will I be driving LEDs? If yes use a low output power decoder as preference, but either will do.

Q. Do I want the lights to be constant brightness when running on DC? If yes use a low output power decoder and use LED lighting.

Q. Do I want to do complicated lighting with LEDs? If yes use a low output power decoder.

Q. Do I need to drive more than 25mA? If yes use a high output power decoder.

The differences between the versions is minimal and there is no reason why some of the outputs on a high output power decoder cannot be configured for low power by just leaving off the output transistor and replacing the current limiting resistor with a more suitable value.

Standard Firmware.

* Long and short addressing (CV1 and CV17/18).

* Supports all service mode programming modes including Direct, Paged, register and address only.

* Supports Operations mode programming (programming on the main) including 6-byte packets.

* Supports LokMaus2 programming mode to give access to all CVs for command stations only able to program CV0-99 with values 0-99

* Advanced consisting including consist address (CV19) and consist function mapping (CV21 and CV22).

* Analogue DC mode including analogue function mapping (CV13 and CV14).

* Supports brake on DC sections when analogue DC mode is disabled (CV29).

* Supports 14, 27, 28 and 126 speed step modes.

* Decoder lock (CV15 and CV16) allowing multiple decoders in one loco to be seperately addressed.

* Full function to output mapping allowing any function F0 to F28 to operate any output.

* Output inversion (CV99) which allows an output to be switched off when a function is active.

* Flicker (not on decoders using 12F629 or 12F675) available on outputs C, E, F, G and H using CV100.

* Personal user ID storage in CV105 and CV106.

* Sensitive input will decode packets even on very dirty track far beyond the NMRA spec.

* Three or eight independent outputs (depending on version).

* Up to 200mA current per output (high power versions only).

* Bipolar outputs (low power versions only) can be used against 0V supply or 5V supply

Standard Firmware Supported CVs.

CV Default value Range Description Notes
1 3 0-127 Short address 0=DC only (address zero is broadcast address)
7 (read) Software release number Set to 1 for this release
7 (write) 0 0,1,2,10,11,12 LokMaus2 Used for LokMaus2 programming mode
8 (read) Manufacturer ID Not yet set (still development)
8 (write) 8 Factory Reset 8= Reset to factory defaults
13 255 0-255 Functions supported in analogue DC mode F1 (bit 0) – F8 (bit 7)
14 63 0-63 Functions supported in analogue DC mode F0 forwards (bit 0), F0 reverse (bit 1) F9 (bit 2) – F12 (bit 5)
15 0 0-7,255 Decoder unlock key Unlocks decoder when 255 or same as CV16
16 0 0-7 Decoder lock ID Set lock address of decoder (other values will work)
17-18 0 Long address
19 0 0-255 Consist address
21 255 0-255 Consist function control F1 (bit 0) – F8 (bit 7)
22 63 0-63 Consist directional lighting control F0 forwards (bit 0), F0 reverse (bit 1) F9 (bit 2) – F12 (bit 5)
29 6 0-255 Configuration bits Default is analogue DC rather than Brake on DC and 28/126 step
33 128 0-255 Function 0 forward output mapping 128=A,64=B,32=C,16=D,8=E,4=F,2=G and 1=H
34 64 0-255 Function 0 reverse output mapping See above
35 32 0-255 Function 1 output mapping See above
36 16 0-255 Function 2 output mapping See above
37 8 0-255 Function 3 output mapping See above
38 4 0-255 Function 4 output mapping See above
39 2 0-255 Function 5 output mapping See above
40 1 0-255 Function 6 output mapping See above
41 0 0-255 Function 7 output mapping See above
42 0 0-255 Function 8 output mapping See above
43 0 0-255 Function 9 output mapping See above
44 0 0-255 Function 10 output mapping See above
45 0 0-255 Function 11 output mapping See above
46 0 0-255 Function 12 output mapping See above
83 0 0-255 Function 13 output mapping See above, CV number may change
84 0 0-255 Function 14 output mapping See above, CV number may change
85 0 0-255 Function 15 output mapping See above, CV number may change
86 0 0-255 Function 16 output mapping See above, CV number may change
87 0 0-255 Function 17 output mapping See above, CV number may change
88 0 0-255 Function 18 output mapping See above, CV number may change
89 0 0-255 Function 19 output mapping See above, CV number may change
90 0 0-255 Function 20 output mapping See above, CV number may change
91 0 0-255 Function 21 output mapping See above, CV number may change
92 0 0-255 Function 22 output mapping See above, CV number may change
93 0 0-255 Function 23 output mapping See above, CV number may change
94 0 0-255 Function 24 output mapping See above, CV number may change
95 0 0-255 Function 25 output mapping See above, CV number may change
96 0 0-255 Function 26 output mapping See above, CV number may change
97 0 0-255 Function 27 output mapping See above, CV number may change
98 0 0-255 Function 28 output mapping See above, CV number may change
99 0 0-255 Output inversion 128 inverts A, 64 inverts B etc.
100 255 0-255 Flicker (outputs C,E,F,G,H only) Gives flicker effect on outputs, H=1, G=2 ,F=4, E=8, C=32
105 0 0-255 User ID location 1 For storing user I.D. information (E.G club membership No)
106 0 0-255 User ID location 2 See above
Colour key
Supported CV Table for V2.18 firmware Not as per NMRA recommendation
Not NMRA recommended default

Enhanced Firmware.

You have tried the standard DIY decoder firmware, now try the all singing all dancing premium function decoder firmware.Everything you have now, but with:-

* Optional NMRA compatible function to output mapping (8-output decoders only)

* Output dimming

* Better, more subtle flicker mode for more realistic oil/gas lamp

* Separate random flicker on each output (e.g. headcode oil lamps will flicker independently)

* Mars ligh

* Gyralight

* Fuzzlight (rotating beacon).

* Xenon flash light (one flash or two flash).

* Flashing LED tail light.

* Ditch lights.

Enhanced Firmware Supported CVs.

CV Default value Range Description Notes
1 3 0-127 Short address 0=DC only (address zero is broadcast address)
7 (read) Software release number Also used for LokMaus2 programming mode
7 (write) 0 0,1,2,10,11,12 LokMaus2 Used for LokMaus2 programming mode
8 (read) Manufacturer ID Not yet set (still development)
8 (write) 8 Factory Reset 8= Reset to defaults
13 255 0-255 Functions supported in analogue DC mode F1 (bit 0) – F8 (bit 7)
14 63 0-63 Functions supported in analogue DC mode F0 forwards (bit 0), F0 reverse (bit 1) F9 (bit 2) – F12 (bit 5)
15 0 0-7,255 Decoder unlock key Unlocks decoder when 255 or same as CV16
16 0 0-7 Decoder lock ID Set lock address of decoder
17-18 0 Long address
19 0 0-255 Consist address
21 255 0-255 Consist function control F1 (bit 0) – F8 (bit 7)
22 63 0-63 Consist directional lighting control F0 forwards (bit 0), F0 reverse (bit 1) F9 (bit 2) – F12 (bit 5)
29 6 0-255 Configuration bits Default is analogue DC rather than Brake on DC and 28/126 step
33 128 0-255 Function 0 forward output mapping CV33 – CV37:- 128=Output A (NMRA output 8), 64=output B (NMRA output 7), 32=output C (NMRA output 6), 16=output D (NMRA output 5), 8=Output E (NMRA output 4), 4=Output F (NMRA output3), 2=Output G (NMRA output 2) and 1= Output H (NMRA output 1)
34 64 0-255 Function 0 reverse output mapping
35 32 0-255 Function 1 output mapping
36 16 0-255 Function 2 output mapping
37 8 0-255 Function 3 output mapping
38 4 0-255 Function 4 output mapping See above or as per NMRA if CV61=0
39 2 0-255 Function 5 output mapping See above or as per NMRA if CV61=0
40 1 0-255 Function 6 output mapping See above or as per NMRA if CV61=0
41 0 0-255 Function 7 output mapping See above or as per NMRA if CV61=0
42 0 0-255 Function 8 output mapping See above or as per NMRA if CV61=0
43 0 0-255 Function 9 output mapping See above or as per NMRA if CV61=0
44 0 0-255 Function 10 output mapping See above or as per NMRA if CV61=0
45 0 0-255 Function 11 output mapping See above or as per NMRA if CV61=0
46 0 0-255 Function 12 output mapping See above or as per NMRA if CV61=0
60 0 0-255 Dimming level 0= minimum brightness, 255=maximum brightness
61 8 0,8 NMRA output mapping compatibility 0=NMRA, 8=useful! Affects CV38-CV46 only
83 0 0-255 Function 13 output mapping As CV33, CV number may change
84 0 0-255 Function 14 output mapping See above, CV number may change
85 0 0-255 Function 15 output mapping See above, CV number may change
86 0 0-255 Function 16 output mapping See above, CV number may change
87 0 0-255 Function 17 output mapping See above, CV number may change
88 0 0-255 Function 18 output mapping See above, CV number may change
89 0 0-255 Function 19 output mapping See above, CV number may change
90 0 0-255 Function 20 output mapping See above, CV number may change
91 0 0-255 Function 21 output mapping See above, CV number may change
92 0 0-255 Function 22 output mapping See above, CV number may change
93 0 0-255 Function 23 output mapping See above, CV number may change
94 0 0-255 Function 24 output mapping See above, CV number may change
95 0 0-255 Function 25 output mapping See above, CV number may change
96 0 0-255 Function 26 output mapping See above, CV number may change
97 0 0-255 Function 27 output mapping See above, CV number may change
98 0 0-255 Function 28 output mapping See above, CV number may change
99 0 0-255 Output inversion 128 inverts A, 64 inverts B etc.
105 0 0-255 User ID location 1 For storing user I.D. information (E.G club membership No)
106 0 0-255 User ID location 2 See above
114 255 0-255 Output dimming Active low, -128 dims A, -64 dims B etc.
125 0 0-60 Output A special effects 8=flicker etc as MX64. See table below
126 0 0-60 Output B special effects See above
127 0 0-60 Output C special effects See above
128 0 0-60 Output D special effects See above
129 0 0-60 Output E special effects See above
130 0 0-60 Output F special effects See above
131 0 0-60 Output G special effects See above
132 0 0-60 Output H special effects See above
Colour key
Supported CV Table for V3.10 firmware Not as per NMRA recommendation
Not NMRA recommended default
Table of effects supported by CV125-CV132
Value Effect
0 Just turn the output on steady (default)
4 MARS light
8 Oil lamp flicker
12 Regular flash on/off 50% mark/space ~0.5Hz
16 Single flash Xenon strobe
20 Double flash Xenon strobe
24 Rotating beacon ‘Fuzz light’
28 Gyralight
32 Ditchlight right
36 Ditchlight left
40 No effect (reserved for Ditchlight type 2 right)
44 No effect (reserved for Ditchlight type 2 left)
48 No effect (reserved for uncoupling)
52 No effect (reserved for soft start)
56 Modern battery portable flashing tail lamp

SAMSUNG DIGITAL CAMERA

SAMSUNG DIGITAL CAMERA

SAMSUNG DIGITAL CAMERA

Accessory Firmware Supported CVs.

CV Alt. CV Default value Range Description Notes
1 513 1 0-255 Lower address bits 0-63 only for decoder address mode
3 515 0 0-144 Output on time in 10mS increments 0=constant, 1=10mS, 100=1S, 144=1.44S
4 516 0 0-144 Output on time in 10mS increments 0=constant, 1=10mS, 100=1S, 144=1.44S
5 517 0 0-144 Output on time in 10mS increments 0=constant, 1=10mS, 100=1S, 144=1.44S
6 518 0 0-144 Output on time in 10mS increments 0=constant, 1=10mS, 100=1S, 144=1.44S
7 (read) 519 Software release number
7 (write) 519 0 0,1,2,10,11,12 LokMaus2 Used for LokMaus2 programming mode
8 (read) 520 Manufacturer ID Not yet set (still development)
8 (write) 520 8 Factory Reset 8= Reset to defaults
9 521 0 0-7 Upper address bits
29 541 128 128,192 Configuration bits 192=output address mode, 128=decoder address mode
33 545 0 0-127 Mode Bits 0-3 as MERG toggle mode, bit 6 Roco momentary mode
34 546 0 0,8 ACK pin 0=pin 6, 8=pin 5 (8-pin) or 11 (14-pin)
35 547 0 0-255 invert Each bit inverts an output pin when set to 1
36 548 255 0-255 Flicker on 14-pin chips Each bit sets an output pin to flicker when set to 0 (only pins 5-10)
37 549 0 0-255 Default output state Each bit will set an output to be active at reset
Colour key
Supported CV Table for V0.05 DIY Acc firmware Not yet implemented
Not as per NMRA recommendation
Not NMRA recommended default

Pulse Accessory Circuit Diagram v1.00

Accessory (2) stripboard layout v1.00 annotated (480x141)

Accessory (2)Stripoard cutting guide v1.01 (480x101)

Accessory (8) stripboard layout v1.00 (480x255)Accessory (8)Stripoard cutting guide v1.01 (480x314)

 

 

Application Examples

Interesting output configurationsInteresting output configurationsThe diagram shows how to wire day, night and tail lights to a 3-output decoder to give automatic directional lighting as well as parking lights (red both ends) using only F0 and F1 functions. Additionally adding an extra output and F2 will allow the lights to be switched off completely (or just the tail lights when hauling a train or running in multiple).Interesting output configurations 2

Diagram 2 shows how to connect both head and tail lights to a single output of a low output power decoder to give automatic directional lighting with F0 active, and parking lights when F0 is inactive.

Interesting output configurations 3Diagram 3 shows how to connect head and tail LEDs in inverse parallel between two outputs allowing the connection of all the directional lighting through the train with a two pole conductive coupling and allows the use of red/white or red/yellow bicolour LEDs.Class 156 exampleThis example is similar in function to the 170 example (without day/night headlight switching) using the same function allocations, but only uses one function decoder for the whole train. Since the 156 does not have lighting fitted as standard there are no pickups on the trailer car, so in this example a 2-pole conductive coupling is used to connect the trailer lighting to the power car. F0 switches between directional lighting (white at front and red at rear) and parking lighting (red both ends) F2 switches off the tail lights (8-output decoder and on the power car only).

You can download an Excel file of the cv table here.