LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

output a wave in U8 using NiDAQ USB 6009

Solved!
Go to solution

Hey 

guys im trying to output a sine or a square wave in U8 format using NI Daq USB 6009 , i am getting some kind of an output but i dont know whether its right or not.please help me verify, of if am doing some kind of a blunder than plz correct me im pretty new to labviw.

I am Resample waveform.vi to vary dt according to my requirement also.but th value which outputs doesnt match with the value/s entering the loop, 

0 Kudos
Message 1 of 26
(3,585 Views)

The USB-6009 has software timed digital outputs. That means that the timing in the wavefrom is ignored.

 

Inside your for loop you have Digital Write, 1 Channel, 1 Sample, U8. You are wiring to it a waveform. Notice the coercion dot at the data input. That coercion probably means  that the first element in the Y array of the waveform is selected and coerced into the U8 data type. The loop then writes that same value 5 times at ~ 50 ms intervals.

 

You need to do at least two things to get close to what you want.

1. Extract the Y array from the waveform. Convert it to an array of U8. (Make sure you avoid numeric overflow on the datatype). Wire the  U8 array to the Digital Write via an autoindexing tunnel.

2. To change your effective dt chnage the Loop Time (ms) constant. Note that the speed limit on the USB-6009 is such that times less than 10-15 ms my be unreliable.

 

Also it is better to Create the channel and Stop and Clear the task outside the for loop rather than repeating that on every iteration

 

Lynn

Message 2 of 26
(3,564 Views)

@johnsold wrote:

The USB-6009 has software timed digital outputs. That means that the timing in the wavefrom is ignored.

 

Inside your for loop you have Digital Write, 1 Channel, 1 Sample, U8. You are wiring to it a waveform. Notice the coercion dot at the data input. That coercion probably means  that the first element in the Y array of the waveform is selected and coerced into the U8 data type. The loop then writes that same value 5 times at ~ 50 ms intervals.

 

You need to do at least two things to get close to what you want.

1. Extract the Y array from the waveform. Convert it to an array of U8. (Make sure you avoid numeric overflow on the datatype). Wire the  U8 array to the Digital Write via an autoindexing tunnel.

2. To change your effective dt chnage the Loop Time (ms) constant. Note that the speed limit on the USB-6009 is such that times less than 10-15 ms my be unreliable.

 

Also it is better to Create the channel and Stop and Clear the task outside the for loop rather than repeating that on every iteration

 

Lynn


hey lynn 

thanks for replying. since im very new to lab view, it would be a great help if you kindly clear the following confusion. 

 

1. so what if i use 1 channel N sample option what would that change?

2. secondly how do i extract the Y array from waveform would i do it by using index array pallet in the proggramming section (screen shot attached).

3. do i change the data type using pallets in conversion section.

4. isnt the tunnel in a for loop is auto inxing by default hence the option "disable indexing" is turned off when u right click on the tunnel.

5. how many times should i run the foor loop because i dont know the size of my array .

 

thankyou very much for your help. 

 

 

0 Kudos
Message 3 of 26
(3,536 Views)

I'm not lynn but I'll give it a try.

 

1. Not really a lot should change, except that you will have to do less iterations of your loop to read/write the same number of sample as you can do multiple samples per read/write.

 

2. To extract the waveform in the Pallet there is a function called "Get waveform component" place this and wire a waveform into then drag the box or click the names to change what is extracted.

 

3. Data-type change between numbers is done using the conversions in the Numeric Pallet. Should be as simple as wire in a scalar or array and get a scalar or array out. But if the number is outside of the maximum range of the new datatype you may get some overflow. Be aware of this possibility, although it shouldn't be a problem if you know the data values going in.

 

4.Autoindexing should be enabled by default but just pay attention and be aware of what it is.

 

5. You should run the loop until some condition met, either you have reached the end of your array, or there is no new data coming in. Autoindexing in a For loop should solve this probem automatically as a For loop will sstop at the end of the shortest array or if it reaches its N value.

Message 4 of 26
(3,516 Views)

hahahaah everybdy is welcome Smiley Happy

0 Kudos
Message 5 of 26
(3,512 Views)

and thankyou very much  i would gv it a try and post back asap, ps can you recommend me a book or some learning source for labview .

0 Kudos
Message 6 of 26
(3,508 Views)

@luminite wrote:

and thankyou very much  i would gv it a try and post back asap, ps can you recommend me a book or some learning source for labview .


I know of some online tutorials...

LabVIEW Basics
LabVIEW 101


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 26
(3,482 Views)

1. I think the 1 Channel, N Sample option will not work with the USB-6009 because it uses software timed digital I/O. 

2. 4. 5. These were nicely answered by ogk.nz.

3. The conversions in the Numeric palette may not be suitable. The signal you are generating is a square wave with amplitude 4, offset 4, frequency 50 Hz, and sample rate 100 Hz.  Technically that violates the Nyquist criterion, but the Simulate Signal VI does not throw an  error. The result is alternating points of value 0 and 8. The resampled signal is a real mess and does not look at all like a square wave, again due to violations of the Nyquist criterion.  The minimum value (0.01) on the dt knob is larger than the required sampling period for a 50 Hz signal.

 

If you want to use the full 0-255 range of the U8 data type, you would need to multiply your 0-8 signal by slightly less than 64 before converting to U8.

 

Lynn

0 Kudos
Message 8 of 26
(3,467 Views)

hey guys

so i did some alterations i have attached the updated .vi , but i am still not sure if ive got it right or not , i cant really interpret the result, can you please take a look at it and as u said i have changed dt to 0.01 because in the timing section (simulate rignal -> right click -> properties) its 100 samples /s

1.is whole array outputting now?

and thankyou very much u people have been a great help to me .

 

0 Kudos
Message 9 of 26
(3,440 Views)

Let's go back to some basics of sampled data systems.

 

1. Nyquist criterion: The sampling rate must be > 2* the highest frequency in the signal. This applies to the original signal simulation. It applies to the resampling. It applies to the DIgital output of the USB-6009. Since you have the Loop Time in the DAQ Write loop set to 100 ms, this means that no signal greater than or equal to 5 Hz can be reproduced at the output.

 

2. Nyquist Criterion: The information in 1 means that resampling at dt < 100 ms is meaningless. All values of the dt knob are less than 100 ms and are thus meaningless.

 

3. A time delay of 50 ms in the while loop is irrelevant considering the 100 ms Wait in the for loop.

 

4. The values coming out of the conversion to U8 are 0, 1, or 2. Placing a graph to look at the data points shows that what you get does not look very sinusoidal.

 

What are you really trying to do? If you tell us more about your objectives, perhaps someone can suggest a better approach.

 

Lynn

0 Kudos
Message 10 of 26
(3,427 Views)