LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

output a wave in U8 using NiDAQ USB 6009

Solved!
Go to solution

thanks alot for replying so fast lynn 

 

ok so this is what im tryign to to 

i want to ouput a waveform e.g. sine square etc in U8 form using NI USB 6009 , and want to control the samples cominng out of the daq per second. since i was unable to vary dt directly thats why i used resample waveform.vi bcz it enables me to vary the samples / s.

 

 1.and ya i am aware of the nyquist sampling rat eand thats why my sine wave is of 5 hz and dt ranges from 0.1 i.e. 10hz to 0.01 i.e. 100hz  which is greater than or equal to 5*2=10 Hz .

2. dt < 100ms implies sampling frequency >10hz which satisfies teh nyquist criterion i.e.  The sampling rate must be > 2* the highest frequency in the signal which = 5 hz .(correct me if im wrong)

3. and yea u r ryt i put it there to slow th process down so i can observe values i think i forgot to remove it so id remove it .

4. and yea u r ight so what am i supposed to do . 

 

would be very grateful for your help .

 

 

0 Kudos
Message 11 of 26
(1,723 Views)

1. and 2. The dt in the waveform you want to send out MUST BE GREATER than 100 ms because that is the rate at which the samples are sent out of the DAQ device. Resampling with a smaller dt is useless. The controlling sampling rate is the rate at which the loop sends out samples. In your VI that is 100 ms loop period = 10 Hz sampling rate. To get anything which looks much like a sine wave you will need to send ten or more samples per cycle of the sine wave. This effectively reduces the maximum frequency of the sine wave to less than 1 Hz, probably less than 0.5 Hz.  You need to rethink the range of frequencies you are trying to use.  You cna probably go a little faster by reducing the 100 ms Loop Time Wait, but you will soon hit the limitations of software DAQ timing.

 

4. Set the maximum value for the Amplitude=Offset control to be 127.5. Then the range of values at the U8 array will 0 to 255 which is the maximum that can be represented by U8. At the lower values (like the default 1) you will get a very jagged waveform. This is inherent in sampled data systems with limited resolution.

 

Lynn

Message 12 of 26
(1,711 Views)

ooooook now i get it, so conclusion is that the loop delay is the determining factor here and i cant go below say 15ms=66.66 hz (damn its low i was thinking i could reach KHz)

so setting loop delay to 15ms means i can send out a sine wave of freq 10-15 hz with  1/dt=freq  of reample waveform.vi set at  20-30hz freq i.e dt= 0.033-0.05s right ?

 

Thanks so much for taking the pain and helping me out lynn 🙂 

0 Kudos
Message 13 of 26
(1,697 Views)

and is there a way to eliminate resample wave.vi since i can control td by varying loop time so its not really useful . i.e. how do i convert dynamic data type to waveform (DBL)

0 Kudos
Message 14 of 26
(1,694 Views)

There are conversion VIs in the Express palette.

 

EDIT:  Signal Manipulation sub palette.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 15 of 26
(1,689 Views)

ok so ive used the from ddt.vi pallet as u said and plotted the data side by side one seems to progress in time other is stationary is something wrong there ??

please see the attached vi.

0 Kudos
Message 16 of 26
(1,686 Views)

I don't think there's anything wrong.  This is one of the reasons I won't touch Express VIs or the dreaded DDT with a 10 foot pole.  I think the conversion to/from DDT throws away some timing info but don't quote me on that.  

 

The best solution is to just learn to program with the real LabVIEW VIs.  Express/DDT stuff is like swiming in the baby pool or putting training wheels on a Harley.  It may seem easier if you're just starting out but as soon as you need to go beyond them you'll have a whole new learning curve ahead of you.  Smiley Surprised

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 17 of 26
(1,676 Views)
Solution
Accepted by luminite

Once you have the U8 array you have lost all timing information from the Simulate Signal VI, so just ignore that timing. Forget the resample VI . It does nothing of value in this situation.  The Wait in the digital write loop is the only thing which affects the data sent out. 

 

When the loop delay is 15 ms, the highest frequency you can generate is 1/30 ms = 33.3 Hz. And you will only get two points per cycle. To get something which looks a little like a sinewave you need at least ten points per cycle. That means that the highest "sine" frequency would be 1/(10*15 ms) = 6.67 Hz.

 

Lynn

Message 18 of 26
(1,667 Views)

hey again

so i bypassed the resample waveform.vi but now valu comming out of the daq doest change why is it so ? please help.PFA the updated vi

thans alot for ur help

0 Kudos
Message 19 of 26
(1,635 Views)

OK. You are getting close.

 

The signal you are feeding to the DAQmx Write.vi is a waveform while it is expecting (and will only use) a single byte in U8 format. The autoindexing tunnel where the array of waveforms enters the for loop selects each waveform in the array in succession. Since there is only one waveform in the array, the for loop only iterates one time. The DAQmx Write probably selects the first value from the Y array and writes that to the output. 

 

What you need to do is to think about the data you want to send to the DAQmx Write: each of the elements of the Y array in succession. In fact you do not need an array of waveforms or even a single waveform because you are not using the timing information. Change the From DDT conversion Resulting data type to "1D arrayof scalars - automatic". Then convert that to U8 and feed the array through an autoindexing tunnel to the DAQmx Write. You will also need to change the "passing points" graph to a chart.

 

Lynn

0 Kudos
Message 20 of 26
(1,623 Views)