LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adjust sample frequency

Solved!
Go to solution

Heey everybody,

 

I am really new to LabVIEW. As in, I have never heard of it until a few months ago. Right now I need to work with this program. I have 5 input channels and 2 output channels. The output channels work fine. They both have different patterns but I have no problems there. The sampling frequency here is 100 Hz as I want it to be. But with the input the frequency is 10 Hz, where I want it to be at least 100 Hz. My device is able to measure at 100 Hz and I can't figure out why I can't get it to 100, since the output is 100 to the same device. 

I already have tried to alter the Number of samples and the Sample rate, but whenever I alter this, I get the error 200279. Or it runs but with a lower frequency. Can anyone help me? 

 

It is really appreciated!

help.png

0 Kudos
Message 1 of 15
(3,559 Views)

Hi Emmy,

 

which DAQ device do you use?

Why do you set a "number of samples" at DAQmxTiming? (Did you read the help for this function and the meaning of this input in "Continuous sampling" mode?)

What happens when the AI task runs in its own loop, independently from AO task?

Why do you attach just an image of your code, but not the code itself?

Best regards,
GerdW


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

Hi GerdW,

 

I use a Bilateral Ankle Manipulator as a device. I don't know if this is the DAQ device. 

 

I used number of samples input because this was in the example provided by LabVIEW. I did read the help but this is my first time working with this program and most of the terms mean nothing to me. It worked with the example and that's why I made it this way. 

 

With the output in a separed loop, the input is still 10 Hz.

 

And I thought I also uploaded my code but probably something went wrong so here it is again (I hope).

 

Thanks for your help already!

0 Kudos
Message 3 of 15
(3,550 Views)

Hi Emmy,

 


@EmmyJCZ wrote:

I use a Bilateral Ankle Manipulator as a device. I don't know if this is the DAQ device. 


This "manipulator" is not the DAQ device. The DAQ device is the one you are reading from/writing to with those DAQmx tasks: it should be some NI hardware…

 


@EmmyJCZ wrote:

With the output in a separed loop, the input is still 10 Hz.


You set a sample rate of 1kS/s and you read 100 samples per call of DAQmxRead: using simple math this gives (1kS/s * 1/100S 😃 10Hz loop rate!

Is this what you are talking about?

 


@EmmyJCZ wrote:

And I thought I also uploaded my code but probably something went wrong so here it is again (I hope).


When using the latest LabVIEW version you should downconvert the VI (aka Edit->Save for previous) before attaching. (I still prefer LV2017…)

Best regards,
GerdW


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

Hi GerdW,

 

I believe my DAQ device then is NI USB-6289.

 

I am really sorry but what do you mean with 1 kS/s? And I figured it was something with the numbers because that would give me 10 Hz. And I want to make that 100 Hz but changing the numbers gives errors 😞

But I don't know what those numbers do or mean...

 

I saved it as a 2017 file 🙂

 

Thanks for your help again!

0 Kudos
Message 5 of 15
(3,527 Views)

Hi Emmy,

 


@EmmyJCZ wrote:

I believe my DAQ device then is NI USB-6289.


You should know this instead of believing: open MAX, then check the available hardware…

 


@EmmyJCZ wrote:

But I don't know what those numbers do or mean...


When you don't know what these numbers mean then you should take some training first!

NI offers self-paced online courses for free until the end of June, there is also a DAQmx course! See also the "Training resources" in the header of the LabVIEW board!

 


@EmmyJCZ wrote:

I am really sorry but what do you mean with 1 kS/s? And I figured it was something with the numbers because that would give me 10 Hz. And I want to make that 100 Hz but changing the numbers gives errors 😞


"1kS/s" is "1 kiloSamples per second" - or a "samplerate of 1kHz": the numeric constant labelled "Sample Rate Input" in your VI has a value of 1000!

The DAQ device is reading samples at a rate of 1000 samples/second: how many samples do you need to read/request when the loop should iterate at 100Hz? (Again: apply simple math!)

It seems (to me) you mix the terms "sampling rate" and "loop rate": your DAQmx tasks are both set to a samplerate of 1000Hz! Which numbers do you get in the "Actual Sample Rate" indicator?

 

Why do you need that 100Hz sample rate at all? And why don't you set the sample rate to 100?

Best regards,
GerdW


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

My device indeed is the NI USB-6289. I checked it in MAX. 

 

I already did some starting courses. I did not know there was a DAQmx course. I did not find it for free and it also takes 6 months to graduate. Right now I am using LabVIEW for my university graduation in hopefully four months so I don't think this course is useful. 

 

And I don't know if I understand you correctly, but if I delete the number of samples input and change my sample rate input to 100, I should measure in 100 Hz? I have tried this, but I get 3861 datapoints instead of the 6050 I need. This seems weird.

 

In the actual sample rate indicator I get the same numbers as I put in the sample rate input. 

0 Kudos
Message 7 of 15
(3,502 Views)

Hi Emmy,

 


@EmmyJCZ wrote:

I already did some starting courses. I did not know there was a DAQmx course. I did not find it for free and it also takes 6 months to graduate. Right now I am using LabVIEW for my university graduation in hopefully four months so I don't think this course is useful. 


It is always helpful to take such courses when you have problems understanding the basics…

 


@EmmyJCZ wrote:

And I don't know if I understand you correctly, but if I delete the number of samples input and change my sample rate input to 100, I should measure in 100 Hz?

In the actual sample rate indicator I get the same numbers as I put in the sample rate input. 


Yes, it will measure with  a samplerate of 100Hz when you set so (and when it also shows this way).

 


@EmmyJCZ wrote:

I have tried this, but I get 3861 datapoints instead of the 6050 I need. This seems weird.


You measure as long as your AO task is running. How long will those waveforms play?

Also both tasks aren't sychronized: you cannot rely on both starting at the same time…

Best regards,
GerdW


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

Hi GerdW,

 

Thanks for the help with the sample frequency. I understand that part now.

 

How can I synchronize both tasks? I want the program to run a certain number of output loops plus some adjustment time. Right now I just timed this but is maybe a for loop better?

 

Thanks for your help so far!

0 Kudos
Message 9 of 15
(3,495 Views)

Hi Emmy,

 

there are also example VIs that demonstrate how to sync AI and AO DAQmx tasks…

Best regards,
GerdW


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