08-01-2012 10:29 AM
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.
08-01-2012 10:34 AM
I would use the sine function, multiply it be 255, than round to the nearest integer.
08-01-2012 10:35 AM
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?
08-01-2012 10:36 AM
@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. 😮
08-01-2012 10:47 AM
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.
08-01-2012 10:50 AM
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.
08-01-2012 11:00 AM - edited 08-01-2012 11:02 AM
As said, use the sine wave VI out of the Signal Generation palette. This code will give you a 2D array of booleans (8x128).
08-01-2012 11:01 AM - edited 08-01-2012 11:05 AM
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.
08-01-2012 12:02 PM
wow, I don't think it would be as simple as that.
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.
08-01-2012 12:09 PM
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.