LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate staircase-shape SIN waveform

Hello,

 

I'm still in an impass with generation of staircase-shape SIN waveform.

Here is very simple example, where a value, generated in the 1st loop should be to "Sample & Hold" in 2nd loop (and then use it for some other staff).

Even with this simplest settup I cannot obtain 100ms of the duration of a step. Actually it's about 80ms (please, see the screenshot below)

I also control the duration of the 2nd loop execution. Despite its code simplicity the duration is more than 1ms.

Where is a problem ?

 

Thanks

 

Pavel

 

staitcase_SIN_generation_step_duration_issue.JPG

 

staircase_sin_steplength_issue_simplest_setup (0).png

0 Kudos
Message 1 of 26
(3,902 Views)

I've modified a little bit this simplest setup: removed loop delay from 2nd loop and added iteration execution control for 2 loops.

1st loop executed duing 1ms and 2nd almost instantly.

Despite this "perfect timing" the step duration still less than 100ms. Mystery ...

 

staitcase_SIN_generation_step_duration_issue (1).JPG

 

staircase_sin_steplength_issue_simplest_setup (1).png

0 Kudos
Message 2 of 26
(3,875 Views)

Writing to any front panel object takes time, so what are you trying to do here?

Why do you need to write to a chart every 1 ms ?

Nobody can see a change on a graph that fast.

 

A chart has an internal buffer that it needs to update every time you add a new value to it.

 

Please explain what your end goal is for this.

 

 

0 Kudos
Message 3 of 26
(3,871 Views)

I think you are confusing yourself by the title of the X-axis on the waveform chart.  It may say time, but it is actually just a number.  Each time you write a value to it, that is 1 more along the x-axis.

 

I'm not sure why the one loop would take 1.6 msec and the other about 1.  Might be the local variable call, may be the updating of the chart.  You've simplified the loops to a point where they aren't doing that much different in program logic.

 

But why are you trying to program a waveform this way?  If you are trying to generate a waveform, use the the actual waveform datatype which gives an array of points and also a delta time value in it.  Right now you are trying to create a precise signal, but are relying on software timing which you have seen is not precise.

0 Kudos
Message 4 of 26
(3,869 Views)

@dkfire wrote:

Writing to any front panel object takes time, so what are you trying to do here?

Why do you need to write to a chart every 1 ms ?

Nobody can see a change on a graph that fast.

 

A chart has an internal buffer that it needs to update every time you add a new value to it.

 

Please explain what your end goal is for this.

 

 


I don't reallyneed to write every 1 ms.

What I need is to obtain staircase-shaped sin waveform with precise timing ... i.e. the step duration should be controlled (e.g. 100ms).

Whatever method will be used for this.

Actually I generate sin in one loop (Slow) and capture the value in another loop (Fast).

Probably exist some method to do the same. Any proposition welcome.

By the way in the last version there is no any delay in the 2nd loop ... it runs at fastest speed.

 

Probably front panel causes this issue... in this case how to workaround it

0 Kudos
Message 5 of 26
(3,859 Views)

@RavensFan wrote:

I think you are confusing yourself by the title of the X-axis on the waveform chart.  It may say time, but it is actually just a number.  Each time you write a value to it, that is 1 more along the x-axis.

 

I'm not sure why the one loop would take 1.6 msec and the other about 1.  Might be the local variable call, may be the updating of the chart.  You've simplified the loops to a point where they aren't doing that much different in program logic.

 

But why are you trying to program a waveform this way?  If you are trying to generate a waveform, use the the actual waveform datatype which gives an array of points and also a delta time value in it.  Right now you are trying to create a precise signal, but are relying on software timing which you have seen is not precise.


I'm not sure why the one loop would take 1.6 msec and the other about 1.

Not 1.6ms, but 1.6us (it is ended with E-6), which is normal because I removed loop delay

And 1st loop runs 0.1sec (please see average value), which is also normal: loop dalay is 100ms.

 

But why are you trying to program a waveform this way ...

I don't keep this method, but for the moment it's the only way I found to create such waveform

 

