# d_out_scan()

Writes a series of bytes or words to the digital output port on a board with a pacer clock.

## Prototype

d_out_scan(board_num, port_type, count, rate, memhandle, options)

## Parameters

board_num (int)

The number associated with the board when it was installed with InstaCal or created with create_daq_device().

port_type (DigitalPortType)

Specifies which digital I/O port to write to (usually DigitalPortType.FIRSTPORTA or DigitalPortType.FIRSTPORTB). The port must be configured for output.

count (int)

The number of times to write the digital output.

rate (int)

Number of times per second (Hz) to write to the port. The actual update rate in some cases will vary a small amount from the requested rate. The actual rate is returned.

memhandle (int)

Handle for the Windows buffer to store data. This buffer must have been previously allocated with win_buf_alloc().

options (ScanOptions)

Flags that control various options. Refer to the constants in the options parameter values section below.

## Returns

- actual_rate (int) – The actual rate set, which may be different from the requested rate because of pacer limitations.

### options parameter values

ADCCLOCK | Paces the data output operation using the ADC clock.
ADCCLOCKTRIG | Triggers a data output operation when the ADC clock starts.
BACKGROUND | If the BACKGROUND option is not used, the d_out_scan() will not return control to your program until all of the requested data has been output. When the BACKGROUND option is used, control returns immediately to the next line in your program and the transfer to the digital output port from memhandle will continue in the background. Use get_status() with DOFUNCTION to check on the status of the background operation. Use stop_background() with DOFUNCTION to terminate the background process before it has completed.
CONTINUOUS | This option puts the function in an endless loop. Once it transfers the required number of bytes, it resets to the start of the buffer and begins again. The only way to stop this operation is with stop_background() with DOFUNCTION. Normally this option should be used in combination with BACKGROUND so that your program will regain control.
DWORDXFER | Normally this function writes to a single (byte) 16-bit port. When DWORDXFER is specified, it writes to two adjacent 16-bit ports at a time as the low and high byte of a single array element in the buffer. It is usually required to set PortType to AUXPORT0.
EXTCLOCK | When this option is used, transfers are controlled by the signal on the external clock input rather than by the internal pacer clock. Each transfer will be triggered on the appropriate edge of the clock input signal; refer to board-specific information. When this option is used, the rate parameter is used for reference only. The transfer rate is dependent on the clock signal. An approximation of the external clock rate is used to determine the size of the packets to transfer from the board. Set the rate parameter to an approximate maximum value.
NONSTREAMEDIO | When this option is used, you can output non-streamed data to a specific DAC output channel. To load the data output buffer into the device's internal output FIFO, the aggregate size of the data output buffer must be ≤ the size of the internal data output FIFO in the device. Once the sample data are transferred or downloaded to the device, the device is responsible for outputting the data. You can't make any changes to the output buffer once the output begins. With NONSTREAMEDIO mode, you do not have to periodically feed output data through the program to the device for the data output to continue. However, the size of the buffer is limited.
RETRIGMODE | Re-arms the trigger after a trigger event is performed. With this mode, the scan begins when a trigger event occurs. When the scan completes, the trigger is re-armed to acquire the next the batch of data. You can specify the number of digital output samples to generate per trigger – this is the trigger count. The RETRIGMODE option can be used with the CONTINUOUS option to continue arming the trigger until stop_background() is called. You specify the trigger count with the set_config() ConfigItem option DOTRIGCOUNT. If you specify a trigger count that is either zero or greater than the value of the d_in_scan() count parameter, the trigger count is set to the value of the count parameter. Specify the CONTINUOUS option with the trigger count set to zero to fill the buffer with count samples, re-arm the trigger, and refill the buffer upon the next trigger.
WORDXFER | Normally this function writes to a single (byte) 8-bit port. When WORDXFER is specified, it writes to two adjacent 8-bit ports as the low and high byte of a single array element in the buffer. When WORDXFER is used, it is generally required to set PortType to FIRSTPORTA.

## Notes

- BYTEXFER is the default ScanOptions option. Make sure you are using an array when your data is arranged in bytes. Use the WORDXFER option for word array transfers.
- The NONSTREAMEDIO option can only be used with the number of samples (count) set equal to the size of the FIFO or less.
- Transfer Method may not be specified. DMA is used.