The AInScBg function writes data to a circular buffer, and the attached example handles the transfer of data out of this circular buffer. The example then logs analog input scan data continuously to a Waveform chart and text file.
The GetStatus VI outputs an array which is the circular buffer into which data is written by AInScBg. It also returns the value CurIndex, which is the index into the buffer of the last completed channel scan. The algorithm used to transfer data from the circular buffer is as follows:
- When the buffer passes the half full point, the data is transferred from the first half of the buffer to an array.
- When the buffer is full and CurIndex cycles round to zero again, the data is transferred from the second half of the buffer to an array.
You can adjust the sample rate to match your application. The count per channel should be adjusted when the sample rate is adjusted. The range of the graph is proportional to the count per channel, and the refresh rate of the graph is inversely proportional to the count per channel. The count per channel must be a multiple of the packet size of the hardware, which can be found in the Universal Library online reference. For example the packet size of the PMD-1208FS\PMD-1608FS is 31 and the packet size of the PMD-1208LS\minilab 1008 is 64.
As a guide, the count per channel should be approximately equal to the sample rate.
Run the example using the LabVIEW single run button.
Don't stop the example using the LabVIEW "Abort Execution" button! If you do, the process will not terminate properly, because StopBackground has not been activated. On the next run, you will just get an error message "Background operation already in process." If the process does not terminate properly, you will need to reboot the computer. So, use the Stop button on the Front Panel instead.
The attached example was created using LabVIEW 7.0. If you require an example that can be opened by an earlier version of LabVIEW, or require further advice or information, please contact technical support.
This example was produced by technical support and is supplied for guidance only. It shows only one way of achieving this functionality and may not be suitable for certain applications.
Because of the way this example is written, if you are using a faster sample rate then you must increase the "Count per Channel" accordingly to prevent buffer overruns. This example can also be used with other types of board, if the count per channel is adjusted to be an integer multiple of packet size.