LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving data from two while loops

I am running a motor using PWM signals and recording its rpm and angular position using a quadrature encoder. The motor needs to run continuously once the program is run, and the user should be able to alter its speed. This part of the program uses a while loop and works fine.

 

Additionally, I want to run an AI task on demand and save the signal data. Here, I also want to save the rpm and angle simultaneously read in the other While loop (the two data sets need to be synchronized). I have used local variables, and a sample output for 3 seconds is attached as output.txt. In the 'output' file, the first column represents rpm, the next one is angular position, and the last column is for the AI signal. The first 10 rows for rpm and angle are filled, but then the next 1000 are returned as 0. This pattern seems to repeat itself.

 

Is this because of an incorrect way of calling data from the other While loop, or does it have something to do with the sampling frequency/number of samples of each task? How can I modify the VI to save the data synchronously?

 

The on-demand AI task is part of a bigger VI where it needs to be separated from the other while loop (that calculates the rpm).

 

I am using the following hardware: 

 

NI cDAQ 9178

NI 9202 AI module

NI 9401 DIO module

NI 9361 CI module

 

Thanks,

lza

0 Kudos
Message 1 of 3
(146 Views)

You should Synchronous Analog and Encoder Inputs

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 3
(101 Views)
A txt file is probably not ideal for you. Look into using a TDMS File instead. There are some very good shipping examples to help you understand the TDMS format.

"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 3
(36 Views)