Porting Scicos-HIL to Scilab 5.0
"Welcome the the _REAL_ world"
- After the usual analysis, simulation and tuning phases, Scicos can also be used to run your controller connected with real plants.
What means "Hardware In the Loop" ? The short story:
- you run a Scicos with some components not as simulated "computational functions" but as REAL things connected with the simulation in real time using data acquisition cards or other interfacing device.
The long history:
- a Scicos diagram is composed by blocks connected by links. Inside each block there is a "computational function", usually a little piece of C code that "simulate" the real device. Scicos-HIL add some blocks that talk with data acquisition cards. With data acquisition cards you can connect a "real" devices as sensors (e.g. an encoder) or actuators (e.g. a motor). In this way it is possible run the Scicos simulation in direct connection with real "plants" and verify the real performances of your controller. Scicos-HIL is a tool developed for medium and low speed closed loop applications (up to 1ms sampling time), but it can be used also for high speed open loop applications using buffered data acquisition cards.
Why real time simulation it is so important for Scicos-HIL ? For open loop applications:
- with buffered data acquisition cards there is no data loss: the data arrives to Scicos with some delay (called "latency") but nothing is lost. Most of the modern data acquisition cards have an internal buffer of sufficient to hide the operating system's latencies.
For closed loop applications:
- "latency" are not permitted: any variation of the _real_ sampling time means alteration in the performances of the plant/controller. Serious latencies can cause degradation or full loss of closed loop system's stability.
The two "flavors" of Scicos-HIL
For Windows
- The real time (latency) performances of the "standard" Windows are very poor. The sampling time is limited to 20 ms.
- The data acquisition card support is very device dependent. You must install device drivers and dll libraries.
For Linux
- The real time performances of the latest 2.6.2x kernels are very good, close to hard real time. Many distribution offer packaged kernels optimized for low latency (e.g. audio) applications. Scicos-HIL is "hard real time ready" using Linux-RTAI or Linux - RT_PREEMPT patches.
- The data acquisition card support is very good using Comedi device drivers and comedi libraries (see www.comedi.org). Some Linux distrubition offer Comedi as packaged application.
- Scicos HIL support also HID USB devices like Measurement Computing USB data acquisition cards.
For Mac OSx
- I'm sorry: Scicos-HIL is not yet available for Mac. It is a real sin because OSX has excellent latency performances.
Scicos-HIL internal organization
Scicos-HIL is organized like any other Scilab 5 modules (there are only few minor differences).
The directories structure is :
modules / scicos_hil / demos / linux / windows / macosx / etc / examples / linux / windows / macosx / help / en_US / scicos_hil_doc / fr_FR / images / includes / locales / macros / linux / comedi / meascomp / rtai / preempt_rt / windows / meascomp / macosx / palettes/ linux / comedi / meascomp / rtai / preempt_rt / windows / meacom / macosx / sci_gateway / c / fortran / src / c / linux / comedi / meascomp / rtai / preempt_rt / windows / meascomp / macosx / scicos_hil.start scicos_hil.quit
1. External dependencies and tools
For the Scilab binary versions:
- Linux
- Comedi: if you want to use Comedi supported cards you need to install the Comedi drivers (kernel drivers). Please use the version suggested in the "README" file if you want immediate results.
MeasComp : many ISA, PCI and PCCards (formely PCMCIA) Measurement Computing interfaces are included in Comedi. The MC USB cards use the USB HID (Human Device Interface) standard as kernel driver. Recent 2.6.1x / 2.6.2.x Linux kernel offer complete USB HID support, so you don't need to install kernel device driver. Warren Jasper (https://www.github.com/wjasper/Linux_Drivers) has prepared a specific library for MC USB family (usbhid). This shared library is provided pre-compiled and loaded at run time. Python drivers also available
- RTAI: to use RTAI specific blocks you need a full Linux-RTAI installation.
- PREEMT_RT: you need a PREEMPT_RT patched Linux kernel
- Windows
- Measurement Computing: for the moment, Scicos HIL support only Measurement Computing USB cards. The USB HID driver is included in the standard Windows installation, but the dll library must be installed (provided by MC).
For the Scilab source versions
- Linux
- Comedi: if you want to use Comedi supported cards you need to install the Comedi drivers (comedi) and Comedi library (comedilib). The full source code is available form the Comedi project web site www.comedi.org. The Comedi project is a very "dynamic" project: please use the suggested "stable" version (see the README file) if you want to avoid problems.
MeasComp : many ISA, PCI and PCCards (formely PCMCIA) Measurement Computing interfaces are included in Comedi. The MC USB cards use the USB HID (Human Device Interface) standard as kernel driver. Recent 2.6.1x / 2.6.2.x Linux kernel offer complete USB HID support, so you don't need to install kernel device driver. The full source code of "usbhid" library from Warren Jasper (https://www.github.com/wjasper/Linux_Drivers), including the test programs is available as "external" package (put some web address here)
- RTAI: to use RTAI specific blocks you need a full Linux-RTAI installation.
- PREEMT_RT: you need a PREEMPT_RT patched Linux kernel.
- Windows
- Measurement Computing: for the moment, Scicos HIL support only Measurement Computing USB cards. The USB HID driver is included in the standard Windows installation, but the dll library must be installed (provided by MC). If you want to develop under Windows, you need the usual Microsoft tools (the "free as a free beer" Visual C++ Express 2005 will suffice) and the MC development library (available from MC).