03-26-2024 03:44 AM
I see, so do I still use the termination char? I’m not sure where the Query unterminated error is coming from. I can attach my code again if that’s helpful.
03-26-2024 04:29 AM
Andrey's answers were kind of confusing. First GPIB devices almost always use an explicit EOI digital line to indicate an End of Information unless it is a very old GPIB device from before the 90ies of last century. The IEEE 488.2 specifically standardized on this behavior to make the communication more unified.
If the instrument also has Ethernet and/or Serial ports, it often will allow to use an EOL character too on the GPIB side to be able to use the same parser for all interfaces but it will still use the EOI line too on the GPIB interface.
Serial and Ethernet port communication without EOL or fixed sized messages is a bug. Any such instrument should be send back to the manufacturer for a firmware upgrade. 😁
Your original problem has however nothing to do with this. Most measurement devices work according to the principle: send ONE command, and read ONE answer. You can't send one command and read two answers and neither works the opposite. You often can combine two or more commands into one command string by separating them with a semicolon, but if any of those commands produces a response you have to read that as one answer.
And of course you can try to send two separate commands first but most devices will complain as they have not been able to send of the response for the first command (your program hasn't read it) and they don't like to receive a new command if a previous command is still pending. Even if a device would support receiving multiple commands, you would have to do extra work to distinguish which of the two answers was for which command, so why making your life harder?
03-26-2024 05:23 AM - edited 03-26-2024 05:25 AM
Thank you! This makes a lot of sense. At some point I was trying to use a command that’s supposed to scan 2 channels but the machine only return the measurement of 1. This is a research project and I’m just having a lot of difficulty with it 😅 anyhow, so I can understand the machine working on sending one command and reading one answer. Is there anyway I can send one command, wait for the machine to read and send the answer and send another command afterwards? Or is this also tedious? Is there a specific approach to it?
03-26-2024 05:30 AM
Since VISA Read will terminate on these conditions:
1) an error occurred in a lower level IO interface
2) the termination character was received if any was configured
3) the EOI line was asserted when using a GPIB instrument
4) the timeout configured for the session was reached
5) the number of requested bytes was received
you can normally simply call the VISA Read right after sending the command with VISA Write. The VISA Read will wait until one of the above conditions gets true.
03-26-2024 05:43 AM - edited 03-26-2024 05:46 AM
I suppose do the program sequentially? I believe I did this but I still got a query unterminated error and then a timeout error when the First Visa Read was sending out its response. Here’s a picture of the current code:
I guess VISA read terminated on condition 4.
03-26-2024 05:52 AM
That trigger (TRG) may not do what you think it should do. If you want to deal with such features on the GPIB bus you absolutely have to dig into the Programmer Reference Manual for your device. What these features do for a specific device and how you need to enable them (by setting potentially extra configuration registers in the device beforehand) is very device specific!
03-26-2024 05:58 AM - edited 03-26-2024 06:00 AM
I use a Visa Write with the command: “MEAS: VOLT?” To trigger measurement. I was more so playing around seeing if the error would change if I didn’t include the command and used a Visa Trigger instead (the machine sent out an error stating the trigger was ignored.) I replaced the trigger with the Visa Write and command afterwards.
03-26-2024 07:25 AM
Even if the measurement trigger isn’t included the code produces a timeout error when the VISA Read is moving on to the second VISA Write command and thus this command is never even processed by the machine. This is what I need help troubleshooting. I’m not sure if maybe I’m reading the incorrect number of bytes or what it is in my code that I need to fix. I’d just like some pointers on what to change.
03-26-2024 01:00 PM
Okay, I figured it out. The error occurred because I did not repeat the trigger command when reading channel 2.