Willkommen 

Digital

RE: DCC Function Decoder for Arduino and ATtiny

 von RudyB , 26.10.2015 11:51

DCC Function Decoder for Arduino and ATtiny

In previous posts on Arduino DCC Decoders I have been using the word 'function decoder', which has led to some confusion. The decoders posted so far are what I should have called accessory decoders.

An accessory decoder listens to a DCC accessory address and switches an output or drives a servo. One Arduino DCC decoder can be configured to listen to max 16 DCC addresses.

A function decoder listens to one address (a locomotive address, or as the NMRA calls it, a multi-function decoder) and it switches locomotive functions, which are called F1, F2, etc. on command stations or handheld controllers.

Now that this is cleared up ... here it is ... an Arduino and ATtiny DCC Function Decoder.

And, if you like it small enough to fit in an HO wagon (with a diode bridge and a capacitor as a power supply), this code also works with the 22x18 mm ATtiny boards that can be had for under $1,50 here.

Of course DCC needs to be fed to the Arduino / ATtiny. For that I use this opto coupler circuit. If it needs to be smaller to fit inside a wagon, it is also possible to use a Zener diode and a resistor.

Configuration is easy. In line 1 of the code state the loc address you want it to listen to. In the lines that follow, define the output pins for F0, F1, F2 ... up to F12. Not all need to be defined, just the ones that you want to use. On the Arduino outputs 3-19 (14-19 are A0-A5) are available. On the Attiny P0, P1, P3, P4, P5.

int decoderAddress = 1830; // This is the decoder address, change into the number you want.
#define F0_pin 13 // Define the output pin for every Function number in use. 13 has on board LED.
#define F1_pin 0 // Available pin numbers: 3-19
#define F2_pin 0
...
#define F12_pin 0



Click here to go the blog post on the Arduino and ATtiny DCC Function Decoder that has the download link.




..


Youtube channel on Model Railway, Traincontroller, Arduino and more

RudyB
Beiträge: 203
Registriert am: 20.09.2014

Themen Überblick

Betreff Absender Datum
RE: DCC Function Decoder for Arduino and ATtiny RudyB 26.10.2015
RE: DCC Function Decoder for Arduino and ATtiny tom75 28.10.2015
RE: DCC Function Decoder for Arduino and ATtiny RudyB 30.10.2015
RE: DCC Function Decoder for Arduino and ATtiny KTH 31.10.2015
 

disconnected Foren-Chat Mitglieder Online 43
Xobor Einfach ein eigenes Forum erstellen
Datenschutz