LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inserting points for the simulate arbitrary express vi on the front panel

Solved!
Go to solution

Hi,

 

I am making an arbitrary waveform generator. And i want to make a signal like this for my cDAQmx: 

 
 
 

Capture.PNG

The points that i now filled in the configure screen of this express vi are as followed: 

0 0
5 0
10 1
20 1
25 2
35 2
40 3
50 3
65 0
75 0
80 -1
90 -1
95 -2
105 -2
110 -3
120 -3
135 0

 

The points are not equally spaced in time. The express vi does the interpolation between these points. My question is; how does the express vi do this? I already opened the front panel of this express vi by converting it but for me it because not clear how the express vi executes this. 

 

With kind regards,

 

Willem

 
 

 

 

0 Kudos
Message 1 of 28
(2,419 Views)

The express VI does this during the configuration, so converting doesn't reveal it's tricks.

 

It looks like linear interpolation to me. So if you have an array of Xs and Yx, and a generated array of destination Xs (X`), generated with a Ramp function, you can use the Interpolate 1D.vi from NI Gmath.lvlib (not the Interpolate 1D function!) with those inputs.

 

But if you want a nice sine wave, there are better ways...

0 Kudos
Message 2 of 28
(2,405 Views)

Okay, thank you for your reply. I am going to try that. I want to make an arbitrary waveform so no simple forms like a sine or something like that. 

0 Kudos
Message 3 of 28
(2,360 Views)

Hi what i have now is this. The problem i have now is that the timing is a bit off. Timing should be exactly like it is on the front panel (X en Y). And a minor issue is that the plot (inside the loop) of the values is a bit strange. It should show the built up of the signal.  

0 Kudos
Message 4 of 28
(2,337 Views)

@WillemNL wrote:

Hi what i have now is this. The problem i have now is that the timing is a bit off. Timing should be exactly like it is on the front panel (X en Y). And a minor issue is that the plot (inside the loop) of the values is a bit strange. It should show the built up of the signal.  


You're building a plot with two values. One Y value is the time, the other Y value is the Y value.The graph plots two point (0, T) and (1, Y).

 

There's no chart where you can add X, Y values consecutively. You either plot Y values, and the dX is fixed (0..n), or you concatenate all X, Y values in (growing) array and put those in an X, Y graph.

 

I'm not sure what you mean by "the timing is off"...

 

The ramp is only need if you want an array out. Seems to me you want to know 1 Y value at a specific time T. 

0 Kudos
Message 5 of 28
(2,335 Views)

I mean by "the timing is off" that the signal does not exactly starts built up the signal after 5 seconds and stops building up after 10 seconds.

 

I forgot to mention that i use labview 2014 so I can not open your vi :). 

0 Kudos
Message 6 of 28
(2,330 Views)
@WillemNL wrote:

I forgot to mention that i use labview 2014 so I can not open your vi :). 


No problem.

 


@WillemNL wrote:

I mean by "the timing is off" that the signal does not exactly starts built up the signal after 5 seconds and stops building up after 10 seconds.


Not sure about this, but some guesses...

 

You're creating 6500 points, the dT of each point is 1/6500. Each iteration is 10 ms. So the real time that elapses isn't the time in the arrays.

 

Also, the interpolation doesn't double the nr of samples. You get a new point between two points. So you get NX2 -1 samples as output. So slightly off...

0 Kudos
Message 7 of 28
(2,327 Views)

Okay thank you very much for your help so far. Just a few questions:

How do I reset the chart, now it keeps adding each run after the last one? 

Why do you compare Y with yi? 

 

And there is one last item i want to add but i don't if it is possible... 

What I did till so far was that i made equal steps for X. But that is not what i want. So what I want to do is to fill in a table on the front panel for X and Y but that the steps between every X-value could be random like the example i already have shown in the first message. 

0 Kudos
Message 8 of 28
(2,324 Views)
Solution
Accepted by topic author WillemNL

@WillemNL wrote:

Okay thank you very much for your help so far. Just a few questions:

How do I reset the chart, now it keeps adding each run after the last one? 

Why do you compare Y with yi? 


You can delete that compare. It was a test for me to see if the first VI did anything. An interpolation factor of 1 seems to interpolate once, and I just wanted to make sure the output wasn't the same as the input. I'm not sure why this interpolation is needed.

 


@WillemNL wrote:

And there is one last item i want to add but i don't if it is possible... 

What I did till so far was that i made equal steps for X. But that is not what i want. So what I want to do is to fill in a table on the front panel for X and Y but that the steps between every X-value could be random like the example i already have shown in the first message. 


The build in interpolation VI (Interpolate 1D.vi) does take an array of X`values, and calculates Y` values from the X, Y arrays. The X` array doesn't need to be regular, or even continuous.

 

For linear interpolation, it probably goes over each X' value, and does a threshold 1D function on the X array to get a fractional index f. Then it does a Interpolate 1D function (not the VI) to get the Y`, the value linear interpolated between Yfloor(f) and Yfloor(f)+1.

 

It's easy to do yourself if you need to, but the build in interpolation does that as well. You can do this inside the loop, for each time individually (preventing a potentially huge X`, Y` array). This also does provide more flexibility.

 

This is what I had in mind:

Interpolate table (ramp).png

 

The Interpolate 1D.vi now interpolates the values in the ramp. But if the ramp isn't regular, it will still do the job.

 

Something like this will do it manually (untested):

 

Interpolate table (manually).png

 

So there is more flexibility here. You don't have to fix the X` values up front anymore.

Message 9 of 28
(2,298 Views)

Hi, I have integrated your idea and it works great, but i have still the problem that the timing i want is not exactly the output timing. There is a time difference of about 2 seconds (measured with an external timer). That is when I have 100 S/s (samples per second). When I change that to 10S/s there is no time difference. Is there some executing limit for this? 

 

 

0 Kudos
Message 10 of 28
(2,271 Views)