Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sine wave on serial port

Hello
I'm trying to send a sine wave between two serial port com4 and com5, I get the data but the sine wave is out of shape.
The sent data is 400 byte but the received vary from 100 to 400 byte and I don't know why
I well attach the vi. I use labview version 8.5

I will be thankful for any help
0 Kudos
Message 1 of 16
(6,147 Views)

Hey Ziad,

Are you giving enough time for the entire byte count to be received?

When the byte count recieved is 400 bytes does it represent the 400 byte sine wave that you wanted to send?

I use LabVIEW 8.2.1 so I can't take a look at your VI Smiley Indifferent

Regards

0 Kudos
Message 2 of 16
(6,136 Views)
Hello Ziad,

I took a quick look at your vi and a few things come to mind.  First, I suggest you put in a "Wait (ms)" vi in your while loops (programming -> timing).  Second, I think you are not reading your entire waveform because your loops are running in parallel.  In your program, the read can run at any time, even though the write may not be done writing.  I suggest combining both loops into one and enforcing program flow with the error clusters. 

Also, here is the VI in version 8.2.
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 3 of 16
(6,117 Views)
I revised the VI a little bit in a way that makes more sense to me and should help with your problem.

Like I mentioned before, and Olivier said, you need to add some waits in to your VI. 

The parallel loops that you had going would not work in any way unless you were using the same instrument to read and write.  The reading process and write process are going simultaneously in your version, when you need the data to be written, then read.  Not read, write, write, write, read, read, write, or some untraceable pattern that was present before.

Hopefully this helps.
0 Kudos
Message 4 of 16
(6,097 Views)

Thank you all for the replies

I tried Steve’s vi but I don’t get any output on com5 witch I don’t know why.

I tried to put a delay loop before the read loop but it makes no difference other than a delay before read but the sine is still out of shape.

I attached my vi in labview version 8.0
0 Kudos
Message 5 of 16
(6,073 Views)
Hey Ziad,

Sorry I didn't make myself one hundred percent clear.  My VI was merely a guideline for you to follow in terms of VI structure and order.

To be honest, I don't really understand the concept or reasoning behind what it is you are trying to achieve Smiley Indifferent .
0 Kudos
Message 6 of 16
(6,069 Views)
Hello again,

As mentioned previously, the parallel loop architecture will not work in this case because you need to wait until the write is done before you can read.  You can ensure that by wiring the error output of the write to the error input of the read.
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 7 of 16
(6,067 Views)

Hello again

All I’m trying to do is sending a wave via serial port and receiving it, and that is just a test in order to be sure that the read part of the program is working properly. Then I will use the read part to read an ECG signal via serial port.

About the wiring when I wire the error output of the write to the error input of the read I get no signal.

thank you

 

I attached the new vi.
0 Kudos
Message 8 of 16
(6,037 Views)
Ziad,

As we mentioned, you should NOT have 2 while loops for this.  You should put all your program inside 1 while loop.  Also, the VISA close vis should be outside the while loops.  I would suggets opening and configuring both serial ports before doing your first write.
O. Proulx
National Instruments
www.ni.com/support
0 Kudos
Message 9 of 16
(6,007 Views)
First and foremost, I recommend you take a long, close look at the VISA Serial Examples provided by NI.  Not only will they help you with your structure and order, but they will show you that you cannot, and should not use two while loops, as we've been telling you all along.

Once again, do not use two loops as Olivier and I continue to tell you.  I think if you take a look at the examples you will see what it is that you have to do.

Regards
0 Kudos
Message 10 of 16
(6,003 Views)