Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB STATUS Register polling using Python Code

Looking for example code (or Psuedo code outline) for polling the status registers. I am writing my code in Python, fairly new to it and GPIB instrument control. I'm not sure the order to use the WAI and OPC commands. I take it in general practice I clear the the registers first, then excute my instrument setup code then poll the registers to find out if the command has finished executing and then issue a command to read the value taken. Main area of concern for me at present in my coding. Second question below is a nice to know question.

Second question would be if I have other instruments on my GPIB bus (ran via USB) two of which set up the test and a third to take the reading is there pitfalls to look out for? Basic set up is Power Meter and Signal Generator, Sig Gen output fed into a stripline and the other end of the strip line  is connected to the Power Meter. Sig Gen output switched on at a set frequency and the power adjusted until the Power Meter reads 0dB, this code I have working, but then adding in the Spectrum Analyser to measure the signal over the stripline. My code knows when the frequency has been set and power output zero'd ove rteh stripline so no need to poll would that be fair to say.

 

Thanks Jamo.

0 Kudos
Message 1 of 5
(5,178 Views)

Hey Jamo,

 

I wanted to let you know that the Python language is not supported by National Instruments. However, I was able to find a KnowledgeBase 4NGMPBMO: How Can I Call DAQmx C Functions in Python? that relates to calling functions in Python that can be related back to GPIB, which could be helpful for this application. 

 

For more information about the ordering of how to call specific functions, we have multiple text based examples that are available for reference. They include polling many devices and how to access the status registers to see what the status of the instrument is. You can find these when you install the NI 488.2 driver and are found in the following location in Windows XP: C:\Documents and Settings\All Users\Documents\National Instruments\NI-488.2\Languages. I would suggest to reference these to see the ordering of how to call different functions. 

 

Also, you may want to reference the Developer Zone Tutorial: Serial Polling and SRQ Servicing with NI-488.2 Software and Basic that provides steps for your program as well.

 

The question of having multiple instruments on your GPIB bus should not be any problems. I would make sure that you are organizing your program properly so you are communicating with specific instruments in your program appropriately. I am not sure I quite understand the setup of your program enough to provide feedback on it. It sounds like you have found a scheme that will work to implement the proper functionality. Can you please provide more information on what specific aspect you are worried about with multiple instruments on the bus? Are you worried about commands being sent or received? 

 

Please let me know.

 

Thanks

Message Edited by Sarah_S on 05-05-2009 05:43 PM
Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 2 of 5
(5,119 Views)

Hey Jamo,

 

Was that able to help in answering your question? 

 

Please let me know if there is anything else I am able to help out with.

 

Thanks

Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 3 of 5
(5,087 Views)

Hi Sarah_S,

thank you for your reply and time taken to help me out. I think I have my polling of my spectrum analyser fixed now, it was a couple of python issues that were causing my grief and not the instrument or the gpib commands, which I have now put down to the learning experience of a new language and it's finer points to watch out for,the two issues were the while loop that was checking the OPC? value to be set as I had used an int variable against a str variable to control the loop was my main issue and secondly the instrument timeout variable set in python another, one was masking the effect of the other and that didn't help, when trying different code changes. Sometimes you get immersed in your own code you can't see a glaring error.

I will read over the reference links you provided and then check that I have my polling correctly setup. I will try and keep my control of the three instruments in my set-up seperate in my code and poll each appropriately (once I have threads running or something similiar my code might get more fancy for instrument checking, but I probably don't need to go that far with my setup as it is fairly basic and just mirrors what you would do manually).

Thanks once again for your help.

 

Cheers Jamo.

0 Kudos
Message 4 of 5
(5,069 Views)

Hey Jamo,

 

Sounds like things are resolved! I am happy to hear that. Feel free to create a new post for any additional questions that do come up. 

 

Have a great day.

 

Sarah S.
Applications Engineering
National Instruments
0 Kudos
Message 5 of 5
(5,053 Views)