Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Turn System Controller bit On/Off, programmatically

I want to write a C program to turn the System Controller bit On or off, for a 488.2 PCI Gpib adapter.
However, I'm confused by the descriptions of the function calls in the NI Fucntion Call refernce manual.
I've tried IBRSC(), and IBSIC(), but neither seem to work.
Is there something else I need to do ?

thanks
0 Kudos
Message 1 of 12
(6,318 Views)
I assume you are trying to write a GPIB program to be a non-controller.
Since you are using C, the typical program that you will write is shown below. The ... will need to be some type of loop where you do asynchronous GPIB I/O calls with some ibwaits. You can search the Discussion Forums, I believe I have posted some algorithms to do this. If you have the ability to do C++, you may consider using NI-Device since it takes care of most of these details for you.

main ()
{
u32 l_GpibHandle;

// Open a handle to the GPIB board
l_GpibHandle = ibfind ("GPIB0");

// Configure the GPIB board to NOT be a system controller
ibrsc (l_GpibHandle, 0);

// Configure your Primay address appropriately
ibpad (l_GpibHandle, X); // X is a number such as 3.

... // Do some GPIB

// Take the board offline
ibonl (l_GpibHandle, 0);
}
0 Kudos
Message 2 of 12
(6,313 Views)


@GPIB Guru wrote:
I assume you are trying to write a GPIB program to be a non-controller.
Since you are using C, the typical program that you will write is shown below. The ... will need to be some type of loop where you do asynchronous GPIB I/O calls with some ibwaits. You can search the Discussion Forums, I believe I have posted some algorithms to do this. If you have the ability to do C++, you may consider using NI-Device since it takes care of most of these details for you.

main ()
{
u32 l_GpibHandle;

// Open a handle to the GPIB board
l_GpibHandle = ibfind ("GPIB0");

// Configure the GPIB board to NOT be a system controller
ibrsc (l_GpibHandle, 0);

// Configure your Primay address appropriately
ibpad (l_GpibHandle, X); // X is a number such as 3.

... // Do some GPIB

// Take the board offline
ibonl (l_GpibHandle, 0);
}




I have two computers, each computer has a PCI GPIB card in it. Both GPIB buses are daisy chained together to a scope.
However, neither computer can use the GPIB bus, if BOTH computers have the System Controller bit on.

So, I want to write a program which will turn the System Controller bit on and off, so I don't have to click my way through the NI Explorer to turn the bit off manually. NI's documentation is clear as MUD- they refer to CIC, System Controller, and Active Controller. Who the heck knows which is which? 🙂
I will take care of running this program on the appropriate computer.
0 Kudos
Message 3 of 12
(6,302 Views)
The whole controller aspect of GPIB can be confusing! Here is a summary to help you understand.
GPIB has two different types of controllers:
1) Controller. A controller is responsible for toggling the ATN line to properly control the bus. When the controller asserts ATN and sends data bytes across the bus, these bytes are interpreted as command bytes to configure the bus for appropriate traffic. There are three different controller states: Idle, Standby, and Active. There can only be one entity on the GPIB bus that is not an idle controller.

  • An idle controller is not currently the controller. Technically, the tranceivers connecting the interface chip to the bus have the ATN line as an input and the SRQ line as an output.

  • A standby controller is currently the controller on the bus and is currently NOT asserting the ATN line. Technically, the tranceivers connecting the interface chip to the bus have the ATN line as an output and the SRQ line as an input.

  • An active controller is currently the controller on the bus and is current asserting the ATN line. Tranceivers are the same as for a standby controller.



NI-488.2 adds the CIC bit to the ibsta for any board that is either in the Standby or Active controller state. Control can be passed from one controller to another controller by using the NI-488.2 command ibpct. When control is passed, the prior controller (the one invoking ibpct) becomes an idle controller and the other controller becomes an active controller.

