Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

What I write to buffer is still in buffer when I read

Solved!
Go to solution

I'm trying to communicate with an instrument via serial. According to the instrument's manual, when I write "SP", the instrument should respond with with "Maximum Speed: [value]". When I try this in NI MAX, however, what I read is "SP \r \r Maximum Speed: [value]". It seems the command I write is still in the buffer when I read from the buffer. Is this typical for serial communication? Is there a way to avoid this? I can't clear the buffer after I write "SP" because the instrument responds immediately, so then I'd be clearing the information I'm trying to read.

0 Kudos
Message 1 of 5
(355 Views)
Solution
Accepted by topic author jrdwight

It may be typical for some instruments to echo the command along with the response. Check your instrument manual if that is expected.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 5
(342 Views)

Also, is this 2-wire RS-485?  I rarely deal with RS-485, but I remember reading what I sent before being able to read the response when I did.

 

You need to give a lot more information on your setup before we can really tell you if this is expected.  What is the instrument?  What is the protocol being used (RS-232, RS-422, RS-485, etc.)?


GCentral
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 3 of 5
(296 Views)

I determined this was the expected behavior for the instrument I was communicating with (which was via RS-422 by the way). I had it in a mode where it echoed every command it received. I was able to change the operating mode so that this echo is disabled.

Message 4 of 5
(285 Views)

@jrdwight wrote:

I determined this was the expected behavior for the instrument I was communicating with (which was via RS-422 by the way). I had it in a mode where it echoed every command it received. I was able to change the operating mode so that this echo is disabled.


That is common for instruments that want to interface with a terminal program such as Putty.  Thank you for letting us know what you found.


GCentral
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
Message 5 of 5
(274 Views)