Monday, January 6, 2014

RIO grande railroad

While brainstorming further the idea of model railway control, I received a myRIO box from NI, which opened my mind. 

RIO Architecture

National Instruments provides several RIO product families for various measurement and instrumentation needs. These families are FlexRIO, CompactRIO, Single- board RIO and myRIO. All the RIOs are sharing the same basic architectural concept with CPU, FPGA and IO. The name RIO stands for Reconfigurable I/O.


The FPGA makes RIO solutions good for fast real-time and IO-intensive signal processing. For different purposes, NI provides number of LabView modules that integrates with the FPGA. User does not need to know anything about VHDL or FPGA programming in order to benefit from the performance of the FPGA chip, the LabView takes care of that. With help of LabView FPGA Module, there is also option to program the FPGA directly with VHDL, if needed.

myRIO

Recently, NI introduced myRIO product  for educational purposes. The device has dual-core ARM Cortex-A9 CPU and Xilinx FPGA chip. Other key features include WiFi and USB connectivity, 40 lines of digital I/O, 10 analog inputs, 6 analog outputs, and audio in/out.

NI myRIO
The myRIO CPU runs Linux RTOS, fully supported by LabView graphical programming environment. Reasoning for Linux is presented in this NI whitepaper. In addition to LabView programming, C/C++ can be used, and Eclipse IDE is officially supported by NI as well. However, when implementing program with C/C++, LabView FPGA Module is needed to get access to IO. As it does not make sense to use this specific hardware without using FPGA and IO.

Model railway control

As said, I just received a  myRIO box that I purchased for evaluation purposes. After spending quite a lot time thinking and investigating control solutions for model railway, as told in my previous posting, I rather soon invented that this box is suitable for implementing the safety function of a railway.

With 10 analog inputs, it can monitor presence of a train at 10 blocks of track, by simply measuring voltage over series shunt resistor. 6 PWM outputs or 6 analog output makes it possibly to drive DC-motors at 6 blocks, enabling speed ramp-up and ramp-down functions. Rest of the IO available can be used for train position sensors, switch control, and signals (semaphores).  USB host interface can be used for connecting RF modules for wireless communication with individual trains.

WiFi is convenient way to connect the myRIO box with a computer running a scheduler software for the operations of the railway, meanwhile the safety functions implemented in the myRIO prevents any accidents to occur.  For example, if a train has reserved a certain block or route, the RIO refuces to turn a switch on that reserved route, even if requested by the scheduler program. Or if a train is about to drive towards a red signal, the safety function can prevent that by switching power off from the section of track.

 LabVIEW for automation control

Using LabView to control a model railway is not unique. I found a scientific paper describing a similar setup. In that arrangement a PCI IO-card was used, and all control logic was running in control PC with LabView. In my scenario, the control is divided in a way that all the safety functions are implemented in RIO, and PC provides user interface and train scheduler.

Open source software  Rocrail is a good candidate for the higher level control and UI, as it provides well documented and open interfaces for control units. Of course, it is possible to implement UI with help of LabView as well, but why to reinvent the wheel?

Why then to use the LabView at all? First of all, all the existing model train control software are based on capabilities of commonly available COTS control systems.  What I'm looking here is something more, and readily available solutions do not exists to fully meet the requirements. Secondly, I believe LabView provides good productivity for all kinds of automation and control designs, model railways included.

Edit Jan. 19th:
Frankly speaking, myRIO is totally overkill for the application I described here. RIO architecture is good for fast signals. In the model railway, signals are rather slow in that sense.

I just found Arduino extension to Labview.  That looks like an ideal solution. First of all, Arduinos are inexpensive. One can connect several Arduinos simultaneously, and have scalability in system design. Arduino with LabView connectivity is fast enough for model railway control purposes.

Arduino has 6 ADC channels, 6 PWM outputs, and in total 13 DIO available. Simple railway layout can be constructed with only that. And more Arduinos can be connected if necessary.



1 comment: