This is a sample that perform sampling in synchronization with a counter comparison match within a single device.
This sample program requires selection of a device with counter input function and analog input function.
Please refer to Example 3 for Using Event Controller for synchronous operation.
Sample specification |
※This is the initial value of the sample program. |
Program name |
InternalSyncCounterSampling |
Conversion data transfer mode |
0 (Device buffer mode) |
Start condition |
10 (Event controller output) |
Clock type |
0 (Internal clock) |
Stop condition |
0 (Stop conversion by the specified times) |
Memory type |
0 (FIFO) |
Buffer size for saving data |
1MByte |
Event |
Master: Comparison count match event, Counter operation 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. Counter/Analog Input Set
・When selecting the command [3
: Counter/Analog Input Set], you can specify the counter channel No. and
comparison count value for Counter(Master).
・When you have specified the Counter(Master),
you can specify the range and the input method for Sampling(Slave).
Depending on the device used, the setting may not
be effective unless the input/output range is changed with the jumper
pin on the device.
・When you have specified the Sampling(Slave).
all counter/analog input settings will be notified to the device driver.
When the notification to the device driver is complete,
the CUI menu will be displayed again.
4. Sampling Set
・When selecting the command [4
: Sampling Set], you can specify the number of channels, the sampling
clock period and the stop times for 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.
・The sampling clock period for
Sampling(Slave) is specified in units of [usec].
The minimum internal clock 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.
・For the stop times for Sampling(Slave),
specify the desired number of acquired data.
When specifying the number of channels for Sampling(Slave),
all sampling settings will be notified to the device driver.
・When the sampling settings are complete, the CUI menu will be displayed again.
5. Sync Action Set
・When selecting the command [5
: Sync Action 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. Sampling Operation
・When selecting the command [6
: Sampling Start], it will be in the standby state of the start condition
[Comparison count match].
No sampling of the analog input takes place immediately.
7. Counter Operation
・When selecting the command [7
: Counter Start], the counter operation will start.
・When selecting the command [8
: AioPresetCnt], the count value will be preset to the specified preset
value.
8. Get Status
・When selecting the command [9
: Get Status], the count value, and the sampling count will be displayed.
・When the count value becomes the same as the comparison count value specified in the Counter(Master), the [Comparison count match] state occurs and analog input sampling starts.
・When selecting the command [10
: Sampling Stop], the analog input sampling will stop.
When the analog input sampling has stopped, an
Event that device operation end occurs.
When the event occurs, the sampling data are saved
in "SamplingData.csv".
・When selecting the command [11
: Counter Stop], the counter operation will stop. To start the counter
operation again, select the command [7 : Start counter].
9. Exit
・When selecting the command [12
: 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.
10. Processing to terminate the program
・When selecting the command [q : Quit], the program will terminate.