This is a sample that synchronizes generating/sampling inside one device.
Generating is master and sampling is slave.
This sample program requires selection of a device with analog output and analog input functions.
Please refer to Example 1 for Using Event Controller for synchronous operation.
Sample specification |
* This is the initial value of the sample program. |
Program name |
./internal_sync_generating_sampling |
Conversion data transfer mode |
0 (Device buffer mode) |
Start condition |
Master: 0 (Software) Slave: 10 (Event controller output) |
Clock type |
Master: 0 (Internal clock) Slave: 10 (Event controller output) |
Stop condition |
Master: 0 (Stop conversion by the specified times) Slave: 10 (Event controller output) |
Memory type |
0 (FIFO) |
Buffer size for saving data |
1MByte |
Event |
Master: Event that device operation end, Event that overflow, Event that generating clock period error, Event that DA conversion error Slave: Event that device operation end, Event that overflow, Event that sampling clock period error, Event that AD conversion error |
1. Specify the desired program name, run the
program, and a CUI(Character User Interface) menu that looks like the
one above will appear.
Appearance may vary depending on software version.
2. Initialize
- When selecting the command [1:
AioInit], you can specify the device name.
Notifies the device driver to start using the specified
device.
When specifying the device name, AioInit will be
executed and the CUI menu will be displayed again.
3. Analog input/output setting
- When selecting the command [3
: Analog I/O Set], you can specify the range for Generating(Master).
- When specifying the range for
Generating(Master), you can specify the range for Sampling(Slave).
- When specifying the range for
Sampling(Slave), you can specify the input method for Sampling(Slave).
Depending on the device used, the setting may not
be effective unless the input range is changed with the jumper pin on
the device.
- When specifying the input method
for Sampling(Slave), all analog input/output settings will be notified
to the device driver.
When the analog input/output settings are complete,
the CUI menu will be displayed again.
4. Generating Set, Sampling Set
- When selecting the command [4
: Generating/Sampling Set], you can specify the number of channels for
Generating(Master).
The starting channel number is fixed at 0ch. For
example, if 3 channels are specified, data will be acquired from 0ch to
2ch.
- When specifying the number of
channels for Generating(Master), you can specify the generating clock
period in units of [usec] for Generating(Master).
The minimum generating clock period value that
can be specified depends on the device used.
You should also consider
the specified number of channels when determining the clock period.
For details, please refer to the item of [Glossary]
Sampling clock period
error.
- When specifying the generating
clock period for Generating(Master), you can specify the generating times
for Generating(Master).
- When specifying the generating
times for Generating(Master), you can specify the number of channels Sampling(Slave).
The starting channel number is fixed at 0ch. For
example, if 3 channels are specified, data will be acquired from 0ch to
2ch.
- When you have specified the number
of channels for Sampling(Slave), all counter/analog input settings will
be notified to the device driver.
When the counter/analog input settings are complete,
the CUI menu will be displayed again.
5. Sync Operation Set
- When selecting the command [5
: Sync Operation Set], the start condition, clock type, and stop condition
will be notified to the device driver.
When the synchronous operation settings are complete,
the CUI menu will be displayed again.
6. Output Data Set
- When selecting the command [6:
Output Data Set], the generating output data with the data of the number
of points specified by the Generating Times will be generated.
The generated output data is notified to the device
driver.
When the generating output data has been generated,
the CUI menu will be displayed again.
Generated data: A
sine wave is generated according to the specified range. One
cycle is the specified Generating Times.
For
multiple channels, a sine wave with a phase delay of 1/4 period (90 degrees)
is generated for each channel.
Generated file example:
7. Generating/Sampling Operation
- When selecting the command [7
: Generating/Sampling Start], data output from the device will start.
Data sampling is also performed at the same timing
as the generating clock.
When the generating starts, the CUI menu will be
displayed again.
- When selecting the command [8
: Get Status], the generating count and the sampling count will be displayed.
- When selecting the command [9
: Generating/Sampling Stop], the generating operation and sampling operation
will stop.
When the generating has stopped, an Event that
device operation end occurs.
When the event occurs, the sampling data are saved
in "sampling_data.csv".
8. Exit
- When selecting the command [10
: AioExit], it will notify the device driver that the use of the current
device is complete.
Data can be acquired from different devices (e.g.
AIO001, etc.) without terminating the program.
When AioExit is executed, the CUI menu will be
displayed again.
- To perform data acquisition processing again, select the command [1 : AioInit] and specify a new device name to perform device initialization processing.
9. Processing to terminate the program
- When selecting the command [q : Quit], the program will terminate.