Python for Windows Continuous Background with Device Discovery

The following Python for Windows example demonstrates device discovery and a continuous background acquisition.

Once started, the acquisition is monitored using the get status function that returns total count and buffer index position. Data is retrieved from the device buffer when it is more than half full (index > half). When this happens, it transfers data from the device buffer to the user buffer. The acquisition loop continues to monitor the index and when it rolls over to zero, transfers data from the upper half of the device buffer. It continues to do this back-n-forth or ping-ponging between the low and upper halves.

The data is automatically scaled to volts via the ScaleData feature. This requires the use of the functions scaled_win_buf_alloc to allocate memory and scaled_win_buf_to_array to transfer the data. The ScaleOption.ScaleData informs the AInScan function that the ScaleData feature is in use. For simplicity, only one row of data is printed each time the buffer is transferred.

To install the Python for Windows support, copy the following URL into your browser and follow the instructions provided.

This example was built using Python 3.8.5 and PyCharm. The code module is provided via a download link at the end of this article.