LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I generate digital 8 bit sinewave?

Hi everyone,

 

is it possible to generate a sinewave using 8-bit digital boolean value? or maybe using digital WDT?

I'm not sure about this, since I've got message from someone that my NI device wouldn't be able to generate a sinewave.  (I'm using PXIe 6544).


But what I'm trying to achieve is, I need to send a digital sinewave into a DUT, and I want to be able to see my digital sinewave.

 

Maybe with generating some boolean arrays? I'm not sure about this, but I've managed to generate 8 bit digital ramp using my NI device. 

I thought the generation would be similar between ramp and sinewave, but they would have different sequences of values. But I couldn't find the sequence to generate sinewave.

 

I mean, to generate 8 bit ramp, I can use this sequence with the same sampling time:

00000000

00000001

00000010

00000011

00000100

.

.

.

11111111

 

 

But for sinewave, I have a feeling it shouldn't be impossible, right?

 

Regards,

Yan. 

0 Kudos
Message 1 of 17
(6,264 Views)

I would use the sine function, multiply it be 255, than round to the nearest integer.

0 Kudos
Message 2 of 17
(6,262 Views)

You would simply generate a sine function, scale it from 0..255, and convert it to U8.

 

I am not sure about your terminology. A boolean value only needs one bit. What do you mean by 8 bit boolean value? An array of 8 booleans? 8 digital outputs?

0 Kudos
Message 3 of 17
(6,259 Views)

@Ravens Fan wrote:

I would use the sine function, multiply it be 255, than round to the nearest integer.



That would give you -255..255. 😮

0 Kudos
Message 4 of 17
(6,258 Views)

hi,

 


@altenbach wrote:

You would simply generate a sine function, scale it from 0..255, and convert it to U8.

 

I am not sure about your terminology. A boolean value only needs one bit. What do you mean by 8 bit boolean value? An array of 8 booleans? 8 digital outputs?


*An array of 8 booleans?*

yes, I mean 8 booleans.


*8 digital outputs?*

no, I'm using serial generation, so I'm using 1 digital output only.

 

like I said, to generate ramp, I can simply generate the sequence:

00000000 - 00000001 - 00000010 - 00000011 ....... - 11111111

with using the same time between each ramp step.

 

But for sinewave, I think cant simply using such method (using sequence).

 

Regards,

Yan.

0 Kudos
Message 5 of 17
(6,247 Views)

Dohhh!  I forgot about the negative half.

 

In that case I'd multiply it by 127 and add 128 to the result.

 

Overall, I'd try out different things and play with it.  The numbers and offsets might need some adjustments.

0 Kudos
Message 6 of 17
(6,244 Views)

As said, use the sine wave VI out of the Signal Generation palette.  This code will give you a 2D array of booleans (8x128).


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
Message 7 of 17
(6,237 Views)

Mystogan wrote:

*An array of 8 booleans?*

yes, I mean 8 booleans.

 

...


*8 digital outputs?*

no, I'm using serial generation, so I'm using 1 digital output only.

 ...

But for sinewave, I think cant simply using such method (using sequence).



Why in the world would you bring a "Sequence" into the discussion. That has nothing to do with anything discussed here! 😄

 

Scale a sine function to the 8bit range (as described earlier), convert to U8, then use "number to boolean array" to make your boolean array. Simple as that! 😄

 

Of course since you start out with a 1D numeric array, you would use an autoindexing FOR loop to generate a 2D array of booleans, one row per value.

Message 8 of 17
(6,235 Views)

wow, I don't think it would be as simple as that. Smiley Embarassed

 

since I'm using digital values from 0~255, I think the best option to generate this is like what Ravens Fan said, multiply by 127, and add 128 to the result, right? 

 

My question now:

-in X-Axis, I'm seeing sample numbers, right? Which means for my example in attachment, I'm having 1 Hz sinewave with 1000 samples. In this case, I have then sampling frequency 1 kHz. How to change the X-axis into time instead samples?

-how to check quality of this sinewave? I mean, what about its resolution? should I use sampling frequency 1000x of sinewave frequency?

 

Thanks a lot, you guys are really great with Labview.

Regards,

Yan.


digital sinewave.png

Download All
0 Kudos
Message 9 of 17
(6,212 Views)

Your one chart looks fine.  It is the other chart.  That is because it is based on some raw numbers, the timing information that is present in the waveform as been thrown away.

 

If you go into the propertyies of this chart, you can set the T0 time and the dT time interval.  It would be the multiplier under the Scales tab in the properties dialog.

0 Kudos
Message 10 of 17
(6,208 Views)