LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

generating continuous waveform while preserving properties

Hello,

Thanks to all the past posters for being so helpful.

I was unable to answer two questions:

The first concerns the maximum triggering rate in LabVIEW. My goal is to have two trigger / gate blocks set up working at approximately 25 Hz and 7800Hz, respectively. Is it reasonable to expect proper trigger/gating even at the higher rate?

Secondly, how can the frequency and duty cycle of a simulated square wave be preserved for smaller samples? I'm trying to simulate a 25Hz square wave with 50% duty cycle at 1MHz sampling frequency, but in 129 – sample increments. Currently, only the first 129 samples are displayed, even on both “reset phase, seed and time stamps” and “use continuous generation” modes. In other words, my goal is to have a waveform that is displayed in ‘pieces’ or in ‘frames’ of the total waveform without resetting generation.  

Your help is always appreciated,

BME_guy

0 Kudos
Message 1 of 4
(3,088 Views)
Hello,
 
Are you talking about software timed operations, or are you talking about some hardware you have?  As far as simulating signals, remember that your data is essentially an array, where you just specify the timing information to be associated with that array.  With that in mind, really your only restriction on how "finely" you can simulate is the precision with which you can represent numbers on a computer.  Using a standard double, the smallest value which can be represented is 2−149 ≈ 1.4012985×10−45 I think (http://en.wikipedia.org/wiki/IEEE_Floating_Point_Standard), although attempting to represent some even larger values, such as 0.1, cannot be done exactly using a double because of the underlying representation.  Hence, computational errors are always a consideration.
 
I have attached a simple example which generates a simulated 25Hz square wave sampled at 1MHz - I display 100000 samples so you can actually see a couple complete cycles.
 
I hope this helps!
 
Best Regards,
 
JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 4
(3,078 Views)

Thank you, JLS, for partially answering my question. I’m sorry for being unclear.

What I’m trying to do is simulate a signal that has a longer period than is visible in a single array. For example, I'm trying to simulate a square wave at 25 Hz sampled at 1MHz, in 129-sample increments. Ordinarily, 40k samples would be required to represent a full cycle of a 25 Hz wave sampled at 1MHz (1sec/1E6 samples * 40E3 samples = 0.04 sec = 25Hz ). The period of this wave is not visible within each individual set of 129 samples, but would be shown when they are pieced together. The pieces are what I'm trying to simulate. This might be compared to playing parts of a track on a CD player by pausing, sending a webpage as packets, or splitting a large software program among several CD’s. (I’m just trying to provide many examplesSmiley Wink)


However, I have not found a way to do this yet. The signal resets and begins simulating at time=0, without ‘remembering’ where the simulation left off in the last 129-sample set. This has been the case in my approaches and also the example included in your reply.

Thanks again, I appreciate your feedback.

BME_guy

0 Kudos
Message 3 of 4
(3,073 Views)
Hello,
 
One way to implement this would be to simply create 1 period of your desired waveform and hold it in an array.  Then, on each iteration of your loop, you simply take out the next 129 points.  The only catch would be that you will have to account for the rollover case.  Well, I decided to just implement this for fun, so I have attached a VI which will take the next N points from a buffer, as well as an example which illustrates how to use it.  The subVI is used like a functional global - basically it has an initialization state where you need to specify the buffer (your array of data) and the start index.  Then you can call it with the Get Next N Points state and it will get the next N points from the array - accounting for the rollover when necessary.  In fact, you can specify getting a different N on different executions of the Get Next N Points state (which is why this must be wired inside the while loop of the example VI which uses the subVI).  If you're not familiar with the functional global concept, it's the idea that you can have an uninitialized shift register hold data across executions of a subVI.  Save both attached VIs to the same location on your machine, and run the example to see how it works.  You can then use my previously attached code to generate 1 period (40000 points for your case) of your square wave, and use that array instead of the example's.  Then make N=129 and you're golden.
 
I hope this helps!  Admittedly the code isn't cleaned up - I literally just wrote this a few minutes ago.  But it should do the job!
 
Best Regards,
 
JLS
 
PS - Just to be clear, the "subVI" referred to as a functional global above is named "Circular Read Buffer Functional Global.vi" and the example which shows how to use it is named "Example Using Circular Read Buffer Functional Global.vi".
Best,
JLS
Sixclear
0 Kudos
Message 4 of 4
(3,058 Views)