LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Receiving a lot of junk on serial

I developed an interface in LabWin that I use to get information using the serial port. While it gives me some useful information, it also gives a lot junk characters on the terminal. I am running my serial connection at:  baudRate 115200, parity 0, dataBits 8, stopBits 1, inputQueueSize 5000, outputQueueSize 512. Any suggestions?
 
Thank you.
0 Kudos
Message 1 of 6
(5,271 Views)
Are you flushing the buffers?
I had a serial project that was giving me a lot of junk until I started calling FlushOutQ (iComPortNum) and FlushInQ(iComPortNum) before every send.
0 Kudos
Message 2 of 6
(5,258 Views)
Thank you Zarnon for your reply. but I was already using FlushInQ and FlushOutQ functions and I am still getting junk characters as well as missing some character while reading from the serial.
0 Kudos
Message 3 of 6
(5,247 Views)
How do you know the junk isn't really there?

A bad cable could do this, or a very noisy environment, or a faulty device that's off on the bit clock by 5% or more.  Do you have a really long cable?  At that bit rate, you can't run it very far without getting into trouble.  rs-232 spec calls out cable length Vs. bit rate.

I used to hook up a dumb terminal like an HP 2392 to a suspect serial stream and eavesdrop on it - made it easy to spot bad stuff.

Do you have a frame ground connected between the PC and the other device?  A ground loop can cause problems.  Optically isolated port can solve this (NI sells these).

Are you using a USB / rs-232 converter by any chance?  Many of these are junk and just don't work reliably.

Does it run error free at a lower bit rate?

Menchar


0 Kudos
Message 4 of 6
(5,232 Views)
Hi there,
 
What are you communicating with through your serial port?  Does your device have a programming manual?  A programming manual would tell you exactly what type of data to expect.  Could you elaborate on exactly what you are seeing, also on the data you are missing?
 
Thanks,
Ted
Ted H
Applications Engineering
National Instruments
0 Kudos
Message 5 of 6
(5,223 Views)

Thank you mechar for your reply. You are right. I was using the USB to Serial connector, which apparently does not work that well and was giving me lot of junk. But I replaced that and everything was fine. The reason I was not sure whats happening was, when I use Tera Term or Hyper Terminal, I do not get all that junk but when i use the LabWin interface, I was getting all of that. I am still not sure. But I am not going to worry about it for now. Thank you for your help.

 

0 Kudos
Message 6 of 6
(5,218 Views)