Large Scale Central

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.

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

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.

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. :slight_smile:

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].

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.

Eric

You never cease to amaze me!

Tom

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

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.

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.