LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal generation

I am trying to generate an abitrary  2 Ms square wave signal at a 2 Hz frequency but I am getting an extra pulse . i.e. Instead of two pulses a second I am getting 3. I do not have any time delays in the programme so does anyone know why this could be?

0 Kudos
Message 1 of 8
(4,057 Views)

Please post a snippet of a VI how you are generating it and what hardware. And a few notes how you are measuring it. Delays in program will lead to reduced rate (more than 500 ms between pulses), not increased. So the problem is with configuration.

0 Kudos
Message 2 of 8
(4,042 Views)

I am generating the signal using a USB-6001 (14bit , 5 kS/s)  in a continous generation mode at a rate of 1 K Hz.

I am reading the signal at a rate of 2 K (Hz) .

 

0 Kudos
Message 3 of 8
(4,028 Views)

Would it be so difficult to attach your vi, instead of a picture of your VI?  It would help us to help you.

 

Bob Schor

0 Kudos
Message 4 of 8
(3,998 Views)

Hi Bob,

I have attached the actual vi. I am measuring a lot of other things in this programme . But the only concern is the time delay that I am getting. Secondly, the recorded data seems to be off by a 5 . i.e When I define a signal to repaet every 0.1s (10 Hz) , a 2 Hz signal is recorded in the written file.

0 Kudos
Message 5 of 8
(3,972 Views)

Hi Nina,

 

But the only concern is the time delay that I am getting.

Which delay do you get?

Your DAQAssistent is set to read 2000 samples at 2kS/s samplerate, so it will take a second to read all values. Then you do some excessive handling of DDT wires to finally write the results to a file…

The other reading DAQAssistent is set to read 100 samples at 100S/s samplerate, it also should take a second to execute. (Does your hardware even support this samplerate?)

 

Secondly, the recorded data seems to be off by a 5 . i.e When I define a signal to repaet every 0.1s (10 Hz) , a 2 Hz signal is recorded in the written file.

Where do you define this 10Hz signal?

Your DAQAssistent in the "smaller" loop is set to output 501 samples at 1kS/s sample rate, so it takes 501ms to output the data…

 

General advice:

- When you want your DAQmx functions to execute the way you want them you should not use the DAQAssistent. Use plain functions!

- When you want a consistent timing in your application you should consider some programming schemes like producer-consumer oder QMH…

- Both FP and BD of your VI are too big!

Best regards,
GerdW


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

Hi GerdW,

 

I understand that my FP and BD is extremmely large, however with the time constraints, my main focus is that the programme works  rather than teh efficiency of the code.

 

Your DAQAssistent is set to read 2000 samples at 2kS/s samplerate, so it will take a second to read all values. Then you do some excessive handling of DDT wires to finally write the results to a file…

The other reading DAQAssistent is set to read 100 samples at 100S/s samplerate, it also should take a second to execute. (Does your hardware even support this samplerate?) Yes my hardware can support this sample rate.

 

Where do you define this 10Hz signal?

The first delay is in the signal generation. The signal is defined in the "Simulate Arbitrary Signal 4" in the smaller while loop. The square signal is manual defined and set to different frequecnies . So taking 10 Hz as an example, the delay is a factor of 5. The signal is written (in the larger loop) as a 2 Hz signal instead. The square signal is set to hold for 2 ms however, the recorded data shows a signal holiding for 10 ms (hence this factor of 5 ) .

Is there a way to get ride of this ?

 

Your DAQAssistent in the "smaller" loop is set to output 501 samples at 1kS/s sample rate, so it takes 501ms to output the data…

I changed the DAQ Assistent in the samller loop to output 1000 samples at 1 kS/s but this doesnt resolve the delay.

 

Can you elobrate on what you mean by :  When you want your DAQmx functions to execute the way you want them you should not use the DAQAssistent. Use plain functions.

 

0 Kudos
Message 7 of 8
(3,939 Views)

Hi Nina,

 

my main focus is that the programme works  rather than teh efficiency of the code.

Having a BD/FP where you don't get lost immediatly greatly helps to prevent errors and make your program "work"…

Don't think about "efficiency of code", but think about "efficiency of programming work"!

 

The square signal is manual defined and set to different frequecnies … I changed the DAQ Assistent in the samller loop to output 1000 samples at 1 kS/s but this doesnt resolve the delay.

So you generate a waveform with variable samplerates, but you still use an output with a fixed samplerate (1kS/s). And you still wonder why your output doesn't match with expected/simulated signal? Really?

 

Can you elobrate on what you mean by

Yes, I can: Get rid of ExpressVIs!

Best regards,
GerdW


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