1) System Controller. The system controller is responsible for toggling the IFC and REN lines. The IFC line (Interface Clear) unaddresses all devices and will cause any devices that have been passed control to become an idle controller. The system controller will then become an active controller. The REN line (Remote Enable) is used to place devices in remote mode to let them be controlled remotely instead of via the front panel of the instrument. Technically, the tranceivers connecting the interface chip to the bus of a system controller have the IFC and REN lines as output, whereas the the tranceivers for a non system controller have IFC and REN as an input. This is why you only want one system controller on the bus. If you have two system controllers on the bus, they both have their tranceivers as outputs and cannot detect the other device asserting the IFC line. Confusion reigns and you typically have communication problems.

That being said, what I said earlier was still correct. The following calls will configure the gpib board to be a non-system controller and will correctly modify the tranceiver so that you can have multiple gpib boards connected to the bus and behave correctly. However, if the GPIB board is not active (you do not have any handles open), it should not interefere with a separate controller on the bus. However, you need to make sure that you take all handles offline when you exit to make sure that the hardware is actually turned off on the bus by always making an ibonl (l_GpibHandle, 0) call at the end.

/ Open a handle to the GPIB board
l_GpibHandle = ibfind ("GPIB0");

// Configure the GPIB board to NOT be a system controller
ibrsc (l_GpibHandle, 0);
0 Kudos
Message 4 of 12
(6,296 Views)
it seems as though ibfind() has been deprecated and replaced with
ibfindA() and ibfindW(), which require 4 arguments.

Here is a dump of gpib-32.dll
ordinal hint RVA name

100 0 00004BA0 AllSpoll
5 1 000110D8 CopyrightString
101 2 00004BE0 DevClear
102 3 00004C20 DevClearList
103 4 00004C60 EnableLocal
104 5 00004CA0 EnableRemote
105 6 00004CE0 FindLstn
106 7 00004D30 FindRQS
108 8 00004D70 PPoll
109 9 00004DB0 PPollConfig
110 A 00004E00 PPollUnconfig
107 B 00004E40 PassControl
111 C 00004E80 RcvRespMsg
112 D 00004ED0 ReadStatusByte
113 E 00004F10 Receive
114 F 00004F70 ReceiveSetup
88 10 00004AE0 RegisterGpibGlo
115 11 00004FB0 ResetSys
116 12 00004FF0 Send
117 13 00005050 SendCmds
118 14 00005090 SendDataBytes
119 15 000050E0 SendIFC
121 16 00005110 SendLLO
120 17 00005140 SendList
122 18 00005190 SendSetup
87 19 00004B60 SetGpibStatusVa
123 1A 000051D0 SetRWLS
124 1B 00005210 TestSRQ
125 1C 00005250 TestSys
85 1D 00004A80 ThreadIbcnt
86 1E 00004AB0 ThreadIbcntl
84 1F 00004A50 ThreadIberr
83 20 00004A20 ThreadIbsta
126 21 00005290 Trigger
127 22 000052D0 TriggerList
89 23 00004B30 UnregisterGpibG
128 24 00005310 WaitSRQ
10 25 00003990 ibask
11 26 000039D0 ibbnaA
12 27 00003A90 ibbnaW
13 28 00003B40 ibcac
14 29 00003B80 ibclr
15 2A 00003BB0 ibcmd
16 2B 00003BF0 ibcmda
17 2C 00003C30 ibconfig
18 2D 00003C70 ibdev
19 2E 00003CD0 ibdiag
20 2F 00003D10 ibdma
21 30 00003D50 ibeos
22 31 00003D90 ibeot
23 32 00003DD0 ibevent
65 33 00003DD0 ibeventx
150 34 00003E10 ibexpert
24 35 00003E30 ibfindA
25 36 00003EF0 ibfindW
26 37 00003F90 ibgts
27 38 00003FD0 ibist
151 39 00004010 iblck
28 3A 00004060 iblines
29 3B 000040A0 ibln
30 3C 000040F0 ibloc
63 3D 00004120 iblock
60 3E 00004150 iblockxA
61 3F 00004190 iblockxW
59 40 000041B0 ibnotify
32 41 00004200 ibonl
33 42 00004240 ibpad
34 43 00004280 ibpct
35 44 000042B0 ibpoke
36 45 000042F0 ibppc
37 46 00004330 ibrd
38 47 00004370 ibrda
39 48 000043B0 ibrdfA
40 49 00004470 ibrdfW
41 4A 00004520 ibrdkey
42 4B 00004540 ibrpp
43 4C 00004580 ibrsc
44 4D 000045C0 ibrsp
45 4E 00004600 ibrsv
46 4F 00004640 ibsad
47 50 00004680 ibsic
48 51 000046B0 ibsre
49 52 000046F0 ibstop
50 53 00004720 ibtmo
51 54 00004760 ibtrg
64 55 00004790 ibunlock
62 56 000047C0 ibunlockx
52 57 000047F0 ibwait
53 58 00004830 ibwrt
54 59 00004870 ibwrta
55 5A 000048B0 ibwrtfA
56 5B 00004970 ibwrtfW
57 5C 00004520 ibwrtkey
3 5D 00011AD8 user_ibcnt
4 5E 00011ADC user_ibcntl
2 5F 00011AD4 user_iberr
1 60 00011AD0 user_ibsta
0 Kudos
Message 5 of 12
(6,270 Views)
That is internal for unicode support. The language interface should handle the conversion for you if you use ibfind.
0 Kudos
Message 6 of 12
(6,268 Views)
These are the functions which are exported, which makes them available to other applications.
ibfind() is not one of the exports, so other applications cannot call it.
0 Kudos
Message 7 of 12
(6,263 Views)
You are correct that ibfindA() and ibfindW() have replaced ibfind(), but as GPIB Guru stated you can still use ibfind() and it will be converted for you. Take a look at ni488.h in C:\Program Files\National Instruments\NI-488.2\Languages\Microsoft C and search for ibfind.

