Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Truncated serial data

Hi there.  I've inherited a system that has some issues I'm trying to resolve.  I'm new to serial communication, so I'm hoping someone here can point me in the right direction.  This system uses VISA to communicate with a Animatics SmartMotor from Moog.   The motor program opens a RS232 serial communication channel and then runs a loop every 100ms that does two things:  (1) Looks for a new position command from the receive buffer (and moves to the new position if it sees one) and (2) outputs the current motor position + a carriage return back to the LabVIEW system.  Note that the system uses a USB to RS232 adapter, so that the motor plugs into the adapter and the adapter plugs into the USB port of the computer.

 

There are 2 things happening that lead me to believe I'm having some data loss during communication.  

 

First, occasionally the motor will go to the wrong position leading me to believe it is not receiving the correct new position.  This is a problem I need to solve.

 

Second, when I look at the position data from the motor after it comes back to my vi, it randomly drops digits.  This is an annoyance, but not critical to system performance.  So the data might looks something like this for an actual position of 3333.  

 

3333

3333

3333

3333

333

33

3

33

333

3333

3333

3333

3333

etc.

 

I've attached a txt file of the SmartMotor code for anyone that wants to check it out along with a stripped down version of the LabVIEW vi's.  SM-Test.vi is the top level vi.  Any thoughts?

 

Thanks in advance!

0 Kudos
Message 1 of 4
(3,228 Views)

I can't look at your code right now, but it sounds like you are using the Bytes At Port.  DO NOT USE THE BYTES AT PORT!!! Since the motor ends it's transmission with a carriage return, use that to your advantage.  Just tell the VISA Read to read more bytes than you expect and it will stop the read when the termination character (carriage return) is read.



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 2 of 4
(3,213 Views)

Thanks Crossrulz, I'll be able to test this tomorrow morning.  Do I need to assign the carriage return as a termination character in my VISA Configure Serial Port function? or does it automatically consider the carriage return as a termination char?

 

Thanks!

0 Kudos
Message 3 of 4
(3,211 Views)

@gintree78 wrote:

Do I need to assign the carriage return as a termination character in my VISA Configure Serial Port function? or does it automatically consider the carriage return as a termination char?


The default settings from the VISA Configure Serial Port is to have the Termination Character turned on (which you want) and the termination character set to a Line Feed (10, 0xA).  So you need to set the termination character to Carriage Return (13, 0xD).



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 4 of 4
(3,203 Views)