08-01-2012 12:32 PM - edited 08-01-2012 12:41 PM
Actually, you will notice that Ravens math doesn't get you down to 0. You minimum value is 1. You want to use 127.5 (which is 255/2) for you offset and gain. I also set the phase to 270 so the sine wave starts at 0V (not sure if needed).
As far as the graph, you simply need to graph the Y and not the waveform which has timing information in it.
08-01-2012 01:08 PM
The problem with all of this is whether you need to have a value that exactly represents the zero points of a sine wave. Using the 127.5, version you can't. You'd either have 127 which is slightly below zero, or 128 which is slightly above.
You have 256 possible values. If you want to have zero represented by one of the values, that leaves you with 255 other values to distribute between the positive and negative parts of the sine wave. You can't divide that evenly by 2. So one side gets 128 numbers, the other gets 127. You'd have the same issue with using an I8 (signed integer) number. there would be 128 values that are negative, 1 value that is zero, and 127 values that are positive.
All of this may not even matter in your situation, but if it does, you just need to play around with the values so you get what you want.
08-02-2012 08:52 AM - edited 08-02-2012 08:53 AM
hi everyone,
thank you very much for all your help. About which one would I use (127.5 version or 127 version), I'll let the user to decide later.
But now, I'm trying to generate this boolean array using my PXIe card. And I'm still somehow not sure how.
Like I said earlier, I'm building my ramp using array of sequences, which executed after the waiting time elapsed. I mean, I put my T1 as my while loop timer, then I've programmed something like this:
ex: I put T1 (as input) = 1ms, means it would run like this:
Time My output
0 s 00000000
1 ms 00000001
2 ms 00000010
. .
. .
. .
255 ms 11111111
I meant here, I'm generating not the whole ramp at once, but at each iteration of my while loop.
And now I need to use the same method to generate this sinewave, that's why I was talking about "sinewave sequence" yesterday.
I could export my generated sinewave, which is 8 bit, into excel then using line plot I can get a similar sinewave.
But my problem now, I can't generate my sinewave with too many samples at once (error message: not enough memory). I've tried to generate 1kHz sinewave, with 10MHz sample rate.
SO, I was thinking if there's any method to generate this sinewave like the way I'm generating my ramp?? plot them one by one, not all at once.
Maybe I should just concentrate to plot 1 cycle only and then repeat this with FOR loop when user requires more cycles.
Regards,
Yan.
08-02-2012 09:36 AM
@Mystogan wrote:
Like I said earlier, I'm building my ramp using array of sequences, ...
What is an "array of sequences". Never heard of that expression.
All you need is a single cycle in memory, then index into it based on N using quoteient&remainder. (look at my functional equivalent here)
Still, you probably want to do something hardware timed. Can you show us some of your code?
08-02-2012 09:39 AM - edited 08-02-2012 09:41 AM
There's the simple Sine Wave PtByPt. You need the Full Development version of LabVIEW to use it. You also have to keep track of your time. A simple shift register will handle that part.
08-02-2012 11:12 AM
hi everyone,
@crossrulz: I'm using LV 2010 Proffesional Development System, and too bad I couldn't find that VI in my LV.
@altenbach: sorry for my bad english :D, I'm gonna try to clarify what I meant with array of sequences here:
I'm building boolean arrays (in attachment: dig_ramp_up_sub2.vi) of 14 bit boolean (2bit for read/write, 3bit for address, 8bit data, 1bit of 0).
I'm using that VI as a sub-VI, and using index of outer while loop (as in pict) to generate Ramp up, Hold, Ramp down (like what I got from other thread in this forum).
My clock frequency of my HSDIO is 40MHz, which means, each boolean "T"/"F" has period time 25 ns.
each step of Ramp consist of 14 bit, which means 14 booleans = 350 ns of time. I'm using D just for delay.
and I can control time (dt) of each step generation of ramp by controlling the wait time of case loop.
Easy for ramp: I can make sequences of 0,1,2,...,255, then hold, then sequences of ramp down: 255,...,2,1,0.
With using outer while loop index as input to my sub-VI, I'm writing my steps into my HSDIO card at each iteration. I'm generating my ramp in only 1 channel.
Maybe I should say "Sequences of boolean-arrays" instead of "array of sequences".
Now I want to be able to generate sinewave, which should have: Amplitude, Cycle numbers, Samples/cycle, Sinewave freq, Sampling freq, which controllable.
And I was thinking to generate sinewave using the same method as I generate my ramp.
But no, I don't think I can do that, since I can't use the same sequences of numbers to generate sinewave, when I use different sinewave freq and different sampling freq for different test.
Regards,
Yan.
08-06-2012 12:08 PM
hi all,
I have one quick question;
how do I control the execution time of my case structure? as you see, I have several case structures in my VI. And I've put a "wait until next ms multiple" in the structure. But I don't think I'm getting precise time result while generating my 256 steps ramp up and 256 steps ramp down using T1. I've tried to check the time with using tick count before and inside the main while loop and I keep getting weird results.
When I generate my ramp with T1 = 1 ms or T1 = 100 ms, and hold time 1 sec, I'm getting the (relative) same result (1070 ms ~ 1110 ms)
when my T1 = 200 ms or 300 ms, hold time 1 sec, same result ~1500 ms
when my T1 = 400 ms or 500 ms, hold time 1 sec, same result ~2000ms
And I dont know how this result occurs.
What I need actually, when T1 is 100 ms, the ramp up is generated in 100ms, then hold 1sec, then ramp down is generated in 100ms, which means I should have ~1200 ms, or
when T1 = 200 ms; hold time 1 sec; result = 1500 ms
when T1 = 300 ms; hold time 1 sec; result = 1700 ms
or I can say my result should be 2.T1 + hold time. But it seems not running that way.
Any help pleasee...