Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI4882 Device Write Issue. Have to double write or I get a timeout.

Hi,

I'm trying to interface with a HP 3497A Option 110.

This is my code:

 

            try
            {
                _dev = new Device(boardIndex, 9);
                _dev.Clear();
                _dev.Reset();
                _dev.Write(ReplaceCommonEscapeSequences("DR3"));
                _dev.Write(ReplaceCommonEscapeSequences("DL3"));
                string resp = InsertCommonEscapeSequences(_dev.ReadString());
                _dev.GoToLocal();
            }
            catch (NationalInstruments.NI4882.GpibException ex)
            {
            }

Highlighted in red is my issue. In order for me to read the response from the device, I have to call _dev.Write(ReplaceCommonEscapeSequences("DR3")) twice or I get a read timeout error.

 

If I call it only once, I get a timeout error, but calling it twice works.

 

Can anyone explain this?

This happens for other options as well.

 

Thanks!

 

 

0 Kudos
Message 1 of 11
(5,496 Views)

Before going to all of the trouble of writing code, I would have verified communication first using NI-488.2 Interactive Control available through NI-MAX.

0 Kudos
Message 2 of 11
(5,481 Views)

Thanks for your reply, but I'm not sure what that would do for me. I appreciate the effort though.

 

 

Communication works fine. I can read the values from the device, but I'm trying to understand if I'm missing something conceptionally in code since I have to make the above call twice in order to read the value.

Is there an additional command I have to send?

There is not many code example out there using .NET and communicating with older devices. These devices do not respond to *IDN? etc.

 

The device does show up in NI MAX as GPIB0::9::INSTR

 

The above code was supposed to be:

           try
            {
                _dev = new Device(boardIndex, 9);
                _dev.Clear();
                _dev.Reset();
                _dev.Write(ReplaceCommonEscapeSequences("DL3"));
                _dev.Write(ReplaceCommonEscapeSequences("DL3"));
                string resp = InsertCommonEscapeSequences(_dev.ReadString());
                _dev.GoToLocal();
            }
            catch (NationalInstruments.NI4882.GpibException ex)
            {
            }

 

Thanks.

0 Kudos
Message 3 of 11
(5,475 Views)

@johndcollins wrote:

Thanks for your reply, but I'm not sure what that would do for me. I appreciate the effort though.

 

 

Communication works fine. I can read the values from the device, but I'm trying to understand if I'm missing something conceptionally in code since I have to make the above call twice in order to read the value.

Is there an additional command I have to send?

There is not many code example out there using .NET and communicating with older devices. These devices do not respond to *IDN? etc.

 

The device does show up in NI MAX as GPIB0::9::INSTR

 

The above code was supposed to be:

           try
            {
                _dev = new Device(boardIndex, 9);
                _dev.Clear();
                _dev.Reset();
                _dev.Write(ReplaceCommonEscapeSequences("DL3"));
                _dev.Write(ReplaceCommonEscapeSequences("DL3"));
                string resp = InsertCommonEscapeSequences(_dev.ReadString());
                _dev.GoToLocal();
            }
            catch (NationalInstruments.NI4882.GpibException ex)
            {
            }

 

Thanks.


No. Your communication does not work out fine, or you wouldn't have the problem you are having.

 

 

0 Kudos
Message 4 of 11
(5,471 Views)

Ok, thank you for pointing that out.

 

Can you try and specifiy what I'm supposed to look for in NI MAX?

It looks like it finds the HP 3497A ok.

 

I have tried this on another setup with similar results.

0 Kudos
Message 5 of 11
(5,466 Views)

As I wrote above  

I would have verified communication first using NI-488.2 Interactive Control available through NI-MAX.

 
0 Kudos
Message 6 of 11
(5,463 Views)

 

Sorry, I guess I'm not getting what you mean with "I would verifiy communication first..."

 

I am communicating with the device. It's responding when I send commands. How do I verify communication.

 

I've run the NI-488.2 Communicator and it behaves the same way.

I have to send the DL3 command twice or the read will time out...Is that the verification you were looking for?

 

Here is the I/O Trace for the code above:

 

Trace.PNG

 

Here is the Trace if I don't send the second write command:

Trace2.PNG

0 Kudos
Message 7 of 11
(5,458 Views)

Are you sure that the command does not require a CR or a CRLF ?

Do you have access to the manual?

 

Perhaps you need to add a delay before a read.

 

 

Message 8 of 11
(5,445 Views)

Thanks for your help..

It was a special eos character that did it.

0 Kudos
Message 9 of 11
(5,339 Views)

John,

 

        What was the special EOS character that you added? I am having the same issue. I have a system in the field that is working properly but the inhouse system is having the double write issue. I have tried adding every applicable character to the end of my write commands with no luck.

0 Kudos
Message 10 of 11
(5,038 Views)