LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating a Square-Pulsed Sine Wave with Phase Tracking

In my application, I'm generating a driver signal to an LED.  The LED is turned off and on like a square pulse with some user-set frequency and duty cycle.  When on, its amplitude is modulated with a sine wave at some user-set frequency.  The pulsing is used as part of a temporal multiplexing design - the returned signal will have the square pulses stitched back together.
 
My initial solution to this problem was to generate a sine wave and a square wave separately and multiply them together.  However, this causes a significant problem with recomposing the returned signal: the phase of the sine wave across each square pulse does not necessarily line up when the pulses are put back together.  With some combinations of pulse frequency/duty cycle and modulation frequency, this might occur - however, I would prefer to be able to change these quantities arbitrarily.
 
Essentially what I need to do is generate a sine wave of a given modulation frequency, then break it into pieces as if the sine wave itself were turned on and off with some frequency and duty cycle.  I would like to be able to do this fairly quickly and efficiently, as the function will be called on a regular basis.  I can think of a few ways to do it, but I was curious as to whether any folks out there had simpler solutions.
 
I've attached an image of my current reconstructed return signal to illustrate the problem.  In the ideal system, the signal shown would appear as a continuous sine wave.
 
Thanks!
 
Steven Israel
0 Kudos
Message 1 of 5
(3,519 Views)
The sine wave generators in LabVIEW "remember" their last state, so if you generate your sine wave in pieces and interleave it with lengths of zeros, it should work fine for you.  Are you streaming output and changing on the fly or outputting fixed length arrays?  The solution will be similar in both cases, but the mechanics a bit different.  In either case, you probably want to allocate a fixed length array of zeros and replace the part you want to be "on" with the sine wave fragment.
Message 2 of 5
(3,515 Views)
Hello
Thanks for your reply. well i am sending my application thats called 05_07_29 GUI. now when you see the GUI. you see the Blocks/banks. number of blocks are adjusted by the user.
when the user gives Block value 3. we get 3 blocks/banks, when the user gives 2, we get two blocks/banks.
now my question is if the user says and offset of 10 . it will start with an offset of 10. right now it is working, but it will immediately start at 10.that means it was at zero and it moves to 10. i would like between this zero and 10(the offset value) a ramp of 2 seconds. and when the block 1 reach its limits.that means time for block 1 is over.it will move to block 2. when it moves to block 2 again i would like to have a ramp that is dependent on the offset. ramp between block 1 and block 2 could be also once again 2 seconds.
my second question is i am trying to give ampl_max and ampl_min value as y_marker value on the displayable graph. because i am not directly using the values 0 to 10 volts, but i am using scaled values. these scaled values ampl_max and ampl_min i  would like to display on graph. i tried it, but it is not working.
the last question is that i checked all sub vis and changes but still when i press stop button(in my application), a dialog window opens and ask to save the file. how can i rectify this?
i would be grateful for any help.
 
Thanks
Regards
 
 
0 Kudos
Message 3 of 5
(3,500 Views)
Hello
Thanks for your reply. well i am sending my application thats called 05_07_29 GUI. now when you see the GUI. you see the Blocks/banks. number of blocks are adjusted by the user.
when the user gives Block value 3. we get 3 blocks/banks, when the user gives 2, we get two blocks/banks.
now my question is if the user says and offset of 10 . it will start with an offset of 10. right now it is working, but it will immediately start at 10.that means it was at zero and it moves to 10. i would like between this zero and 10(the offset value) a ramp of 2 seconds. and when the block 1 reach its limits.that means time for block 1 is over.it will move to block 2. when it moves to block 2 again i would like to have a ramp that is dependent on the offset. ramp between block 1 and block 2 could be also once again 2 seconds.
my second question is i am trying to give ampl_max and ampl_min value as y_marker value on the displayable graph. because i am not directly using the values 0 to 10 volts, but i am using scaled values. these scaled values ampl_max and ampl_min i  would like to display on graph. i tried it, but it is not working.
the last question is that i checked all sub vis and changes but still when i press stop button(in my application), a dialog window opens and ask to save the file. how can i rectify this?
i would be grateful for any help.
 
Thanks
Regards
0 Kudos
Message 4 of 5
(3,504 Views)

Your diagram is the LabVIEW equivalent of a C program written on one line. It is syntactically correct, but us poor humans don't have much chance to debug it. In particular, you need to break it into more subroutines (try to limit each one to one screen in size) and make sure the data flow is top-left to bottom-right. I strongly urge you to check out the LabVIEW Style Guide. Read it. Live it. It will make your life much easier. Like using the correct format for C, it becomes second nature after awhile. In the process of doing this, you will probably find your file query.

Generating a ramp between you sine waves is fairly simple. You can do it yourself using a FOR loop and the formula for a line or use Ramp Pattern.vi. It is just another array to send to your output device. You can also use the Formula express block, but I would not recommend it, as it will be much slower.

0 Kudos
Message 5 of 5
(3,483 Views)