Infinite Sampling Using User Buffer


Appearance

 

Overview

This is a sample that performs sampling with a stop condition other than the Stop conversion by the specified times in user buffer mode.

Sampling data is added to the file that saves the data at Event that the specified number of data are transferred.

Sampling will stop if the user buffer is overwritten when collecting acquired data.

This sample program requires selecting a device with an analog input function.

Sample specification

※This is the initial value of the sample program.
Please note that it is different from the initial value of the driver.

Program name

AiSamplingInfiniteUser

Conversion data transfer mode

1 (User buffer mode)

Memory type

1 (Overwrite the memory)

Event

Event that AD conversion start, Event that device operation end, Event that the specified number of data are transferred, Event that overflow, Event that sampling clock period error, Event that AD conversion error

 

Step to Use

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.
    

  ・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.
    

 

4. Sampling condition setting

  ・When selecting the command [6 : Condition Set], the Condition Set menu will be displayed.
    

  ・When selecting [1: Start Condition] from the Condition Set menu, the Start Condition menu will be displayed.
    Select the desired start condition from the Start Condition menu.
    When the desired start condition is specified, the Condition Set menu will be displayed again.
    

  ・When selecting [2 : Sampling Clock Condition] from the Condition Set menu, the Sampling Clock Type menu will be displayed.
    Select the desired clock type from the Sampling Clock Type menu.
    

    If the Internal clock is selected, enter the sampling clock period in units of [usec]. The minimum sampling clock period that can be specified depends on the device used.
    If the External clock is selected, data will be obtained at the cycle of the external clock connected to the device.

    You should also consider the number of channels you specified. For details, please refer to the item of [Glossary] Sampling clock error.

    When the desired sampling clock is specified, the Condition Set menu will be displayed again.

  ・When selecting [3: Conversion Speed Condition] from the Condition Set menu, you can specify the conversion speed.
    Enter the desired conversion speed in units of [usec].
    When the desired conversion speed is specified, the Condition Set menu will be displayed again.

    The minimum value that can be specified depends on the device used.
    

  ・When selecting [4: Stop Condition] from the Condition Set menu, you can specify the desired stop condition.
    You can select from External trigger rise edge, External trigger fall edge, Level comparison, Command, and In Range/Out Range comparison.
    When the desired stop condition is selected, the Condition Set menu will be displayed again.
    

  ・When selecting [b: Back] from the Condition Set menu, you will return to the Top menu.

 

5. User Buffer Set

  ・When selecting the command [7 : 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 number of data transfers for the sampling times.
    

 

6. Event that the specified number of data are stored Set

  ・When selecting the command [8 : AioSetAiEventSamplingTimes], you can specify the sampling times.
    When entering the desired sampling times, AioSetAiEventSamplingTimes will be executed and the CUI menu will be displayed again.
    

 

7. Sampling Operation

  ・When selecting the command [9 : Sampling Start], sampling will start.
    When sampling starts, the CUI menu will be displayed again.

    An event occurs when the sampling data for the number of Data Transfer Times in the "Event that the specified number of data are transferred Set" is stored.
    Data in the user buffer is stored as a file on the storage medium.

    Every time an event occurs, the [Transfer Position], [Overwrite Count] and [Status] will be displayed and updated on the bottom line of the screen.
    

  ・When selecting the command [10 : AioGetAiTransferCount], the transfer position will be displayed.
    When the transfer position is displayed, the CUI menu will be displayed again.

  ・When selecting the command [11 : AioGetAiTransferLap], the overwrite count will be displayed.
    When the overwrite count is displayed, the CUI menu will be displayed again.

  ・When selecting the command [12 : AioGetAiStatus], the status will be displayed.
    When the status is displayed, the CUI menu will be displayed again.
    

  ・When selecting the command [13 : Sampling Stop], the data sampling will stop.
    When the data sampling has stopped, the CUI menu will be displayed again.

 

8. Exit

  ・When selecting the command [14 : 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.