If you want to use ibfindA() and ibfindW() directly you can. Here is what the NI-4882 help file says:

"The calls ibfind, ibrdf, and ibwrtf all require an argument that is a name. ibfind requires a board or device name, and ibrdf and ibwrtf take a file name. Because Windows 2000/XP supports both normal (8-bit) characters, and Unicode (16-bit) wide characters, GPIB-32.DLL exports two versions of each of these functions. An "ASCII" version is for 8-bit characters (ibfindA, ibrdA, ibwrtA) and a "wide" version for 16-bit characters (ibfindW, ibrdW, ibwrtW). Because Windows Me/98 does not support wide characters, the only valid functions to use are the 8-bit "ASCII" versions."

Shawn B.
National Instruments
Use NI products on Linux? Come join the NI Linux Users Community
0 Kudos
Message 8 of 12
(6,243 Views)
>>You are correct that ibfindA() and ibfindW() have replaced ibfind(), but as GPIB Guru stated you can still use ibfind()
How, after calling loadlibrary("gpin-32.dll"), I cannot get any connection to ibfind(), nor ibfindA()?
0 Kudos
Message 9 of 12
(6,240 Views)

@*** wrote:
How, after calling loadlibrary("gpin-32.dll"), I cannot get any connection to ibfind(), nor ibfindA()?



I assume that is a typo and you meant gpib-32.dll. What "C" language are you using? You shouldn't need to do a loadlibrary and getproc address calls. The NI-488.2 driver comes with language interfaces that do all of those things automatically. Browse to 'C:\Program Files\National Instruments\NI-488.2\Languages'. I believe it comes with Microsoft C and Borland C. If you are using something different, you may need to do the loadlibrary and getprocaddress calls, but hopefully that should be unnecessary.

Have you tried to compile and use any of the sample programs that ship with NI-488.2? That would be another good place to get started.
0 Kudos
Message 10 of 12
(6,236 Views)