cmri

Dec 2013 5

ArduinoCMRI and RS485

A fun little side project of mine is Arduino C/MRI, a library that lets you easily connect your Arduino projects up to the JMRI layout control software, by pretending to be a piece of C/MRI hardware. Hence the name.

In previous episodes, we've looked at various methods of expanding the capabilities of Arduino C/MRI; be it by using shift registers, or emulating larger boards. But at some point you're going to need more than just one board, and that's where things get confusing.

The logical answer, you would think, is to connect multiple Arduino's to your computer. Simple. One USB cable for each one. The problem is, JMRI is not designed to address more than one C/MRI system at once. Trust me, I've done everything including hacking the XML config f...

Read full post...
Sep 2013 30

Simulating Railroad Crossing Lights

Everyone has seen a railway crossing before, and if you're a railfan you've probably spent more than a few hours stuck behind them waiting for their infernal blink-blink-blink to stop so you can continue chasing your train!

How do you make your model crossing blink like that though? The simple answer would be a 555 timer in astable mode with some set and reset triggers. But that would be easy, and when you're an software engineer everything looks like a software problem. So instead, we attack the problem with a sledgehammer and use an Arduino.

Kidding aside, there are very valid reasons why you might want to use an Arduino for such a simple problem. Suppose you're using the excellent Arduino CMRI library to connect your layout to

Read full post...
Sep 2013 23

Addressing many LEDs with a single Arduino

A fun little side project of mine is Arduino C/MRI, a library that lets you easily connect your Arduino projects up to the JMRI layout control software, by pretending to be a piece of C/MRI hardware. Hence the name.

A common problem when using Arduino C/MRI is dealing with lotsĀ of inputs and outputs. As an example, lets wire up a simple non-CTC crossing loop here in New Zealand. It is about as simple as you can get:

Each end consists of:

A turnout. We'll need 1 digital output to drive that. A route indication signal on each leg of the turnout. We'll need an LED for red, and one for green (technically it'd be blue here in NZ). That's 3 pairs of outputs = 6 more. A push button ...
Read full post...
Sep 2013 22

Driving many outputs with Arduino C/MRI

A fun little side project of mine is Arduino C/MRI, a library that lets you easily connect your Arduino projects up to the JMRI layout control software, by pretending to be a piece of C/MRI hardware. Hence the name.

Hello World

The basic "hello world" example is fairly straightforward, wiring up a JMRI light to a physical LED on the Arduino board.

#include <cmri.h> CMRI cmri; void setup() { Serial.begin(9600); // make sure this matches your speed set in JMRI pinMode(13, OUTPUT); } void loop() { // 1: main processing node of cmri library cmri.process(); // 2: update output. Reads bit 0 and sets the LED to this digitalWrite(13, cmri.get_bit(0)); }

It's easy enough to extend this example to handle 5, 10, even 15 outputs... if you have an Arduino Mega, you could have a LED on...

Read full post...