You're reading ...
Hardware, Software

Use an ATTiny with USB as a DCC Accessory Decoder

If we like to have a really small DCC accessory decoder that sets us back just some $2,50, the ATTiny might just be it.

ATtiny85Of course we could use a plain ATTiny chip and solder it onto a small piece of experiment baord together with the optocoupler circuit needed to transfer the track DCC voltage to 5V TTL. But then we’d have to figure out how to program the thing. Not really difficult, but still more work than when we’d use the new ATTiny USB boards that are available nowadays.

ATTiny_USBThis is an example of such a board. The dimensions are just 22×18 mm and it contains the ATtiny, a few LED’s, a power converter that allows up to 16V input and a mini USB port. The boot software to make this USB work and allow connection to the Ardiuiono IDE is already baked into the chip. The hardware can be found here.

There is no USB-serial chip on the board, it relies on the software inside the ATTiny. While it worked with both my PC’s, there is no guarantee it works with every PC. The process of installing the software and drivers and get it to work with your Arduino software development IDE is described here.

The ATTiny DCC accessory decoder software can be downloaded here. The schematics for the optocoupler circuit needed to transfer DCC track voltage to TTL can be found on the Software page.

The USB driver is inclued in the zip file, in case the process described at the digistump site did not work (which happened with me with one of the PC’s).

The video shows the ESU ECoS sends out a DCC accessory address, that controls pin 1 of the ATtiny, which has the on board LED attached.

 

About RudyB

Hobbyist

Discussion

