Forums Power and Sound Power and Sound
  • Topic: Intoducing AirDCC : Airwire-Compatible Arduino Library

    Back To Topics
    (0 rates)
    • January 7, 2018 9:31 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      Intoducing AirDCC : Airwire-Compatible Arduino Library

      I have polished up my AirWire-compatible library for the Arduino, and named it AirDCC.  Here is a link to the repository on GitHub: https://github.com/ereuter/AirDCC

       

      To make this work, you need a CC1101 module such as this one: (Link to Amazon)

      These run at 3.3 V, so to connect to a 5 V Arduino, such as the Uno, you need one of these: (Link to Amazon)

      Both parts are cheaper on eBay if you want to wait for shipping from China.

       

      To install, download the zip file, unzip into your /arduino/libraries folder, wherever that is on your computer.

       

      There is an example accessory decoder program included, available under the examples submenu.  This uses the DCC_Decoder library that is available in the Arduino Library Manager.  The example decoder decodes 4 accessories and toggles separate pins for on & off, plus a servo pin.  You can define the accessory addresses, the pins you want to use, and the two limits for each servo.  All of the states are saved to EEPROM and restored on power-up.  You can also define the AirWire channel.  This is hard-coded at the moment, but will eventually be a CV.

       

      The library also works for transmitting.  You will see variables in the example for transmit and power.  This is what I'm using for my JMRI interface.  More on that soon.

      This post was edited by Eric Reuter at January 8, 2018 10:55 AM EST
    • January 8, 2018 6:16 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      Here's the example sketch running on a Arduino Pro Mini with three servos:

    • January 8, 2018 9:53 PM EST
      • Charlottesville, Virginia
         
      • Posts
        297
      • Thanks
        2
      • Thanked
        21
      • Reputation
        Well Respected

      Cool.  Is that a pro mini on the breadboard? I can't quite tell.  I do love the atmega328.  Really great micro.  I can also see why everyone likes that airwire knob!

      Man, a git repo on LSC.  Nice looking code too.  That is awesome.

    • January 9, 2018 6:17 AM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      Thanks, Martin. Yes, a Pro Mini.  There are 4 servo outputs (I only had 3 servos handy) and 8 open collector outputs, which is what the string of  transistors is for.   I have since added LEDs for each of the four channels to indicate status.   The back of the board isn't as pretty. :)

    • January 10, 2018 2:24 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      I've found that I can scan all of the AirWire channels in less than a second and recover 2 or 3 packets from each at that rate.  I'll work up a display that shows all of the locomotives running on each channel.  Here's raw data from 2 throttles (one real, one JMRI).  Format is [Channel Loco Direction Speed].

    • January 11, 2018 10:24 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      Using my library, I created a scanner, and we tried it out at the club meeting tonight.  Here's a screen shot:

      It scans all the channels ever second and displays the unit, speed, and direction for each active throttle.

    • January 11, 2018 10:40 PM EST
      • Branchport, NY
         
      • Posts
        145
      • Thanks
        9
      • Thanked
        5
      • Reputation
        Well Respected

      Eric

      You never cease to amaze me!

      Tom

       

    • January 11, 2018 10:47 PM EST
      • Charlottesville, Virginia
         
      • Posts
        297
      • Thanks
        2
      • Thanked
        21
      • Reputation
        Well Respected

      Very cool. What is this running on and what is it written in?  Software Nerds need details :)

    • January 11, 2018 10:58 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      The Arduino does the scanning and sends a string for each DCC packet over usb/serial (see the post above for raw data). The display is Python using curses, running in a terminal window. 

    • January 14, 2018 7:05 PM EST
      • Kittery, ME
         
      • Posts
        395
      • Thanks
        26
      • Thanked
        86
      • Reputation
        Well Respected

      I did a demo of the AirDCC library the other night at the NHGRS meeting, and prepared a photo and schematic. I thought I'd put them here. This is running the example code provided with the library, but could be adapted to multiple uses.  Note that for servos, an external 5V source should be used.  

       

Forums Power and Sound Power and Sound

    Icon Legend

  • Topic has replies
    Hot topic
    Topic unread
    Topic doesn't have any replies
    Closed topic
    BBCode  is enabled
    HTML  is enabled

Add Reputation

Do you want to add reputation for this user by this post?

or cancel

Ads by Google