To download NI software, including the products shown below, visit ni.com/downloads.
This Python script allows users to acquire and plot vibration data from a C Series Sound and Vibration Input Module, in addition to using digital edge triggering. The script utilizes NI-DAQmx, NumPy, and Matplotlib.
The code begins by instantiating constants such as the sample rate, the samples to acquire, the sampling mode, and the channel and trigger names. The DAQ task is created within a “with” block, as it provides a cleaner, more readable code, in addition to ensuring a proper use of memory resources. Within the task, a channel for the accelerometer is created, the timing of that task is configured, and the trigger is configured. Data is acquired through the “task.read” function in a for loop. Time data is generated using the NumPy linspace function, and both datasets are plotted using Pyplot functions. Overall, this program flow follows the same programming flow that you typically see in NI drivers: open, configure, read or write, and close.
If necessary, this script can be modified to accept different measurement and triggering types, longer or unlimited acquisition time, and more. For more information, read the API documentation in the link provided below.
Description-Separate-2
To utilize the script:
How-Separate-2
This script was built in the Jupyter Notebook environment with a Python 3 kernel.
Additional-Separate-2
Related-Separate-2
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.