53 thoughts on “Use an ATTiny with USB as a DCC Accessory Decoder

  1. I’m using the Attiny85 no DigiSpark. After flashing the chip nothin happened. No response to any command no LEDs. After some trials i changed two things. First i wrote a new bootloader with 16 MHz internal clock speed. And second now i’m using for the 5V power supply an anti-interference capacitor mit 0,1 µF between GND and VCC and now it works 😉

    With 8 MHz as internal clock speed and capacitor it never works. For the DCC Signal on P2 i tried a direkt connection with a 22k resistor and an opto coupler 6N137. Both works fine.

    Greetings
    Martin

    Like

    Posted by Martin | January 30, 2022, 08:00
  2. Hello Rudy, I have a little problem, I do not get the software for the attiny85 running (function and accessory), I use the Arduino 1.8.5, current lib, compiling and downloading is not a problem (without errors), but me do not get a reaction. If I use a pro mini 328p (function and accessory correct INO) everything works, the optocopler is connected correctly. 5V is also ok, I have taken a Digispark and a normal attiny85, no success.
    const byte maxaccessories = 2;

    accessory[0].address = 55; // DCC address
    accessory[0].mode = 0; // Continuous: HIGH until DCC switches the address off again
    accessory[0].outputPin = 1; // Arduino pin to which this accessory is connected

    accessory[1].address = 56;
    accessory[1].mode = 2; // Oneshot: HIGH for ontime ms, then LOW and stays LOW.
    accessory[1].outputPin = 1;
    accessory[1].ontime = 100;

    int decoderAddress = 55;

    define F0_pin 1 // Define the output pin for every Function number in use
    #define F0_pin2 1 // 2nd pin for same function is possible. Can use forward / reverse direction … see line 97.
    #define F1_pin 0 // Available pin numbers: 0,1,3,4,5
    #define F2_pin 3
    #define F3_pin 0

    What am I doing wrong ?
    Thank you for a little info
    Olaf

    Like

    Posted by Olaf Reis | November 26, 2017, 19:19
    • Olaf, I sent you an email with a .ino file to try.

      Like

      Posted by RudyB | November 27, 2017, 11:04
      • I have the same problem. With a Nano it works with a Attiny85 (no Digispark) nothing happens.

        This entry should initialize with the red LED on:

        accessory[3].address = 4; // DCC address
        accessory[3].mode = 4; // Continuous: HIGH until DCC switches the address off again
        accessory[3].outputPin = 3; // Green signal
        accessory[3].outputPin2 = 4; // Red Signal
        accessory[3].onoff2 = 1; // Initially set Red signal to ON

        Can you please send the .in file to me?

        Best Regards
        Martin

        Like

        Posted by Martin | January 27, 2022, 20:41
      • I’ve sent you an email with the file.

        Like

        Posted by RudyB | January 29, 2022, 10:10
  3. Hi Rudy – Thanks for all your videos, and blogs, sharing what you are doing with the rest of the planet!!!

    In earlier Blog Questions, people have said they have problems using more than 1 Address with the software you have made available.

    Perhaps people don’t understand what DCC Decoders Can and Can’t do. There are 2 types of DCC Decoders, with 2 Sub-Types:
    – Multi-Function (Mobile) Decoders – 7-Bit (Short) Addresses
    – Multi Function (Mobile) Decoders – 14-Bit (Long) Addresses
    – Accessory Decoders – Basic
    – Accessory Decoders – Extended
    (Refer: NMRA Standard 9.2.1, page 1 of 12)

    A Mobile Function Decoder can ONLY have 1 Address. Different Functions are then controlled with Function Keys on the Throttle. Anyone trying to use DCC Decoder Software for a Mobile Decoder with multiple addresses is – therefore – going to be quite disappointed.

    On the other hand, an Accessory Decoder has a DIFFERENT Address for EVERY Function.

    Some DCC Manufacturers have 1 Physical device, than can control Multiple Functions. Initially, these came out as 1 Physical device, able to control 4 Point Motors. These were sometimes restricted to the First of 4 Addresses being Forced into a Starting Address that was every 4 Addresses (i.e. 1-4, 5-8, 9-12, 13-16 etc).

    I’m not aware of any NMRA Standard that requires such ‘Group of 4 Addressing. So, 1-4 and 3-5 should be legal. You might do this because you use the same address to control different physical devices quite far apart from each other on your layout.

    These TYPES OF dcc devices were ‘Basic” Accessory Decoders, because each ‘Function’ could only have a State of On or Off (Red or Green). So, 3-Aspect Signals, or the ‘Many-Aspect’ Signals in use throughout the E.U. (Before Brexit), could NOT be handled by a ‘Basic’ Accessory Decoder.

    Accordingly, the Extended Accessory Decoder exists, which can have 32 States (5 Bits – So Zero to 31). I’m not aware of a 32-Aspect Signal, so it would appear that any Prototypical Signal can be controlled by an Extended Accessory Decoder.

    But, each Signal, or Point, or Function controlled by an “Accessory Decoder” WILL have a Unique Address!!!

    ===
    So, what determines whether a DCC Decoder is a Mobile/Multi-Function Decoder, or an Accessory Decoder?
    – It is the Software inside!

    If the Software responds to Messages (Packets) intended for Mobile Decoder Addresses, then it is a Mobile/Multi-Function Decoder.
    If the Software responds to Messages (Packets) intended for Accessory Decoder Addresses, then it is an Accessory Decoder.

    Each Decoder Type has different Messages (Packets) that it can understand. So, an Accessory Decoder needs to respond to an Accessory Address, then correctly process the Message (Packet) that follows the address the Decoder has been told to respond to.

    To confuse things for us Huimans, the SAME Address number can be used for BOTH a Mobile Decoder and an Accessory Decoder!?!?! As the Packets have different Headers, the DCC Decoders have no such confusion that we Humans have!
    🙂

    ===
    In summary:

    – if the software for an Arduino/ATtiny DCC Decoder is for a Function Decoder, you can ONLY have 1 Address. Different Functions are controlled by the Throttle’s Function Keys

    – if the software for an Arduino/ATtiny DCC Decoder is for an Accessory Decoder, you MUST have 1 Address for EACH Function. Each Decoder can have 1 or More Addresses (A 16-Function Arduino DCC Decoder could therefore respond to 16 different addresses).

    I trust this has been helpful.

    Liked by 1 person

    Posted by Warren | April 6, 2017, 13:27
    • Thanks for that Warren. A very useful sum-up of DCC decoders. Has anything much changed since you posted this?

      Like

      Posted by overviewman | January 28, 2021, 06:12
    • Rudy this is excellent stuff! Very useful for non-mobile decoder implementations.

      I was musing on using this as a mobile decoder. The immediate issue would be use of USB supply. That would make it a problem for a mobile decoder – for example a coach lights controller. However, since all the pins have been brought out to the board edge, I would imagine that these little boards can be programmed via JTAG if an appropriate programmer is connected to them correctly? The P0,P2,P3 etc pins are used for other things when the chip is put into programming mode.

      Programming in that way would obviate the need for a USB connection and the VIN could be derived from track DCC current via a bridge? I would have thought that a single TINY85 could power enough LEDs from 4 outputs to light up a coach interior? You would need a reservoir capacitor too I think.

      Of course, in such a scheme the decoder would need to be detachable from the coach for re-programming should the need ever arise – but I think it could work. I have ordered some boards and will give it a shot and let you know.

      Unless anyone has already trodden this path…….. 🙂

      Best regards
      Alan T.

      Like

      Posted by overviewman | January 28, 2021, 06:41
      • Yes, it can be used as a mobile DCC decoder, you can even use F0 – Fn as DCC commands. You’ll need the little option coupler circuit inside too, but that can be built small. For power you could even consider a 3.7V lipo battery if you have room inside. Don’t know a about alternative ways of programming, I always programmed it via USB first and then use it, I’ve had little need for reprogramming.

        Liked by 1 person

        Posted by RudyB | January 28, 2021, 07:39
      • Hi Alan, All,

        Have you noticed the ATTiny boards also have a Vin pin and a 5V regulator onboard?
        This allows you to put in a voltage of 7 to 16 volts DC on the Vin pin. The 5v pin you use to power other stuff.
        When you use the DCC signal and rectify it with two diodes and a capcitor (make sure the DC voltage is less then 16v),

        Best regards,
        Ron

        Like

        Posted by Ron Kraaijkamp | June 24, 2021, 19:55
  4. Hi Rudy – Thanks for all your videos, and blogs, sharing what you are doing with the rest of the planet!!!

    However, I have a question for you…
    In the Video, between 1:12 and 1:16, you say that your ATtiny85 can control 4 Function Outputs.

    I’m not sure how you can control any more than 3, unless you don’t use the USB connection after you have uploaded the software (But I would expect that you would also have to remove/disable the USB Software, or it might get confused).

    This is how I see the 6 Pins on the ATtiny85:
    PB0 – Available for an Output
    PB1 – Available for an Output (But has a LED Attached, which might interfere with a Servo, if one was attached)
    PB2 – DCC Input (Interrupt 0)
    PB3 – USB (Available for an Output, if the USB Software was never enabled with the ‘Serial.begin’ statement)
    PB4 – USB (Available for an Output, if the USB Software was never enabled with the ‘Serial.begin’ statement)
    PB5 – Reset (Can be made Available as an Output, with ‘special’ work – There is no Reset Button on the Board you used, but the RESET Function MUST be disabled, or DCC Commands might trigger a RESET)

    The way I see it, this device could easily be used as a Mobile (Multi-Function) Decoder with
    – Up to 3 On/Off Functions (PB0, PB1 & PB5), or
    – Up to 2 Servos (PB0 & PB5) and 1 On/Off Function (PB1)
    (Assuming the issue with running Servos on an ATtiny85 can be resolved)

    Or, as 1 or 2 Accessory Decoder Functions, controlling:
    – One 2-Aspect Signal (PB0 & PB1), or
    – One Point Controller (PB0 & PB1), or
    – Two 2-Aspect Signals (PB0 & PB1 and PB3 & PB4), or
    – Two Point Controllers (PB0 & PB1 and PB3 & PB4), or
    – One 3-Aspect Signal (3 of PB0, PB1, PB3 & PB4), or
    – One 4-Aspect Signal (4 of PB0, PB1, PB3 & PB4)
    (Using LEDs with a Common Anode or Cathode increases the options to you, but I trust you get the gist here)

    The Inbuilt LED would then indicate One of the Two possible states of the Signal or Point. Obviously (?), there would need to be additional Circuitry to Control Point Motors, because the ATtiny85 can Supply (Or Sink) up to it’s “Absolute Maximum” of 40 ma per Pin (But up to 20 ma is preferable – Refer to the Datasheet for all the details).

    Liked by 1 person

    Posted by Warren | April 6, 2017, 13:26
  5. Hi Rudy,

    First of all, thanks for all the work you’ve done – very much appreciated.

    I have installed successfully on an ATTiny85 and I have been testing using mode 1 with an led on pins 0, 1, 3, & 4. Everything is fine on pins 1, 3, & 4 and I can toggle the led on/off but something strange seems to be happening on pin 0. On startup, the led is bright as expected but when I try to toggle the led off, the led just darkens a bit and does not ‘go LOW’. It does toggle back to bright again but never goes off.

    Have you come across this behaviour before or do you have any ideas?

    Thanks in advance.
    Graham.

    Like

    Posted by Graham Sutherland | April 3, 2017, 18:13
    • Graham, it’s a little hard to know exactly what you are doing, without a Reference to exactly which pin you are referring to.

      Here are 2 diagrams (I prefer the first):
      1 – http://marcusjenkins.com/wp-content/uploads/2014/06/attiny.pdf (ATtiny85 in the Top Half)
      2 – http://pighixxx.com/attinypdfv3_0.pdf
      (#2 says that the Current Limit is 10 mA per pin, and the Datasheet says it is 40 mA Maximum. So, given this error, what else is wrong too, but I just don’t know it yet?)

      You can’t be referring to Chip Pin Numbers, because they start at 1, and you are referring to 0. So, here is what I have assumed that you are using:
      PB0 – Digital or Analogue Pin
      PB1 – Digital or Analogue Pin
      PB3 – USB (If you are using a Pre-Fabricated Board, therefore a Limit of about 3.6 Volts Output)
      PB4 – USB (If you are using a Pre-Fabricated Board, therefore a Limit of about 3.6 Volts Output)

      The other pins are
      PB2 – INT0, used for DCC Input
      PB5 – RESET, so (Typically) Not Used

      This Circuit Diagram of the Digispark Board that uses the ATtiny85 shows the Zener Diodes on PB3 & PB4:
      https://s3.amazonaws.com/digistump-resources/files/97a1bb28_DigisparkSchematic.pdf

      As you can see from the Circuit Diagram, of the 4 Pins you are using, PB0 is the ONLY pin that has nothing connected to it, so it SHOULD be the pin most likely to work the best!?!?!

      All in all, PB0 should work just fine. It might be worth you posting your Code, in case that is where the issue is, rather than in the Hardware.

      You code should have something similar to the following line:
      pinMode(PB0, OUTPUT); // set the digital pin as Output
      (You would have one of these lines for each Output Pin)

      Or you would use a Loop and Index, that might look something like this:
      for (MCU_Pin_Number = PB0; MCU_Pin_Number <= PB4; MCU_Pin_Number += 1)
      {
      pinMode(MCU_Pin_Number, OUTPUT); // set the digital pin as Output
      }
      pinMode(PB2, INPUT); // set the digital DCC Input pin as Input

      When writing to a Pin with a LED attached, you might use something like this:
      int LED_State = LOW;
      digitalWrite(PB0, LED_State);

      ===
      You could try this code, to see if it works correctly (On for 1 second, Off for 1 second, forever!)…

      // The setup function runs once when you press reset or power the board
      void setup()
      {
      pinMode(PB0, OUTPUT); // initialize digital pin PB0 as an Output.
      }

      // The loop function runs over and over again, forever
      void loop()
      {
      digitalWrite(PB0, HIGH); // Turn the LED On by making the Voltage Level HIGH
      delay(1000); // Wait for 1 second
      digitalWrite(PB0, LOW); // Turn the LED Off by making the Voltage Level LOW
      delay(1000); // Wait for 1 second
      }

      If the above Code works correctly, then your other Code / Sketch is the issue. If this Code doesn't turn the LED on PB0 Off completely, it is a Hardware issue (Or the 'Configuration Fuses' in your ATtiny might be set to some configuration other than normal).

      Like

      Posted by Warren | April 6, 2017, 23:31
      • Is there any way to Post a Picture here?

        Like

        Posted by Warren | April 7, 2017, 18:04
      • Graham, I have given a lot of thought to how someone might be able to get a LED to Glow Brightly, then Glow Dimmer (But not OFF). And, I can’t for the life of me work it out.

        I prefer the Right circuit, that has the Resistor at the Top, because the Resistor limits the current as soon as possible. After the Resistor, the maximum Current that can flow is determined by the Resistor, and it’s typically less than 20 mA. Using the circuit on the Left, short circuiting the LED’s Cathode to ground is likely to destroy the LED.

        When using Open-Collector Transistor Switching, the Earth is being Switched, so there is a valid reason to limit the Current as soon as possible, because the LED has a Voltage applied to it all the time.

        The 2 most common ways to switch a LED are:
        1 – For the MCU Pin to be set to HIGH, supplying a Positive Voltage (Typically +5 Volts), and “Sourcing” the Current to the Point marked “1” (There is a Ground permanently attached to Point 3).
        2 – For the MCU Pin to be set to LOW, supplying a Ground, and “Sinking” Current from the Point marked “3” (There is a Positive Voltage permanently attached to Point 1).

        It’s also possible to use either the Left or Right circuit, and do something that is less useful (And waste more Current) than the above.

        Using the Left Circuit, and with the MCU Pin connected to Point 2, setting the MCU Pin to HIGH will turn the LED Off, but the MCU Pin is now Sending (Sourcing) current through the Resistor to Earth.

        Using the Right Circuit, and with the MCU Pin connected to Point 2, setting the MCU Pin to LOW will turn the LED Off, but the MCU Pin is now Receiving (Sinking) current through the Resistor from +5 Volts.

        ===
        Now, looking at the 4 Possible ways that the LED could actually Glow Brightly, I can find no way to wire the LED, the Resistor and the MCU Pin, so that you will get a Bright or Dim LED, but no Off LED.

        So, I can’t see that there is a way to get a Dim LED, without destroying the LED. Consider this:
        1 – Using the Right Circuit
        2 – Using a REALLY Large Resistance Value
        3 – Connecting the MCU Pin to Point 2
        4 – The MCU Pin is somehow in a High Resistance state (So all the Current is going from the +5 Volts. through the Resistor and the LED)

        With a sufficiently high Resistance Value, there would be little Current to make the LED Glow, and it would therefore be Dim. If you then set the MCU Pin to HIGH, and Provide current to the LED at Point 2, (Using PB0) you will send +5 Volts to the LED, with NO Resistance.

        I would expect the LED to glow VERY Brightly for LESS than 1 Second, then extinguish, because it has been destroyed bt the MCU Supplying too much current.

        The Datasheet for the ATtiny85 (http://www.atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf) isn’t much help in clarifying what the MCU will do in the situation.

        Section 21.1 on page 161 says: “DC Current per I/O Pin .. 40.0 mA”. But, it doesn’t say what limits that current. Is the Maximum Current limited Internally by the MCU, or is it up to the Designed to ensure that the 40 mA limit is never exceeded using external Resistance?

        if the Current IS limited Internally, then delivering 40 mA into a LED is unlikely to destroy it. However, I don’t feel like finding out for sure, using one of my MCUs!!!

        ===
        In summary Graham, it’s really difficult to help you any further, without the following information:
        – How the LEDs are wired,
        – The Resistance Value you have used for EACH LED,
        – Whether a Power Supply of more than 5 Volts is being used, and
        – The Code in your application,

        Like

        Posted by Warren | April 8, 2017, 09:42
      • Hi Warren,

        Wow, thank you for your replies. The amount of depth you have gone into is fabulous and it seems as though you hit the nail on the head with the pinMode function.

        The code I was using (from October 2014!) was the Servo and function Decoder with this section of code within ConfigureDecoderFunctions()…

        for (int i = 0; i -1′, the pin responded as expected.

        Please accept my apologies for my late reply and thank you again for all the effort you have put in.

        Best regards,
        Graham.

        Like

        Posted by Graham sutherland | April 10, 2017, 11:20
      • apologies I forgot the code tags…

        It should have been:
        for (int i = 0; i < maxfunctions; i++)
        {
        if ( gAddresses[i].outputPin )
        {
        pinMode( gAddresses[i].outputPin, OUTPUT );
        }
        gAddresses[i].onMilli = 0;
        gAddresses[i].offMilli = 0;
        }

        when I changed the ‘if’ condition to ‘> -1’, the pin responded as expected.

        Graham.

        Like

        Posted by Graham sutherland | April 10, 2017, 11:30
    • I have no idea. What happens when you try the internal example of the “Blink” code that flashes a LED on / off with just a couple of lines of code? Can you try that for all pin nr outputs?

      Like

      Posted by RudyB | April 9, 2017, 10:17
      • Hi Rudy,

        My replies to Warren above show the correction so I wont bore you by repeating them here.

        Thanks to all the great work you do, I now have an ATtiny85 controlling two servos with two pins indicating direction!

        Best regards,
        Graham.

        Like

        Posted by Graham sutherland | April 10, 2017, 11:34
      • Hello Graham
        You can post the sketch for the servos with the attinyvfor me?
        That would be great.
        Thank you very much.

        Olaf

        Like

        Posted by Olaf | April 26, 2017, 19:07
  6. hey wold be possible to use this as a loco decoder?

    Like

    Posted by Tibor Otto Dettruz (Omgalof) | December 1, 2016, 16:47
  7. Hello Rudy!

    Thanks for a fantastic and informative homepage.

    I hope this post is still active, because i’m loosing my hair really fast here 🙂

    The last couple of days, i’ve been working on a Attiny85 solenoid project for turnouts.
    I have a working Arduino Uno setup, but want to make it smaller – and because my fascination of, what that tiny chip is able to do.

    To begin with, I started out with your DCC Accessory Decoder. The code is working fine with the Arduino uno, but with the Attiny85 I get the same problem as posted by Leo January 26, 2016, 15:31.

    With only one DCC address it works like a charm, with one more, nothing works.

    Do you have any idea where to start?

    Best regards

    Michael

    Like

    Posted by Michael | August 18, 2016, 19:52
    • Hi Michael. I’m sorry to hear that as soon as there’s more than one address configured nothing works. I don’t know if I have time but if you can send me the file I may have a chance to look into it. I sent you an email.

      Like

      Posted by RudyB | August 19, 2016, 09:42
  8. Hi Rudy,I was hoping this function decoder would allow me to use a IR sensor together with Train Controller to sense a train passing a given point on the track, but then I realized that your decoder has to have an address provided to it to work, in other words opposite to what I need. Could you give me any suggestions as to how I could use a simple IR sensor to detect movement and then convey this to Train Controller Silver. any help would be greatly appreciated.
    StewMac (From Train Controller Forum).

    Like

    Posted by Stew McManus | July 30, 2016, 16:01
  9. Hello, I have a question I want to build a Minidecoder for a servo for my garden railway, it would be ideal if I could take the protokol Attiny for this servo incl . DCC . Have ye here a hint that sketch I could use ?
    Olaf from Dortmund (Gemany)

    Like

    Posted by Olaf Reis | March 10, 2016, 20:21
  10. Dear Rudy,

    What I don’t see in your post is the arduino alimentation. In your video the arduino is power by the USB but in the wagon we have only DCC signal.
    Thanks in advance for your help.
    Manu

    Like

    Posted by Emmanuel Cordier | March 6, 2016, 07:51
    • Correct, when used inside rolling stock, a lil power supply will be needed, can be made using a diode bridge rectifier, a capacitor and a resistor between diodes and C to limit the power switch on current.

      Like

      Posted by RudyB | March 6, 2016, 12:15
  11. Hello,
    i wanted to use your program for the attiny accessory decoder on a attiny45 to switch leds on and of. i tryed with a schematic without optocoupler but with a 2k2 resistor like here: http://www.mikrocontroller.net/attachment/10896/DCC-Decoder_t15.jpg is there anything i must change in the sketch? because no dcc input is recognized.
    best regards leo

    Like

    Posted by Leo | January 25, 2016, 19:40
    • It’s really hard to tell if there’s no reaction to the DCC what the cause is. Maybe best build the opto coupler circuit for test purposes and try from there if you can solve the issue?

      Like

      Posted by RudyB | January 25, 2016, 20:11
      • Hey, me again,
        i made some progress, i now can use the attiny as a accessory decoder for 1 LED, means just 1 😦 if i just configure one accessory everything works fine (exept that i have to switch it on and off with my roco multimouse saying address 5 even if i said address 1 in the sketch…) but as soon as i try more than just one address and accessory nothing works, even the first one that previosly worked, does nothing anymore…
        the function decoder sketch does nothing at all… 😦
        perhabs you could give me some hints?

        greetings leo

        Like

        Posted by Leo | January 26, 2016, 15:31
      • I’ve sent you an email so we can try solve this mystery.

        Like

        Posted by RudyB | January 26, 2016, 17:12
    • Leo, I don’t know whether you’ve noticed, but there are some Issues with the Circuit you have decided to use, not the least of which is incorrect Pin Numbers!?!?!

      The circuit says that the L272D is to get VCC on Pin 4, and Ground on Pin 5. The L272 Datasheet (http://www.st.com/content/ccc/resource/technical/document/datasheet/02/9c/bc/75/59/9c/47/bd/CD00000054.pdf/files/CD00000054.pdf/jcr:content/translations/en.CD00000054.pdf) says that Ground is actually Pin 6. If you look carefully, Pin 5 on the L272D is used TWICE!?!?!

      Then, there is the matter of Voltage Regulation – There is NONE, in the normal sense of the word, just a Zener Diode (D2)!!! Resistor R1 sets the Voltage delivered to the ATtiny15L, with D2 trying to keep everything below whatever Voltage it is.

      The DCC Input, via R2 goes to PB2 (INT0), which – Pin wise – is pretty standard. However, if the Current into PB2 goes Up and Down, then so will the Unregulated Voltage. As the DCC Specifications allow for the Input to a Decoder to be in excess of 20 Volts, if the Consumed Current becomes very small, the Voltage applied to PB2 will approach the Voltage applied to the Track (My Z21 supplies 18 Volts).

      Unfortunately, the ATtiny15L has: “Maximum Operating Voltage … 6.0V”. It looks like this could easily be exceeded.

      ===
      Given Design issues such as the above, your use of a 2.2K Resistor – just because this design uses a 2.2K Resister – isn’t necessarily sound logic.

      The circuit you are following applies the Full (Un-Rectified) DCC Track Voltage to PB2 on the ATtiny15L. One of the Purposes of the Optocoupler is to avoid that at all costs.

      You don’t say what you did to get your ATtiny to work (So I guess we will never know now). But, as Rudy suggested, you should first try what Rudy has proven to work.

      If you want to use a different circuit, from a different website, then maybe you should be asking your questions there.

      Like

      Posted by Warren | April 9, 2017, 14:16
  12. Hello Rudy, it is so good to see a skilled engineer bringing new opportunities to the model railway hobby, it is the software that brings the hardware “to life “after all!. You are providing so many projects for us to experiment with its quite hard to keep up with your progress! I want to try all of them …..
    Regards
    MartinK

    Like

    Posted by martinkirkby | November 9, 2015, 21:10
  13. Hi Rudy,
    Slight error in line 6 regarding mode numbers with reference to line 27 in RB_DCC_Decoder_Accessory.ino
    Alex

    Like

    Posted by alex | October 21, 2015, 19:12
  14. Very nice application. I have developped something similar for bigger Arduinos (https://git.framasoft.org/locoduino.org/UniversalAccessoryDecoder), but my version of the Mynabay’s hardware is a lot bigger than yours. How have you collapsed all the components of the DCC hardware interface in such a small volume ?

    Liked by 1 person

    Posted by Trusty | October 21, 2015, 07:53
    • Ehh, I really don’t know … I haven’t changed anything in the Mynabay library. I was not even aware there are different versions around. Actually this version still is much too big. I’m now working on code that is really small and only has the bare necessaties for an accessory- or a function decoder.

      Like

      Posted by RudyB | October 21, 2015, 15:37
      • Good news, but I was speaking on the hardware part, the Optocoupler and other compenents of the mynabay circuit which seems to just have the size of the optocoupler itself !

        Like

        Posted by Trusty | October 22, 2015, 06:50
      • O, haha, yes, I see now I misread your question. Well, the ATtiny is a PCB, bought as such at a size of 22×18 mm. The optocoupler, diode and 2 resistors are mounted on a PCB, twice the size of the opto. All and all maybe still a bit too large to build into an N scale wagon.

        Like

        Posted by RudyB | October 22, 2015, 07:34
  15. leuk projectje
    ik ga het proberen

    Like

    Posted by dick koning | October 16, 2015, 10:27
  16. Hoi Ruud,

    Mooi project. Ik heb er net een paar aangeschaft om random LED te programmeren, maar dit project is helemaal geweldig.
    Hoe kom ik overigens aan de library ?
    Via Mynabay zie ik geen mogelijkheid om deze te downloaden.

    Groeten,
    Pieter

    Like

    Posted by Pieter Bruinsma | October 15, 2015, 17:20
  17. Very good Rudy. Off to the shop’s to buy one or two cheers

    Jim

    Like

    Posted by Jim Hardie | October 15, 2015, 12:47

Trackbacks/Pingbacks

  1. Pingback: Workshop – Teil 2: Und es wird (vielleicht) doch digitalisiert | BC Northern Rail - March 15, 2019

Leave a comment

Archive of all posts