Jump to content

VISA Serial Comm.


bhaldeman

Recommended Posts

I am trying to check the position of a motor through the serial port. I am building array that corrolates actual motor position with a seperate optical readout. I need to send a command to the motor controller to "ask" for current position, then "read" the response back through the serial port. To read back, currently I am checking for bytes at the serial port, and then reading if there are bytes. I run that check in a while loop that needs at least a 25ms wait or the system hangs.

This 25ms accuracy is not good enough. Is there a way for the serial port to tell when it has bytes waiting rather than having a very fast loop continually checking it?

thanks a ton

ben

Link to comment
...  Is there a way for the serial port to tell when it has bytes waiting rather than having a very fast loop continually checking it?

thanks a ton

ben

2596[/snapback]

Yes there is.

One way might be to use VISA Events to notify you of the arrival of a serial character. First you have to Enable the event, and then you can wait on it.

Another option is to take advantage of the timeout on the VISA read function. If you Read one character with a large time out (500ms or so), the Read function will return as soon as one character is received, then you can proceed to read the remaining characters. If it times out then you can clear the error and repeat.

I'd really like to post images of some code to make this all a little more clear but I can't seem to figure out how. :blink:

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.