Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Eliminate repeated samples to one sample/second

I wrote a program to control an actuator and collect data from the
actuator, torque sensor, and pressure transducer. My first program asks the
user to input the number of cycles for the actuator and the time duration
for each cycle. This same value is used for all three actuators. My second
program asks for the same information from the user but for each actuator.
The program is designed so that each actuator has its own while loop and
will stop after completing the number of cycles. The program is designed to
operate just like the first other than that difference. The main
differences in the programming were seperate while loops for each actuator and local variables.

However, the second program is outputting about 145 samples per second
instead of 1 sample per second. Each of the samples during that seconds are
repeated values. I need to only have 1 sample per second. Any suggestions?

0 Kudos
Message 1 of 10
(4,139 Views)

Hi Lauren,

 

I tracked down your forum post and wanted to give you a few more steps to get the thread going.  One thing I would recommend would be to have a DAQ assistant for each actuator as well.  You currently have a loop that acquires all of the data and sends it through a local variable.  The difficulty encounter with local variables is that you cannot trace the data flow.  If you were to have a write to spreadsheet for each actuator and current output and a DAQ assistant for each actuator within the while loops, this could eliminate some of the need for the local variables.  Basically you would be better sreved to modularize each sub system into one while loop.

 

Also, as I mentioned i nthe email, you could trace the updates you made to the VI one by one to see when the data increases from 1 sample to 145 samples per second.  Finally, you are recording in your DAQ assistants continuously at 1 kHz and 1000 samples per channel.  You then convert this from dynamic data to a 1-D array of single values and then index the array.  It would be more efficient to just acquire a single point at 1Hz.

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 2 of 10
(4,099 Views)

Adam,

 

I've tried using a DAQ assistant for each actuator before but I get the following error:

 

Error -200279 occurred at 3 Actuators - Different Timing.vi:Instance:6:1

 

Possible reason(s):

Attempted to read samples that are no longer available. The requested sample was previously available, but has since been overwritten.

 

Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem.

 

Property: RelativeTo

Corresponding Value: Current Read Position

Property: Offset

Corresponding Value: 0

 

 

Also, my sample rates were the same between the two programs and the first program worked fine. The only DAQ assistant that has 1 kHz is for the pressure and torque using the NI 9237 module. If I try to change it to 1 Hz, I get the following error:

 

Error -50103 occurred at DAQmx Start Task.vi:19

 

Possible reason(s):

NI Platform Services:  The specified resource is reserved. The operation could not be completed as specified.

 

Lauren

 

0 Kudos
Message 3 of 10
(4,083 Views)

Hi Lauren,

 

Here is a KnowledgeBase article that discuss error 200279.  I imagine this is coming from trying the DAQ assistant that is continuously reading.  Also, I forgot that you are most likely usign the same DAQ device for all of your actuators, which is why you get error 50103.  You are trying to create a task on the same device, when only one task is allowed per device.  However, you can have one analog output and one analog input task for multifunction cards.

 

Furthermore, which measurement files have 145 samples per second?  Is it just one file or all of the files?

 

Finally, here is a recommendation.  Eliminate the local variables for your Torque 1, 2, and 3.  Also, then move your write to measruement file express VIs into the same loop.  I have attached an image that shows this on the block diagram.

 

Best,

 

Adam
Academic Product Manager
National Intruments
Download All
0 Kudos
Message 4 of 10
(4,052 Views)

Hi Adam,

 

Yes, I am using the same device to operate all three. I am using NI 9237 (for torque and pressure), 9203 (current input from actuators), 9265 (current output for actuators) and 9435 (read limit switches from actuators). Since each module needs to operate three actuators, I put the DAQ assistand in a seperate while loop and used local variables.

 

I want to keep the torque with its respective actuator which is why it is the same while loop. I need the torque to stop/start collecting data with the actuator so I need to keep the local variables.

 

All of the current/position files are reading about 145 S/s. The torque files are reading around 80-90 S/s. When the program is running you can also see that the graphs are moving a lot faster than they should be. The pressure is at 1.68 S/s like it should be.

 

Lauren

0 Kudos
Message 5 of 10
(4,010 Views)

Hi Lauren,

 

Please try the suggestion that I posted above.  If you investigate the setup you currently have, you will notice that you have the write to measurement file express VI within the other loop for no reason at all.  It is merely taking the value from the other loop via a local variable for the torque.  Obviously, the Actuator/Torque loops are running faster than the Pressure and Torque loops.  If you notice that you even mentioned that the Pressure data is logging correctly at around 1.6 Hz, you should also notice that if you were to log the data for the torque variables it would be at the same rate.  However, you have taken that logging out and placed it into the Actuator/Torque loops which are running faster, and log the same signal over and over.  This is because the local variable is not updated until the Pressure and Torque loop acquires data again.  Again, please give the previous suggestion of moving the data logging into the Pressure and Torque loop for the Torque Sensors a try to see if it helps.

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 6 of 10
(3,977 Views)

Hi Adam,

 

Moving the torque to the pressure/torque loop would fix the problem. That is how my other program is set up. However, every torque sensor is set up with an actuator. I want the two to run together and stop together which is why I had the torque in the same loop as the actuator.

 

Also, if I move the torque, there is still the issue with the current files collecting repeated values. I understand it has to do with the fact that I'm passing values between loops. Is there no way to eliminate the extra samples without eliminating the local variables?

 

Lauren

0 Kudos
Message 7 of 10
(3,954 Views)

Hi Lauren,

 

You could possibly use a case structure with a local variable with a boolean.  You would then place the wrtie to measurement to file within the case structure, and only write to file when the boolean is true.

 

Also, you could move the logging to the acquistion loop and pass a local varaible if an actuator loop is stopped nad then not log data in the acquisition loop using a case structure as well.  This is probably the best option.  It would get rid of the data variables but still require local variables to declare when the loop is stopped. 

 

Finally, just log the data for the current input when the data is acquired, as mentioned for the actuator loops.  And you could pass the data to this loop so that it is logged at a slower rate as you desire.

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 8 of 10
(3,934 Views)

Hi Adam,

 

I wanted to try your first suggestion before moving onto the next one. I moved all the torque files and graphs back into the Pressure and Torque loop. I'm probably not doing the case structure correclty. What should I do for the true case?

 

Lauren

0 Kudos
Message 9 of 10
(3,931 Views)

Hi Lauren,

 

Here are screens shots for the recommendation, for the true and false cases.  Basically, you just do not log any data in the true case becsue the true case indicates that your other loop is stopped.

 

Best,

Adam
Academic Product Manager
National Intruments
Download All
0 Kudos
Message 10 of 10
(3,898 Views)