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 window that looks like the one above will appear.
Appearance may vary depending on software version.
2. Initialize
・Specify the device name set in the device manager as the device name, and click the [AioInit] button.
Notifies the device driver to start using the specified device.
3. Analog Input Set
・Select the desired input range in [Range:] and press the [AioSetAiRangeAll] button.
Depending on the device used, the setting may not be effective unless the input range is changed with the jumper pin on the device.
・Select the desired input method in [Input Method:] and press the [AioSetAiInputMethod] button.
4. Sampling Set
・Enter the desired number of channels in [Number of Channels:] and press the [AioSetAiChannels] button.
The starting channel number is fixed at 0ch. For example, if 3 channels are specified, data will be acquired from 0ch to 2ch.
・In [Sampling Clock Period:], enter the desired sampling clock period in units of [μsec] and press the [AioSetAiSamplingClock] button.
The minimum value of the sampling clock period that can be specified depends on the device used.
You should also consider the number of channels you specified. For details, please refer to the item of [Glossary] sampling clock period error.
・In [Conversion Speed:], enter the desired conversion speed in units of [μsec] and press the [AioSetAiScanClock] button.
The minimum conversion speed that can be specified depends on the device used.
・Enter the desired number of samples in [Stops Times:] and press the [AioSetAiStopTimes] button.
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.
・In [Attached Data:], check the checkbox of the data you want to save together, and press the [AioSetAiAttachedData] button.
・When you press the [Basic Settings] button, the conditions in the "Sample specifications" table above are set to the device.
5. User Buffer Set
・Specify a value greater than the Stop Times for [Sampling Times:] and click the [User Buffer Size Set] button.
Allocate a user buffer in the program memory and notify the device driver of the buffer memory location.
6. Sampling Operation
・Press the [Sampling Start] button to start sampling.
・Press the [AioGetAiTransferCount] button to update the displayed value of [Transfer Position:].
・Press the [AioGetAiStatus] button to update the displayed value of [Status:].
・Data sampling stops when the [Sampling Stop] button is pressed.
・A device operation end event occurs when data acquisition is completed up to the specified Stop Times or when sampling stops.
In event handling, display the user buffer value in the [Sampling Data:] text box.
・By pressing the [Output Acquired Data to File...] button, the data displayed in the text box can be saved in a text file.
7. Exit
・Press the [AioExit] button to 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.
To perform data acquisition processing again, specify a new device name and press the [AioInit] button to perform device initialization processing.
8. Processing to terminate the program
・Press the [Close] button in the window to terminate the program.