LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tringular wave without waveform generator

Solved!
Go to solution

Hi. I need to make a triangular signal (just one cycle, since it will work as a sample that will later be replicated to create a cycle with N samples). So far, I've only achieved the rising part of the signal, but I can't figure out how to make it decrease back to 0.

In the attached images I have my block diagram. I tried dividing the peak voltage by two so that the number of points covers the entire rise and fall of the signal and then the original voltage is recovered by multiplying by two again. The problems I have are that since the case loop starts the decrease when the signal is higher than the peak voltage:

  1. The signal goes +dV above the peak voltage before decreasing.
  2. When it starts decreasing, it stops when the condition is again fulfilled, that is, when the signal is again lesser than the peak voltage, so it goes up and down again and again.

How can I correct this to make the signal go up until V= peak voltage (which should occur at half the number of points) and go down afterward?

0 Kudos
Message 1 of 3
(395 Views)
Solution
Accepted by topic author davidllerenav

I think that part of your difficulty is a "counting" problem, and part is not quite appreciating the difference between (and often the superiority of) the LabVIEW Chart and LabVIEW Graph.

 

So here's the Math part.  Make a Triangle Wave with 4 points.  A sequence could be 0, 1, 2, 1, 0, 1, 2, 1, and an equally valid sequence could be 1, 2, 1, 0, 1, 2, 1, 0.  If you want things to be "symmetric", you could "phase-shift by half a point" and do 0.5, 1.5, 1.5, 0.5, and (of course) an infinite number of other sequences by varying the phase shift.

 

What algorithm would you use to generate the first 4-point Triangle Wave?  Let's call 0 the "Current Point".  Let's agree that we have two "phases", Rising and Falling.  What kind of "thing" in LabVIEW takes on 2 values?  ["Boolean" is one answer].  How many points do we do in each phase?  [You know the answer to that, as well].  Do you want to keep generating waves until you say "Stop"?  What kind of structure "runs until you say "Stop"?

 

So you have your Current Point (which you are going to plot on a ?what?, you have your initial Phase ("Rising"), and you know how many points to plot in this phase (it is related to the number of points in your "wave", i.e. it is related to "4").  What do you need to do?  Plot, then compute the next value, or Compute the next value, then plot?

 

Open LabVIEW, and start putting these things down, and you'll soon have an N-point Triangle Wave (N better be an even number!).

 

Bob Schor

 

Message 2 of 3
(346 Views)

Another thought:

 

1. Generate the original rising ramp, for example (0,1,2,3,4,5)

2. Make a copy and reverse the array, i.e. (5,4,3,2,1,0)

3. Trim off the first and last values  and only keep the "interior" values, i.e. (4,3,2,1)  
     Note: this helps you avoid redundancy at the peak and trough when you build your triangle wave

4. Append to the original rising ramp, i.e. (0,1,2,3,4,5,4,3,2,1)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 3 of 3
(336 Views)