Python Forum

Full Version: Issue to read commands with pyvisa
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I am trying to communicate with a piezoelectric controller. The communication is fine, as I can read the correct set values of the parameters. The problem is that I need to run multiple times the code in order to have the full information. I try to explain better. Here is my code:

import pyvisa
rm = pyvisa.ResourceManager()
my_instrument = rm.open_resource('ASRL3::INSTR')
print(my_instrument.query('geta 4')) #the command 'geta 4' asks for the actual piezo voltage set on channel 4
If I run the first time the script (using Spyder), I got "get 4" as output.
By running a second time (without closing the tab), I got "voltage = 1.000000 V", which is correct.
By running the third time, I got "OK".

I am not sure this is normal. Also, if I now update the command to 'geta 3' and run the script again, he doean not update it, it still gives me 'get 4' as output, and all as before.

Any help would be very much appreciated. Thank you.