Fast Analog Output (FAO) Functions

The FAO (Fast Analog Output) functions achieves continuous, high-speed analog output by way of DMA transferring.

Presently, PCI-1712 and PCI-1721 support the FAO. The operation flows are similar. For more detailed information about FAO, please refer to the DMA Transferring.

Allocate buffer

In order to start the FAO, the user should initially allocate a buffer for the driver and transfer the address to the driver for later operation. The buffer size is related to the required data count (the data count for a single cyclic output, or the total data count for non-cyclic output). The buffer should be large enough to store the data of a single output. The buffer space for each data is 2 bytes, therefore the buffer size can be calculated in the formula below:

                                buffer size = output count* 2 (byte)

The following figure indicates the transfer relationship between the user buffer, the driver buffer and the FIFO.

Please refer to the table below for setting the buffer size:

Condition\Method Data Count (Unit: Sample)
Even Multiple of the number of channels Multiple of the FIFO Size >4K(recommended)
1712  
1721  

1 Initialize Buffer

In order to initiate DMA, the user needs to allocate the buffer, and prepare the data for the driver buffer. After the transfer is finished, needs to release the resources. If the data is float voltage value, then the user has to call the DRV_FAOScale to convert the voltage value into binary data. The data will then be filled in the driver buffer for output by using the DRV_FAOLoad.

2 Enable Event

If the event notification method is used, the user has to enable the event before the operation so as to avoid transfer interruption. The specified event can be enabled by calling the DRV_EnableEvent and can be checked by using the DRV_CheckEvent. The following table lists the event types supported by PCI-1712 and PCI-1721.

Event Type Description
ADS_EVT_AO_HIBUFTRANSFERED
ADS_EVT_AO_LOBUFTRANSFERED
This event will be signaled when the data in either buffer has been transferred. The user can call the DRV_FAOCheck to check which buffer's data has been transferred, and then fill different data into this buffer.
ADS_EVT_AO_TERMINATED Triggered when a non-cyclic FAO operation finishes or the DRV_FAOTerminate is called.
ADS_EVT_AO_UNDERRUN Triggered when the buffer is not filled with new data. This indicates the incontinuous transfer.

The user can also call the DRV_FAOCheck to check the current status. The event mode is recommended in order to avoid the complex programming and incontinuous transfer.

3 Transfer Data

The driver will divide the driver buffer into two equivalent parts for continuous transfer. In event mode, when a half has finished the transfer, the corresponding event will be signaled in order to fill the half with new data. If it is not in event mode, the user will have to call the DRV_FAOCheck to check the current status and fill new data.

The following figure displays the status of the driver buffer in both modes.

The navy blue part indicates the space that stores the required binary data.

(1) The buffer is used as two equal size parts: the first half and the second half. The driver transfers data from the first half.

(2) When the data in the first half is transferred, the user has to fill the half with new data by calling the DRV_FAOLoad. At the same time, the buffer is transferring data from the second half.

(3) When the data in the second half is transferred, in non-cyclic mode the DMA will be stopped, while in cyclic mode, the user has to fill the half with new data by calling the DRV_FAOLoad. At the same time, the driver begins to transfer the data in the first half, so as to achieve continuous transfer.

Please note that if the first or the second half is not filled with new data, in cyclic mode, an underrun event will occur to indicate that the transfer is incontinuous.

Please note: In multi-channel mode, the device transfers data channel by channel.

4  Stop operation

In non-cyclic mode, the function will stop automatically when all the required data has been transferred. While in cyclic mode, the DRV_FAOTerminate function must be called to stop the FAO operation.
The user can receive the terminate message in two ways: one is by the ADS_EVT_AO_TERMINATED event when it is enabled; the other is by continuously calling the DRV_FAOCheck until a stop flag is checked. The former is recommended.

FAO Related Functions

Function Purpose
DRV_EnableEvent On the device indicated by the DeviceHandle, it enables or disables a specified event by specifying the corresponding EventType. This function supports all types of events for DMA and interrupt operation. After the event is enabled, the DRV_CheckEvent can be called to check the type of signaled event.
DRV_CheckEvent On the device indicated by the DeviceHandle, it checks the specified event status and clears the event.
DRV_FAOLoad Transfers the data from the user's buffer to the FAO (Fast Analog Output) output buffer without affecting the output process. When the FAO output buffer is empty or “ready” (checked with the DRV_FAOCheck), then the data must be loaded (FAOLoad) in order to avoid buffer underrun. This function is used in PCI-1712/1721.
DRV_FAOCheck Retrieves the current status of FAO (Fast Analog Output) functions. The contents of the return status including running status (running/stopped or complete/incomplete), current output status, and buffer status. Please note that this function can't be used to detect buffer underrun. This function is used in PCI-1712/1721.
DRV_FAOTerminate On the device indicated by the DeviceHandle, it stop the running FAO (Fast Analog Output) operation by way of safely resetting the hardware, releasing resources and sending a terminate event to the user. This function is used in PCI-1712/1721.