Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read error from dynamixels

Hey guys,

 

I am trying to write a low level serial communication VI for reading speed from a dynamixel using labview and the myRIO. The VI I use to do this (attached below) works on the first iteration returning the correct number of bytes that are expected. If I put this VI in a while loop, it will never read in the correct number of bytes the second time throwing an I/O error -1073807298. Since the dynamixels use RS485, I am using a MAX485 chip to convert TTL (RX and TX) to RS485 which means I'm using a digital IO pin on the myRIO as the enable. I have had no issues writing to the dynamixels, only reading. It seems strange that it reads fine the first time but not the second since no data is transferred from one iteration of the VI to the next. Essentially I want to enable TX, send the command for reading speed, enable RX, read in the response to the buffer then read the bytes from the buffer. I have no idea why this isnt working. What is going on here?

0 Kudos
Message 1 of 2
(4,322 Views)

Try opening the VISA session outside the loop, performing all reads and writes inside the loop, then closing the connection after the loop completes.  As the code is now, each time the VISA write is called, you're trying to open a VISA session to the same VISA resource.  After the first iteration, that connection is already open, so it's not surprising that you're getting an error after the first iteration.  Opening and closing outside the loop should fix this.

 

If you need an example, take a look at any of the VISA examples available in the example finder.

Cody A.
0 Kudos
Message 2 of 2
(4,256 Views)