LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a triangular waveform to serial port

Hello, 

I would like to send triangular waveform on a serial port say at 30ms period.  what should be best option to do this. Can we use simulate signal vi and then wiring this directly to serial write VI . 

or should we must place inside a while loop and place wait until next ms vi to control the sample period .

the objective is to tight ms period in between data points.

regards,

0 Kudos
Message 1 of 10
(3,298 Views)

What do you mean by a triangular waveform to a serial port?

 

To me a triangular waveform is an analog waveform of varying voltages.

A serial port is a digital interface.

 

If you want to output a triangular waveform, you need to connect an analog output device.

0 Kudos
Message 2 of 10
(3,289 Views)

Did you figure out your protocol yet? (serial port read and write : executing link establish once)

 

Are you continuously sending the samples?  Are you sending 1 sample at a time or as a block of samples?  How deterministic does this actually need to be?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 10
(3,277 Views)
here is serial write at once. is it possible to entire signal without using loop or we should select "one point per iteration" and use a loop.
Download All
0 Kudos
Message 4 of 10
(3,189 Views)

That VI doesn't contribute anything to the conversation.

 

What is the device at the other end of the serial line?  What message protocol does it expect the data to be in?

Message 5 of 10
(3,178 Views)

Your question makes absolutely no sense.

 

As has been said, as a first step you need to research what commands the device at the other end of the serial cable supports. For example if it is an arbitrary signal generator, it might be sufficient to send a command for "Triangle wave (amplitude, frequency, duration)". Other devices might allow you to write a waveform to a internal buffer to be looped on demand, while simpler devices might just expect a scalar value at timed intervals in proper syntax.

 

Do you have the manual of whatever box connects to the other end of the serial cable? Start there!

Message 6 of 10
(3,167 Views)

On the other side device expects a 14 byte frame at 30ms interval.

2 of the bytes are for waveform signal 2 for timer 30ms interval. Others are static 

0 Kudos
Message 7 of 10
(3,161 Views)

OK, this has nothing to with a triangle wave, just with updating an output value of a dumb device by sending a properly formed frame of data containing the new value.

 

I assume you can properly format the 14 byte frame and the problem is reduced to generating the new value and timing, both fully controlled from within your LabVIEW program.

 

Is this LabVIEW running on a PC or LabVIEW RT? You cannot guarantee any timing on a PC. What is the max allowable jitter in the output? Do you need to be able to turn the wave on and off? Do you need to maintain phase?

 

How many points are in one period of the waveform? I tend to generate a waveform once and then loop through the indexes (e.g. using the remainder of dividing the iteration could by N of the wave using quotient and remainder), thus simplifying the inner code as follows.

 

outputthis.png

Message 8 of 10
(3,154 Views)

Thanks it solved 50% of my issue .

I am using a PC , one sample point at 30ms . 

on the other hand if i want to use same code for piece wise linear like using "Arbitrary signal"

0           0

30ms   10

60ms    20

etc

and its effect on loop rate.

0 Kudos
Message 9 of 10
(3,150 Views)

The output signal is fully defined by the discrete points you are sending. If you want linear interpolation, you just need to generate the interpolation points and increase the update rate accordingly (e.g. double the rate to send one additional interpolated value halfway between points, e.g. 45ms, 15V). However, you will quickly get into limits of timing accuracy if you go much faster.

 

How many bits/value characterize the D/A converter?

What is involved in the communication? Are you just blindly sending frames or do you e.g. need to wait for a "ready" signal before sending the next frame?

Message 10 of 10
(3,140 Views)