You're reading ...
Software

New versions of Arduino & ATtiny DCC Accessory- and Function Decoders

New versions of Arduino DCC Decoders are available.

ATtinyDCC Function Decoder
The possibility to use the direction of travel of the loc (forward or reverse) to switch outputs has been added. This makes it possible to switch head and tail lights depending on the loc direction. It is built in both the Arduino and the ATtiny version. How to configure this, is shown inside the code.

ArduinoUnoSmdDCC Accessory Decoder
A mode has been added to switch signals using two pins. The outputs are inverse, if pin1 is HIGH, then pin 2 is LOW. How to configure this, is shown inside the code. Four modes are available now:
mode 1 – Continuous output. OFF at startup.
mode 2 – One shot, with a timer. OFF at startup.
mode 3 – Flasher with 2 outputs that alternate, with 2 timers. OFF at startup.
mode 4 – Signal with 2 outputs that always are inverse. At startup one of them is ON.

IMPORTANT:
The output logic has been changed with respect to the previous versions. In the new versions, the Arduino output pin is LOW when accessory or function is switched ON, and vice versa. If you need it the other way around … it is not difficult to edit this in the code, just do a ‘find’ for all digitalWrite instructions and modify them.

The download link is available on the software page.

The download contains all Aduino decoder versions, S88-, sniffer- and sound software.

About RudyB

Hobbyist

Discussion

18 thoughts on “New versions of Arduino & ATtiny DCC Accessory- and Function Decoders

  1. Rudy,

    Great project, I’m using an ATTiny85 as an accessory decoder. I know it’s been a while and my problem may be very simple to fix. I load your latest software with one output pin configured in mode 1 (or 2) and it works fine. However, if I change the maxaccessories constant to a number other than 1, the decoder stops functioning. In short, I can only get it working for one accessory address. Thanks for any suggestions you might have and thanks for sharing your work.

    Like

    Posted by Alex Young | June 19, 2021, 18:34
    • I have no idea why that happens. Or were you using the ATttiny function decoder code, that will react to just one address. I’ll send you an email then you can send me your code and we can have a look together.

      Like

      Posted by RudyB | June 20, 2021, 20:50
  2. Hi Rudy

    I have recently acquired a couple of Digispark Attiny85 boards that I would like use with my train layout using your designs. I have successfully loaded the Accessory Decoder software on to a board and it works 100% but I cannot load the Function Decoder Software at all.
    Using the Arduino IDE software I cannot even Verify the sketch. When I try to verify the following fault/s is displayed:- C:\Users\Main\Documents\Arduino\RB_DCC_Decoder_Function_ATtiny/RB_DCC_Decoder_Function_ATtiny.ino:91: undefined reference to `DCC’

    Apart from the DCC address (50) I have not changed any code.

    What am I doing wrong?

    Like

    Posted by Gareth McNaugton | September 18, 2020, 16:45
    • It’s long ago, I don’t remember precisely, but it could be that the function decoder uses another DCC library. If you’d Google for NMRA DCC library I bet you’ll find it.

      Like

      Posted by RudyB | September 18, 2020, 22:10
      • Hi Rudy
        I think that it was finger trouble on my part in that I had the DCC_Decoder in the wrong directory as I tried it on what I call my Railway PC and it worked 100% using the original DCC Decoder library.
        Many thanks for the reply.
        Regards
        Gareth

        Like

        Posted by Gareth McNaugton | September 19, 2020, 14:50
  3. Hi Rudy,

    I have just found your site and have to thank you for your great work. I am interested in the ATtiny function decoder with the ability to use the direction of travel to switch outputs. I downloaded the code from your software page (https://www.dropbox.com/s/qkhrc147m38llb9/Arduino_DCC_S88.zip?dl=0), however I cannot see any references within the code to use the directional feature. Any help is appreciated.

    Like

    Posted by Martin | August 26, 2019, 05:58
    • Hi Martin. The DCC function decoder switches functions no matter what the direction of travel is. It can be made direction aware, but that would require extra coding for which I currently do not have enough time.

      Like

      Posted by RudyB | August 26, 2019, 09:53
      • Hi Rudy,

        Thanks for your response. I was under the impression the capabiliuty was already in the code from your post: “The possibility to use the direction of travel of the loc (forward or reverse) to switch outputs has been added.”

        Cheers.

        Like

        Posted by Martin | August 27, 2019, 03:02
      • LOL, looks like Altzheimer really is becoming a thing … I forgot I ever wrote this code … every Function can be made to switch based on the direction of travel … you just need to code this yourself but it is not difficult to do. There is an example in the code already. I sent you a newer version by mail.

        Like

        Posted by RudyB | August 27, 2019, 08:30
  4. Hi Ruud, i recently came across your videos and I must say excellent work. Since I was looking for a device to control servos and signals, I bought a couple of Arduinos to use your example of the DCC Accessory and function decoder sketch. I tested with 2 signals using address 1 & 2 with the coreesponding pin 13,12, respectively 6, 7. The first signal works fine, but the second doesn’t do anything. Do you have any idea what the reason could be for that problem? I would be greatful for an advice.
    Thanks in advance for your help.
    with regards, Herb

    Like

    Posted by Herb Janssen | December 21, 2016, 17:23
    • Herb, if one signal is working there is hope … it means that the biggest hurdle, feeding DCC to the Arduino via the opto coupler, is successfully taken! Can you do a little test? What happens if you config the signals such that their outputs are exchanged … does ‘1‘ still work, mow on the other outputs? If not there probably is a hardware issue with the output connections. Else it may be something in the software config and I’ll have a look. I’ll send you an email so you can send me your code.

      Like

      Posted by RudyB | December 21, 2016, 18:54
  5. Hi Rudy,

    Timetable in TC would be a great idea, but another thing I think, could be interesting in a video, could be the use of Virtual contacts and or Virtual Occupancy detection, perhaps one could save some money on detector modules.

    Best regards Niels

    Like

    Posted by Niels Ove Hauge | November 23, 2015, 10:49
  6. Hello Rudy.
    Hope You are allright, I really miss Your Traincontroller videos, which has given me so much help. I do hope, You could give Us some more, it would be nice?
    Best regards from Niels.

    Like

    Posted by Niels Ove Nielsen | November 9, 2015, 12:55
    • Niels, thx for your feedback. I have been busy with my railway hardware the past weeks. 🙂 Also … I have run out of subjects to cover with the video’s. Any ideas?

      Like

      Posted by RudyB | November 9, 2015, 13:27
      • Rudy, glad to hear. Suggestions to videos could be one about timetables. And perhaps one about using sensors on a track where I don’t want to have a block, only the contact sensor. I don’t know how to visualize that track with a certain colour, when the track is occupied, perhaps it is something with a flagman?

        Like

        Posted by Niels Ove Nielsen | November 9, 2015, 15:34
      • Hi Rudy,

        I also miss your great videos a lot. How about a video on timetables?

        Best regards, Michael

        Like

        Posted by Michael Schonwandt | November 22, 2015, 21:31
      • It has been a busy period. As sson as I find the time I’ll start work on a time tables video.

        Like

        Posted by RudyB | November 23, 2015, 08:51
  7. Post arrived today with a new ATiny, looking forward to the days work.

    Like

    Posted by Jim | October 31, 2015, 09:16

Leave a comment

Archive of all posts