LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to reduce the time of a loop

Hello,

 

I have a VI how generate and acquire signals via a NI-USB device.

 

I have lighted a bit my VI because the rest of the calculation doesn't increase the time spend in the loop.  (I acquire 8 signals and i do 2 PID in the real VI)

 

So, the VI is made for read two hall sensor of a motor and tell me in wich position is the motor (Motor is a stepper with 20step per 360°). But I think that my VI only count from 0 to 19 ..

 

I have tried to decrease the values of both DAQ but then the sine wave doesn't look like sine.. The loop run at 200ms/iteration

 

If anyone know how to run it faster it would be great 🙂

 

thanks

 

Max

0 Kudos
Message 1 of 12
(3,139 Views)

All those express vi's need to go away to improve the performance.

 

Example: Replace the simulate signals with "Sine waveform .vi"

 

Now lets really look at that code:  for every loop iteration you are creating two waveforms and writing them to the DAQ AO buffers.  Why?   use events to build the waveforms ONLY when one of the controls change.  that gets a lot of wasted computations out of your loop since the control values change infrequently compared to the loop iteration time.

 

Especially look at the Producer Consumer Events and use a notifier to feed the DAQ AO

 

Next those DAQ express vis really do have a lot of call overhead compared to programming with the DAQmx API.  the shipping examples should point you in a better direction.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 12
(3,126 Views)

Hi Jeff,

 

In fact, the buffer size of these two DAQ slow down the speed of the loop. I have a rate at 1MHz and 200kS, if I reduce them i lose in precision.

 

I haven't many knowledge with the DAQmx but I will try. 😉

 

 

0 Kudos
Message 3 of 12
(3,112 Views)

Oh, eventually we'll get into processing the data outside the loop acquiring it.  But I don't want to overload you yet.  We might even hang this project on the Continuous Measurement and logging sample project template's framework before you get all the performance you want.  

 

A single "do everything" loop is not going to cut it for tight PID control.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 12
(3,104 Views)

I'm not sure I have understand what you said.

 

You think that I can store the data somewhere and after the loop is completed process them ?

 

I upload all my work , the main is the "LabVIEW_final.vi" . Maybe it's easier for explain.

 

In my mind I see the system like a succession of loop for divers measures, stroring them ant after that process with some Mathscript. And at first that wasn't so bad.

 

But now I need to know the position and the speed of my motor is higher than my loop..

 

 

-->  My_VI

0 Kudos
Message 5 of 12
(3,092 Views)

Please just post it to the forum.  Don't link to outside files.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 12
(3,072 Views)

And use a zip file.  Many people can't open RARs.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 12
(3,067 Views)

Sorry for the external link.

 

here is my vi :

0 Kudos
Message 8 of 12
(3,061 Views)

Hello MaxLab,

 

my name is Dominik and i want to know what explicit question you have on your program that i can try to help you fast and confident. I think the easiest way is that we start with a single question where you cannot go on with your programming and than we will see the other things. Please tell me where you exactly have a problem and what you think about it. 

 

Have a nice day

Kind regards

Dominik

0 Kudos
Message 9 of 12
(2,973 Views)

Hello Dominik,

 

I think that my problem is the buffer sizes of my DAQ assistant.. if I set 200kS I got 200ms for an iteration - if I set 100kS I got 100ms for an iteration.

 

But, for a good taste of my measure, I need theses 200kS.

 

Thanks you for your answer

0 Kudos
Message 10 of 12
(2,949 Views)