Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Read/Write GPIB protocol in c#

Solved!
Go to solution

Hello everyone,

I have a configuration of a system controller and two instruments connected on a GPIB bus.

Being a c# developer I'm not able to get the full extent of how exactly things needs to be done with GPIB communication. The majority of examples don't follow the full protocol of what need to be the read/write steps between a system-controller and the attached instruments.

Kindly know that the examples that come along with VISA or 488.2 drivers installation are not explicitly pointing at the order that things need to be done.

I'll be so much happy if anyone could point me at an example of how should be a GPIB discussion between the system-controller and at least two instruments. Aspects like passing the control between the entities etc. will be very much appreciated. Thanks in advance.

Oh Yes, C# of course. Thanks

0 Kudos
Message 1 of 7
(9,881 Views)

Hi ,

 

Did you check this link for C# and Visual Basic.Net Instrument control Tutorial, here are the links: http://www.ni.com/tutorial/2739/en/

Also, there is an example, maybe you want to check it, this is the link: http://www.ni.com/example/26162/en/

There is not much information, but let me try a search for something useful.

Are you using Visual Studio?

 

0 Kudos
Message 2 of 7
(9,847 Views)

Hi,

I've read perhaps by now dozens of articles, those which you sent too or similar and watched the existing examples in c#. Yes, I'm using Visual-Studio 2015 and coding in c#/WPF.

The point remains as you mentioned - not much information. For c#.

So I'm hoping to find like a procedure, not even coding, that will tell me what are the steps to pursue when I need to control multiple instruments. It comes to the point that whatever I do, I get exceptions from the NI 488.2 or VISA DLLs that - "...need to be the CIC" or "GPIB bus error", etc.

I understand that NI are expecting a certain way of doing things when using the GPIB bus. It's just that I couldn't find anywhere in the NI documents or forum discussions what is that procedure. Hopefully you can come with something in that direction. Thanks many for your support.

0 Kudos
Message 3 of 7
(9,843 Views)

Hello, thanks for the reply.

So I'm familiar with the tutorial and the example that you sent. The points which are in question with c#/.NET programming and are not answered in the many pages that I've read are:

1. How to perform a gpib line monitoring without getting into a stuck situation? Not with the Device commands nor the Board level couldn't solve this issue.

For instance using "C" programming I could do the following:

iblines(gpib_boardM, &DEVICE_PRESENT_M); -- that command monitors the line, NOT blocking, and tells when the Attention bit (ATN) and the Listener (LACS) bit are asserted. I could not find any equivalent in C#.

2. In a multiple devices control (e.g. two devices connected to one controller) when should each entity take control on the gpib line and how is the control passed among them? The command - PassControl() only creates a mess with unpredicted consequences.

So at this point, to solve my case I actually wrote a "C" DLL that monitors the gpib line and when a message is observed I get a Boolean signal into my C# DLL to read the message from the gpib.

It's not an ideal solution but it's better than telling my boss and worse my customer that I have no solution! 🙂

I'll be happy if you can find anything better which is based only on C# programming. Thanks again for your help.

0 Kudos
Message 4 of 7
(9,827 Views)

Hi!

I know is not an ideal solution, but is a really clever solution.

If I find something really useful I would let you know. Im still looking for some proper documentation of this.

0 Kudos
Message 5 of 7
(9,822 Views)
Solution
Accepted by topic author Arik2017

Thanks, I'm very happy to have A solution. I'll go ahead and close this deal. Again if you're really going to pursue this item and come with a better solution I'll be the first to give you plus 1 for letting me know.

0 Kudos
Message 6 of 7
(9,815 Views)

It is not clear for me what you want to do and why the standard examples aren't good for you.

 

"How to perform a gpib line monitoring without getting into a stuck situation? Not with the Device commands nor the Board level couldn't solve this issue."

Usually you never need to monitor the lines to communicate with your instruments.  I don't know any circumstances when Iblines would be necessary except for debugging communication problems with home-made or not quite compliant devices.

 

"In a multiple devices control (e.g. two devices connected to one controller) when should each entity take control on the gpib line and how is the control passed among them? "

Usually there is one controller (PC) and instruments never take control (and most often are not able to).   PassControl  could be useful if you want to be able to switch to another acquisition program running on a different PC (or a microcontroller) but is probably never used either.

0 Kudos
Message 7 of 7
(9,155 Views)