Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Notify for 2 (or more) Devices

Hi..

 

we want to serve several devices using an eventhandler called by asserting the device's SRQ line. To test this, we used the example supplied by NI on

C:\Dokumente und Einstellungen\All Users\Dokumente\National Instruments\NI-488.2\Examples\DotNET3.5\Notify\cs.
We modified the code, so that 2 devices with different primary addresses will be opened. We also added a second Notify-Callback Routine for the second device. Unfourtunatly we found, that only the last opened device raise the notify callback. It doesn't matter, in which order you call the device.notify. Attached you find a NI spy session, which show in lines 1 to 63 the events if first the device with PAD 4 is opened and then the device with PAD 2.after that, both devices register the notify callback handler. Then a command ist sent to the device with PAD 2 (the "*" is a software ACK our device send end expect after each command). This device answer as expected with the notify callback. The second command is then sent to the device with PAD 4, but no notify callback is raised. Closing the devices and oppening in reverse order (first PAD 2 then 4) show (lines 64 to 126) that again only the last opened device respond with the notify callback.
 
Has anyone successfully used Device.Notify() for more than 1 device, preferable C#? Can you offer some words of advice on what may be the problem?
 
Thanks,

Harald
 
Software Details:
NI-488.2, version 2.71
Microsoft Visual Studio 2008
DotNET 3.5
  Common 8.7.35.131
  Gpib 8.7.35.104
 
Hardware details:
Windows XP/SP3
NI488-GPIB
no Standard device

0 Kudos
Message 1 of 5
(4,180 Views)

Hello Harald,

 

for further investigations it would be nice to take a look at your modified Code. 

Can you please attach your Code to the next post.

 

Regards

 

Moritz M. 

0 Kudos
Message 2 of 5
(4,134 Views)

Hello Moritz,

 

attached the source-code wie modified.

To create the SPY-file attached to the first post, we run the program, send the command to the first device (with "2" in the stringToWriteTextBox) and then send a command to the second device (something different than "2" in the stringToWriteTextBox). Then we closed the program and modified the openButton_Click as listed below, than send the commands to the two devices in the same manner.

 

Thanks,

 

Harald

 

        private void openButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                int currentSecondaryAddress = 0;
                if (sadComboBox.SelectedIndex != 0)
                {
                    currentSecondaryAddress = (int)sadComboBox.SelectedItem;
                }

                testDevice4 = new Device ( (int) boardIDNumericUpDown.Value,
                     (byte) 4,
                     (byte) currentSecondaryAddress );
                testDevice4.UnaddressingEnabled = true;             // untalk and unlisten after sending command
             
                testDevice = new Device ( (int) boardIDNumericUpDown.Value,
                    (byte) padNumericUpDown.Value,
                    (byte) currentSecondaryAddress );
                testDevice.UnaddressingEnabled = true;             // untalk and unlisten after sending command



                SetupControlState(true);
                ClearOutput();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
 

 

 

0 Kudos
Message 3 of 5
(4,078 Views)

Hi Harald,

 I took at look at your code and compared it to the example using a diff program. I saw some commands were different that I couldn’t explain so I thought that I would add a second device to the example and see if I could replicate your experience with the hardware I have on hand. I’ve attached the project I modified and the spy capture that I got when I ran it. I modified the example so that it would open a connection to two GPIB devices and the all the other buttons so that it would operate on booth devices. Take a look at this code and see if you can modify your code so that you get the behavior you expect. Hope this helps!
Matt
Applications Engineer
National Instruments
Download All
0 Kudos
Message 4 of 5
(3,947 Views)
FYI the command "*SRE 16" configures my instrument simulator to assert the SRQ when it has information to return. Cheers!
Matt
Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(3,945 Views)