| 1 |
|
| 2 |
GETTING STARTED: |
| 3 |
|
| 4 |
After installing comedi and comedilib, cd to this directory (comedilib*/demo). |
| 5 |
|
| 6 |
Use ./board_info for a very first test. If hardware and software are correctly |
| 7 |
installed, the program prints a list of subdevices it recognises. If the |
| 8 |
device is not /dev/comedi0, use here and in the following the command-line |
| 9 |
option -f <device>. |
| 10 |
|
| 11 |
Continue with ./inp -s <subdevice> -c <channel> to read individual samples, |
| 12 |
and with ./outp -s <subdevice> -c <channel> <integer value> to set an |
| 13 |
output value. Other beginning demos are: cmd, dio, inpn, tut1, tut2. |
| 14 |
You should understand how these work before trying to understand the |
| 15 |
other demos. |
| 16 |
|
| 17 |
The perl subdirectory contains a few examples for the perl wrapper. |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
DEMO PROGRAMS: |
| 22 |
|
| 23 |
ao_waveform: |
| 24 |
You need a device (and driver) capable of streaming analog output, |
| 25 |
which currently is some of the members of the NI AT-MIO and PCI-MIO |
| 26 |
E series. Creates a sine wave on an analog output channel. You |
| 27 |
can specify the frequency of the generated sine wave on the |
| 28 |
command line. |
| 29 |
|
| 30 |
board_info: |
| 31 |
Displays some information that Comedi knows about a device. |
| 32 |
|
| 33 |
choose_clock: |
| 34 |
Selects a master clock source. The subdevice must support |
| 35 |
INSN_CONFIG_CLOCK_SRC. The command-line argument specifies |
| 36 |
the clock source, and the optional -F option specifies the clock's |
| 37 |
frequency. |
| 38 |
|
| 39 |
choose_routing: |
| 40 |
Changes the signal routed to a specified channel. The subdevice must support |
| 41 |
INSN_CONFIG_SET_ROUTING. The command-line argument specifies |
| 42 |
the signal you want routed to the specified channel. This demo |
| 43 |
can be used, for example, to choose a what signal you want to |
| 44 |
appear on a PFI line (which has been configured as an output) |
| 45 |
of a National Instruments board. |
| 46 |
|
| 47 |
common: |
| 48 |
This is not an example. The file common.c just contains some code |
| 49 |
that is common to many of the examples. |
| 50 |
|
| 51 |
cmd: |
| 52 |
An example for directly using Comedi commands. Comedi commands |
| 53 |
are used for asynchronous acquisition, with the timing controlled |
| 54 |
by on-board timers or external events. If this demo doesn't work |
| 55 |
with your hardware, read the comments in the source. Hint: data |
| 56 |
is written to stdout, comments to stderr. |
| 57 |
|
| 58 |
dio: |
| 59 |
Requirements: A board with a digital I/O subdevice. Not just |
| 60 |
a 'digital input' or 'digital output' subdevice, but one in |
| 61 |
which the channels can be configured between input and output. |
| 62 |
Configures the specified channel as an output if passed a |
| 63 |
nonzero argument. Otherwise, the channel is configured as |
| 64 |
an input. Once the channel's direction has been configured, |
| 65 |
you can read/write to it with the inp/outp demo programs. |
| 66 |
|
| 67 |
do_waveform: |
| 68 |
Requirements: NI M-Series board. |
| 69 |
This demo uses the digital io subdevice with an |
| 70 |
asynchronous command to generate waveforms. The |
| 71 |
waveforms in this example are square waves with |
| 72 |
varying periods depending on the digital output |
| 73 |
channel. Channel N outputs a square wave with |
| 74 |
period 2*(N+1) clocks. The command line argument chooses the |
| 75 |
clock signal for updating the outputs. As a suggestion, |
| 76 |
you might use the output of one of the general |
| 77 |
purpose counters for a clock (the default clock |
| 78 |
source is the output of general purpose counter 0), |
| 79 |
and run the gpct_pulse_generator demo to start the counter |
| 80 |
generating pulses on its output. |
| 81 |
|
| 82 |
Note, you must configure at least one of the digital channels as |
| 83 |
an output (for example by running the dio demo program) |
| 84 |
before running this program. You must also pass the dio |
| 85 |
subdevice file using the -f option, since the default write |
| 86 |
subdevice for the m-series boards is the analog output. For |
| 87 |
example, "dio_waveform -f /dev/comedi0_sub2". |
| 88 |
|
| 89 |
eeprom_dump: |
| 90 |
Dumps the EEPROM of a card, if it has one. Useful for debugging |
| 91 |
devices/drivers. |
| 92 |
|
| 93 |
gpct_pulse_generator: |
| 94 |
Configures a NI general-purpose counter subdevice to produce a |
| 95 |
continuous train of pulses on its output. The -F option specifies |
| 96 |
the pulse period (as a frequency in Hertz), and the argument specifies |
| 97 |
the pulse width (in nanoseconds). By default, the pulse width will |
| 98 |
be set to half the pulse period. You may need to use the "dio" |
| 99 |
and "choose_routing" demos to route the counter's output to |
| 100 |
an output line that you can observe (for instance one of the PFI |
| 101 |
lines). |
| 102 |
|
| 103 |
gpct_simple_counting: |
| 104 |
Configures a NI general-purpose counter subdevice to act as a |
| 105 |
simple event counter. You can select the input to the counter |
| 106 |
using the "choose_clock" demo. The counter's value can be read |
| 107 |
out using the "inp" demo. |
| 108 |
|
| 109 |
inp: |
| 110 |
Simple input: Reads one sample from one channel on one subdevice. |
| 111 |
|
| 112 |
inpn: |
| 113 |
Slightly more complicated input demo. (It has a for() loop.) |
| 114 |
Reads each channel on a subdevice, at every possible input |
| 115 |
range, and converts the data to a voltage. |
| 116 |
|
| 117 |
insn: |
| 118 |
Example showing how to use instructions directly. Not |
| 119 |
recommended for beginners: use higher-level functions such |
| 120 |
as comedi_data_read(), comedi_data_write(), etc., as demonstrated |
| 121 |
in the inp, outp, and dio examples. |
| 122 |
|
| 123 |
ledclock: |
| 124 |
This demo requires a Fantazein clock modified to be directly |
| 125 |
controlled by the parallel port on a computer. The original |
| 126 |
demo used a real-time task and controlled the parallel port |
| 127 |
directly. This version is not complete. |
| 128 |
|
| 129 |
mmap: |
| 130 |
This example shows how to map the internal Comedi buffer |
| 131 |
and directly access samples instead of using read() and |
| 132 |
write(). This is very similar to cmd.c, so look there for |
| 133 |
comments on most of the code. |
| 134 |
|
| 135 |
outp <value>: |
| 136 |
Write one <value> to one channel of one subdevice. Requires |
| 137 |
a digital or analog output subdevice. |
| 138 |
|
| 139 |
pwm: |
| 140 |
controls PWM devices. Use the option -N 0 and -N 1 to switch |
| 141 |
it on / off respectively. Call with no arguments to get |
| 142 |
a help screen. |
| 143 |
|
| 144 |
receiver: |
| 145 |
This demo is meant to be used in conjunction with the sender |
| 146 |
demo. Receiver requires a digital input subdevice, and sender |
| 147 |
requires a digital output subdevice. When the clock and data |
| 148 |
pins are connected between the sending and receiving devices, |
| 149 |
one should be able to send bits over the link. |
| 150 |
|
| 151 |
select: |
| 152 |
An example for using select() with asynchronous input. This |
| 153 |
example requires an asynchronous input subdevice that can |
| 154 |
handle TRIG_TIMER as a scan_begin_src. |
| 155 |
|
| 156 |
sender: |
| 157 |
See receiver. |
| 158 |
|
| 159 |
sigio: |
| 160 |
Similar to the cmd demo. This demo sets up a signal handler |
| 161 |
for SIGIO, which is called whenever data is ready to be read |
| 162 |
from the device. |
| 163 |
|
| 164 |
sv: |
| 165 |
Similar to inp, but measures the input using the comedi_sv_*() |
| 166 |
functions, which average many samples to try to get a more accurate |
| 167 |
estimate of the actual input. |
| 168 |
|
| 169 |
tut1: |
| 170 |
tut2: |
| 171 |
Tutorial examples. See the Comedilib documentation. |
| 172 |
|
| 173 |
|
| 174 |
COMMAND-LINE OPTIONS: |
| 175 |
|
| 176 |
Many of these demos are linked with the file common.c, which parses |
| 177 |
command line options. Some options don't make sense with all programs. |
| 178 |
The options are: |
| 179 |
|
| 180 |
-a <aref> use analog reference <aref> (default: 0 == ground) |
| 181 |
-c <chan> use channel <chan> (default: 0) |
| 182 |
-s <subd> use subdevice <subd> (default: 0) |
| 183 |
-r <index> use voltage range <index> (default: 0) |
| 184 |
-f <file> use device file <file> (default: /dev/comedi0) |
| 185 |
-n <value> use <value> for the number of channels in a scan |
| 186 |
-N <value> use <value> for the number of scans |
| 187 |
-F <freq> use <freq> as the scan frequency |
| 188 |
-v verbose |
| 189 |
-d set analog reference to differential |
| 190 |
-g set analog reference to ground |
| 191 |
-o set analog reference to other |
| 192 |
-m set analog reference to common |
| 193 |
-p display values in physical units |
| 194 |
|