This is a sample that performs finite sampling with attached data in user buffer mode.
This sample program requires selecting a device with analog input function.
Sample specification |
※This is the initial value of the sample program. |
Program name |
AiSamplingAttachedData |
Conversion data transfer mode |
1 (User buffer mode) |
Start condition |
0 (Software) |
Clock type |
0 (Internal clock) |
Stop condition |
0 (Specified times) |
Memory type |
0 (Not overwrite the memory) |
Event |
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 Set
・When selecting the command [3
: AioSetAiRangeAll], you can specify the range.
When specifying the range, AioSetAiRangeAll will
be executed and the CUI menu will be displayed again.
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 selecting the command [4
: AioSetAiInputMethod], you can specify the input method.
When specifying the input method, AioSetAiInputMethod
will be executed and the CUI menu will be displayed again.
4. Sampling Set
・When selecting the command [5
: AioSetAiChannels], you can specify the number of channels.
When specifying the number of channels, AioSetAiChannels
will be executed and the CUI menu will be displayed again.
The starting channel
number is fixed at 0ch. For example, if 3 channels are specified, data
will be acquired from 0ch to 2ch.
・When selecting the command [6
: AioSetAiSamplingClock], you can specify the sampling clock period.
Enter the desired sampling clock period in units
of [usec].
When specifying the sampling clock period, AioSetAiSamplingClock
will be executed and the CUI menu will be displayed again.
The minimum sampling
clock period that can be specified depends on the device used.
You should also consider the number of channels
value you specified.
For details, please refer to the item of [Glossary] sampling clock period error.
・When selecting the command [7
: AioSetAiScanClock], you can specify the conversion speed.
Enter the desired conversion speed in units of
[usec].
When specifying the conversion speed, AioSetAiScanClock
will be executed and the CUI menu will be displayed again.
The minimum conversion
speed that can be specified depends on the device used.
・When selecting the command [8
: AioSetAiStopTimes], you can specify the stop times.
Enter the desired sampling times.
When specifying the stop times, AioSetAiStopTimes
will be executed and the CUI menu will be displayed again.
If acquisition of
multiple channels is specified in the Number of Channels, the number of
data specified in the Stop Times is acquired from each channel.
・When selecting the command [9
: AioSetAiAttachedData], you can specify the data you want to save as
attached data.
Specify whether to attach Attached information
of analog input, Data of analog output, Data of digital input and output,
Data of counter channel 0, and Data of counter channel 1.
when you have specified
whether or not to attach all attached data, AioSetAiAttachedData will
be executed and the CUI menu will be displayed again.
The attached data that can be specified differs
depending on the device used.
・When selecting the command [10
: Basic Settings], the conditions in the "Sample specification"
table above will be set to the device.
When the settings for the device are complete,
the CUI menu will be displayed again.
5. User Buffer Set
・When selecting the command [11
: User Buffer Size Set], you can specify the sampling times to store in
the user buffer.
Allocate a user buffer in the program memory and
notify the device driver of the buffer memory location.
When specifying the sampling times, the CUI menu
will be displayed again.
Please specify a value
greater than the stop times for the sampling times.
6. Sampling Operation
・When selecting the command [12
: Sampling Start], sampling will start.
When sampling starts, the CUI menu will be displayed
again.
・When selecting the command [13
: AioGetAiTransferCount], the value of transfer position will be displayed.
When the value of transfer position is displayed,
the CUI menu will be displayed again.
・When selecting the command [14
: AioGetAiStatus], the status will be displayed.
When the status is displayed, the CUI menu will
be displayed again.
・When selecting the command [15
: Sampling Stop], the data sampling will stop.
When the data sampling has stopped, the CUI menu
will be displayed again.
・When data acquisition is completed
up to the specified Stop Times, or when sampling stops, Event that device
operation end occurs.
In the event processing, all converted data in
FIFO are acquired and saved to the text file "SamplingData.csv",
and the following message is displayed.
7. Exit
・When selecting the command [16
: 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.
8. Processing to terminate the program
・When selecting the command [q : Quit], the program will terminate.