LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Data Acquisition

Hi,

 

I am using a stepper motor (Nema 23) along with a stepper motor drive. Additionally, I am acquiring an analog input signal from a sensor. I am using cDAQ NI 9178 and LabVIEW 2022 Q3 on a Windows platform. The stepper motor rotation changes the condition of the sensor and thus its signal is dependent on the motor orientation.  

 

I want to run the VI in two modes:

 

1) initially, both the stepper motor and the analog input loops run and allow for manual operation (like changing the motor position, saving data to a file, etc.). Once the setup is ready and the stepper motor has been set to zero degrees, enter into mode 2) whereby pressing a Boolean switch makes the stepper motor rotate by -30deg and hold its position for 10 seconds (-30deg is the first state). At the end of this interval, the analog input that is being read simultaneously at a preset sampling rate is stored in a text file. Once the data is stored for 5 seconds, the motor then rotates by +5deg, holds its position for 10 seconds, and then stores the analog input data (again for 5 seconds) to a different text file numbered sequentially. And so on... 

 

I have attached the VI for the first mode, but I have limited knowledge about how to approach the second (automated) mode. 

 

Any help is much appreciated.

 

lza

0 Kudos
Message 1 of 3
(398 Views)

Hi Iza,

 


@laz_2331 wrote:

Any help is much appreciated.


I guess you want to implement a state machine with several predefined states and some conditions to go from one state to another!?

 

Right now you only have two loops running in parallel…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(351 Views)

I have attached an updated version of the VI.

 

The stepper motor part of the code is handled in two modes: either the user inputs the required rotation angle (manual mode), or the code starts rotating the motor sequentially (auto mode) to pre-defined values in an array. The analog input signal is read continuously. The data, though, is saved in either the manual mode (where the user enters the file path, file number, etc., and then starts/stops the extraction) or the auto mode where the code saves the acquired signal following certain pause periods. 

 

When I run the program and hit the auto mode, it enters into its auto mode of operation correctly. The motor rotates, and the data is saved to a file as expected. However, if I hit Stop now (while the auto mode is enabled), the program returns the following error: "Warning 200010 occurred at DAQmx Stop Task.vi". This error does not appear if I hit the stop after the auto sequence is complete. For the sake of safety, I want to be able to stop the code immediately (or as soon as practically possible). How do I modify the attached code to achieve this?

 

Also, the waveform on the front panel stops updating, once inside the auto mode. 

 

Thanks,

lza

 

 

 

0 Kudos
Message 3 of 3
(279 Views)