Index of /people/artem/projects/tools/rt_control
Name Last modified Size Description
Artem: tools: rt_control
Parent Directory -
communicate.c 27-Jan-2006 12:15 12K
control.c 27-Jan-2006 12:15 11K
control.h 27-Jan-2006 12:15 1.2K
rt_control.c 27-Jan-2006 12:15 7.4K
rt_control_report.m 27-Jan-2006 12:53 472
rt_control_saved.m 27-Jan-2006 12:53 801
rt_info.h 27-Jan-2006 12:15 1.5K
To be used with sub-kernel real-time linux (RTAI). Uses Comedi library to listen on input channels and provide real-time feedback on output channels of National Instruments DAQ board. The core module (rt_control.c, rt_info.h) originally written by Alan Chen. In the present version the control algorithm is defined in a separate file (control.c, control.h) to simplify user implementation. Other modifications include multichannel functionality and extra fifos for interprocess communication (comminucate.c).
- To start the sub-kernel module:
- root@RTAI_host:/root/rt/bin# /sbin/insmod rt_control.ko
- To start the user communication process:
- root@RTAI_host:/root/rt/bin# ./communicate outfilename
- The process displays event statistics every 30 seconds in the following format:
timestamp trig_events thresh_events reported_events baseline_voltage_mV
Same information is written to a outfilename.report, except that the timestamp is saved in seconds without hh:mm:ss formatting
- User interaction:
- 'Ctrl-C' to bring up the prompt.
'?' to list available commands.
- Present control algorithm:
- A longer 'baseline' window is followed by a shorter 'probe' window. When the difference in baseline and probe average crosses the specified threshold the 'ON' state is noted. If this 'ON state' is sustained for a specified duration, an 'event' is 'detected' and a command output is issued.
- Hardware connections assumed by control algorithm:
connect the signal of interest to AI0 (analogue input #0)
optional: connect external trigger to AI1 (see 'g' below)
optional: connect external threshold level control to AI2 (see 'e' below)
read feedback command voltage pulses from AO1 (see 'a' and 'w' below)
read timeout indicator from AO0 (see 'b' below)
optional: add probe voltage average to AO1 (set 'm=2' or 'm=3', see below)
optional: read averaged baseline voltage from AO0 (set see 'm=1' or 'm=3', see below)
- Interaction with rt_control module (commands supported by communication interface)
t - threshold voltage, millivolts, negative value for downward polarity
o - detection timeOut, milliseconds, if we do not want events too close in time
p - probe time window, milliseconds, use this to average sampling noise
b - baseline time window, milliseconds, use this to average baseline level
d - minimum duration requirement for reportable events, milliseconds
g - attention span after external triGGer, milliseconds, '0' to turn off
s - save traces of detected events, limited to one event per report period
e - turn on/off threshold level readout from an external analogue input
a - command amplitude, mV
w - command width, us
m - extra output monitors: 0='none', 1='baseline', 2='probe', 3='both'
l - write one-line note to a log file, nothing is sent to rt_control process
q - save statistics, close connections to rt_control, quit
- Capturing traces of events (see b,o and s commands of communication interface)
- We continuously keep record of all the samples in 'baseline' and 'timeout' time intervals. After an event is reported, 'baseline' samples are frozen and 'timeout' samples are collected to allow the 'capture' of input signal trace for the 'event'. Saves in microvolts as 32-bit integers.
- Loading recorded data into Matlab:
rt_control_report.m loads reported statistics:
rt_report = rt_control_report('20060118_rt/20060118_test1.report')
rt_control_saved.m loads captured traces of detected events:
rt_traces = rt_control_saved('20060118_rt', '20060118_test1.00*', 10000)
where three parameters are: folder, filename pattern for multiple traces, sampling frequency (Hz).
Plot like this:
Send complaints, comments, suggestions to Artem Starovoytov