Digital I/O

Showing results for 
Search instead for 
Did you mean: 

Problems Reading Serial Communication Ports

I'm trying to read code from COM 1 which is being sent from another computer (which is running Matlab).  I'm using a VISA serial port reader and checking the port every 20ms and it should be receiving just 1s and 2s but occasionally it claims that it is receiving strange numbers like 65 or even -123 and other apparently random numbers.  What could be causing this? (I'm almost positive the port is only receiving 1s and 2s.)



0 Kudos
Message 1 of 5

So the numbers I have been seeing obey the following binary pattern:

10  00001010
18  00010010
33  00100001
34  00100010
65  01000001
66  01000010

Somehow 1s seem to be inserted where 0s should be in addition to the original signal for 1 and 2.


What could be the cause of this and what are the potential sollutions?


Thanks in advance for any help.  This is extremely frustrating! 

0 Kudos
Message 2 of 5
Message Edited by Nicholas Bowman on 01-06-2009 06:50 PM
0 Kudos
Message 3 of 5

Double check that you've got the same baud rate, partity, and start and stop bits on both ends...  Feels like you're seeing a stop bit or something.



Rob Purser
Manager, Test and Measurement
0 Kudos
Message 4 of 5

Nicholas Bowman--


I have found a few documents that may give you some more background regarding serial communication.  I think Rob Purser has pointed out good items to check, such as the baud rate, parity bits, and start and stop bits.  To give you more information, National Instruments has great documents that offer insight when using serial communication.  I have linked one below and it specifically talks about common problems.


Developer Zone Tutorial: Serial Communication Starting Point - Common Problems


Are you implementing any form handshaking?  I have found another Developer Zone that touches on this. 


Developer Zone Tutorial: Serial Communication Overview - What is Handshaking?


Like Rob discussed in his post, your settings could be the primary reason for your difficulties.  If you are curious about the default setting for the serial port, I have another documet that indicates this information.


KnowledgeBase 2P9818WH: Default Setting for Serial Ports




Tyler C

Message 5 of 5