LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine wave - max/min

Hi,

 

I have a question for you guys.

 

How do a generate a sine wave if I have two values, one is supposed to be the max value and the other the min.

Both these values comes in form of a byte array from a text file.

 

I can´t send negative values to the device therefore I want to set the two values so the sine wave is going from one to the other.

 

My problem is when I simulate a sine wave the amplitude is both negative and positive. My device can't handle that. 

 

How do I fix this?

 

Cheers /andechr

 

0 Kudos
Message 1 of 9
(4,480 Views)

Generate a sine wave with amplitude (Max-Min)/2, which is equivalent to a Peak-to-Peak of Max-Min.  Now add (Max+Min)/2 (the mean of Max and Min) to it.  It is easy to show that the resulting waveform will have a max of Max, a min of Min, and will be a sinusoid.

 

Bob Schor

Message 2 of 9
(4,451 Views)

Now add (Max+Min)/2 (the mean of Max and Min) to it.
What do you mean with that?

 

I have the block 'simulate signal' with the right amplitude.

But it doesn't generate a smooth sine wave.

 

/andechr

 

 

0 Kudos
Message 3 of 9
(4,424 Views)

@andechr wrote:

Now add (Max+Min)/2 (the mean of Max and Min) to it.
What do you mean with that?


 

You have an array of points representing the sinusoid (with zero mean).  You calculate (Max+Min)/2, which is a number (I'm assuming the sinusoid and the number are both Dbls).  You have an Add function.  Wire the array of Dbl into one side of the Add, the number into the other.  That "adds" the Mean to the sinusoid, making the Zero Mean sinusoid have a new mean.

 

Bob (sometimes I mean what I say) Schor 

 

0 Kudos
Message 4 of 9
(4,414 Views)

Sorry, I didn't pay attention to the rest of your post, where you talk about not having a smooth signal.  Can you post some code?  I have no idea what you are doing, and why you are having so much trouble.  Also, it would help if you could say, in detail, what you are hoping to accomplish.  For example, "I want to have an array of 1000 Dbls that represents a 3Hz sinusoid with maximum of 5 and minumum of 2.5, with samples taken every 10 milliseconds".

 

BS

0 Kudos
Message 5 of 9
(4,408 Views)

I have two arrays that a read from a measurement file. One of them are going to be the max peak of the sine wave and the other one is going to be the min.

The arrays are looking like this. [176, 161, 00, 00] and the second one [149, 21, 00, 00] both dec.

I then subtract the second array from the first and divide the resulting array by two.

One of my problems is how to insert this final array to the amplitude of the block 'simulate signal'.

I have the same problem for the offset, when I add them together and then divide them.

I have attached a jpg-file.




/andechr

0 Kudos
Message 6 of 9
(4,395 Views)

I have two arrays that a read from a measurement file. One of them are going to be the max peak of the sine wave and the other one is going to be the min.

The arrays are looking like this. [176, 161, 00, 00] and the second one [149, 21, 00, 00] both dec.

I then subtract the second array from the first and divide the resulting array by two.

One of my problems is how to insert this final array to the amplitude of the block 'simulate signal'.

I have the same problem for the offset, when I add them together and then divide them.

I have attached a jpg-file.




/andechr

Download All
0 Kudos
Message 7 of 9
(4,395 Views)
You aren't making any sense. The amplitude is a scalar so passing an array will not work. Do you really want the array to be the signal? If so, you don't need the simulate function at all.
0 Kudos
Message 8 of 9
(4,374 Views)

@andechr wrote:

I have two arrays that a read from a measurement file. One of them are going to be the max peak of the sine wave and the other one is going to be the min.

The arrays are looking like this. [176, 161, 00, 00] and the second one [149, 21, 00, 00] both dec.


My previous post, I asked you to tell us what you are trying to do (and I didn't mean "Read from a measurement file").  The problem as originally stated said you had two numbers, max and min, and needed to generate a sinusoid (frequency, sampling interval, and length not specified) with that max and min.  I told you how you would take max and min and turn them into parameters a sinusoid generator would understand, namely Amplitude and Bias (or Offset).

 

Now you are talking about arrays from a Measurement File.  What are these arrays?  Are you generating multiple sinusoids based on one array have multiple values for Max and the other multiple values for Min?  Or are the arrays the actual data, somehow?

 

Without a clear understanding of what you want to do, you really cannot begin to write coherent code.

 

Bob Schor  (trying to be helpful, but not getting any useful information from you ...)

 

0 Kudos
Message 9 of 9
(4,355 Views)