... use the the actual waveform datatype which gives an array of points and also a delta time value in it.

Here I didn't properly understand what you mean. Could you develop a little bit more your idea.

 

Thanks in advance

 

0 Kudos
Message 6 of 26
(3,848 Views)

So have you looked at the Signal Generation sub folder under Signal Processing?

 

I still can't see why you are generating a sinus signal, one sample at a time, that is software timed. What do you need these samples for?

 

Generate your waveform with the correct functions from the Signal Generation or Waveform Generation pallet.

 

We need to know your end goal, to what your are really doing. Why do you really need a software timed signal?

 

You know the Waveform data type right?

Else see here: http://digital.ni.com/public.nsf/allkb/B965F316364DE17B862572DF00363B10

Or http://zone.ni.com/reference/en-XX/help/371361L-01/lvhowto/graphing_waveform_data/

0 Kudos
Message 7 of 26
(3,831 Views)

@dkfire wrote:

So have you looked at the Signal Generation sub folder under Signal Processing?

 

I still can't see why you are generating a sinus signal, one sample at a time, that is software timed. What do you need these samples for?

 

Generate your waveform with the correct functions from the Signal Generation or Waveform Generation pallet.

 

We need to know your end goal, to what your are really doing. Why do you really need a software timed signal?

 

You know the Waveform data type right?

Else see here: http://digital.ni.com/public.nsf/allkb/B965F316364DE17B862572DF00363B10

Or http://zone.ni.com/reference/en-XX/help/371361L-01/lvhowto/graphing_waveform_data/

So have you looked at the Signal Generation sub folder under Signal Processing?
Sure, but there are only "standard" shapes - SIN, triangle, square, etc.
The mine is rather non-standard.
I still can't see why you are generating a sinus signal, one sample at a time, that is software timed.
Because I didn't find another way to generate satircase-shape SIN, where I could define following parameters:
  • step duration (along X axis)
  • step value (along Y axis)
Generate your waveform with the correct functions from the Signal Generation or Waveform Generation pallet.
I didn't find a solution with these functions. Any suggestion welcome.
We need to know your end goal, to what your are really doing. Why do you really need a software timed signal?
This signal will be pased to NI DAQ and, then to experiment workbench. Before starting with hardware I need to debug algorithm in software, so I need this signal to pass it through some VI, that imitate the behavior of a DUT (device under test)

 

0 Kudos
Message 8 of 26
(3,823 Views)

Generate a sinewave.  Then take the array of data 1 element at a time and use that to initialize an array of 100 elements of that value.  Do that in a loop to and build the 100 elements at the end of the array.  Now you can build that array back into a waveform.  Remember to adjust your dT in the waveform because each element is now 1/100 of the time it was before.

 

0 Kudos
Message 9 of 26
(3,819 Views)

Pavel_47,

 

You have multiple threads going with very similar questions.  Each time you make a little progress and then come up against a new obstacle, you start a new thread.  While there is some merit in keeping each thread short and to a single topic, I think that you may be making things more difficult here because no one is sure just what has neen answered and what has not.

 

Please pick one thread, possibly this one, and specify your overall goal. Tell us what you are really trying to generate or measure, not so much what you have tried that did not work. For example give details about what the staircase sine wave should look like. What is the range of amplitudes? What is the range of step amplitudes? Does every step have the same amplitude or does it depend on sin(t)? What is the range of frequencies? How is the duration of each step related to the frequency? Do all steps have the same duration? Which parameters of this waveform are fixed and which can vary? How often can they change? If a parameter changes while generation is in process, does the waveform change immediately or at the end of the next complete cycle? What sampling rate or rates will be used? In one thread you had noise or a higher frequency sine wave superimposed on the stepped waveform. Is that a requirement or simuation of interference? If a requirement, then also specify all the parameters of the higher frequency signals.

 

What will you do with this signal after you get it generated?

 

After we have answers to these questions, we will have a much better idea of what you are trying to do and can then more likely give you useful advice on how to achieve it.  Help us to help you by not making us pry information out bit by bit.

 

Lynn

0 Kudos
Message 10 of 26
(3,794 Views)