Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB-USB communication by delphi code

I tried to write a code in Delphi to control my instrument(Keithly6221). The instrument is connected and as soon as I run the programme it shows -113 error(undefined header). and i can't communicate with the instrument. please suggest me How to overcome issue.

0 Kudos
Message 1 of 9
(2,441 Views)

You might look at these threads:

https://forums.ni.com/t5/LabVIEW/113-quot-undefined-header-read-quot-error-1074000000/td-p/3579277

https://forums.ni.com/t5/LabVIEW/Error-1074000000-Agilent-3446X-Series-Acquir-Triggered-Multiple/td-...

Otherwise I think no one will answer this question without more complete and precise information (code, NIMAX trace etc.).

0 Kudos
Message 2 of 9
(2,397 Views)

Thanks for Your Reply.

 

I wrote a code I am attaching that one in a text file.

 

All SPCI commands are correct as per the instrument instruction manual. same SPCI command works well in MAX instrument communication section.

 

please take look. looking forward to hearing from you.

0 Kudos
Message 3 of 9
(2,378 Views)

You don't tell which line causes the problem and I don't see there any instruction displaying device error messages from the instrument in this code so maybe the error comes from a different unit.  You have to run the code under the debugger (it's good to learn using the debugger in general) to see which line of code generates the message and after which gpib command.   

0 Kudos
Message 4 of 9
(2,366 Views)

I think there is an issue with the last part in the code where I have created new function SendToGenerator

 

procedure TForm1.SendToGenerator(command: string);
begin
 strcopy(Vstr, '');
 strcopy(Vstr, pchar(command));
 ibwrt(Dev3, VStr, strlen(VStr));
 if (Pibsta^ AND ERR) <> 0 THEN
 GPIBCleanup('Unable to write to device');
end;

 

Progam run well without showing any error even not any warning but as soon as I start the communication with the instrument. there is -113 error on the instrument display (undefined header).  when I stared at any communication the first call is made to this function which has to contains some problem so that it's showing an error after its execution.

 

 

 

0 Kudos
Message 5 of 9
(2,349 Views)

Apparently your instrument does not recognize the sequence of characters in Vstr as a valid command. Put a breakpoint in the line

ibwrt(Dev3, VStr, strlen(VStr));

to check what is the string being actually sent to your device.

 

0 Kudos
Message 6 of 9
(2,332 Views)

We have checked multiple times that what is the command string been sent to the instrument after the command executed (by using show message function). The string value and its sequence are okay but still showing error. 

 

even we have checked the command ibwrt by entering the value of strlen externally still showing error.

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

Did you observe the communiction with NI IO-Trace ? Could it be , that your Command Strings lack termination characters ( like carriage return and/or line feed) which your device expects ? 

0 Kudos
Message 8 of 9
(2,274 Views)

Can you please elaborate little how to plot the NI IO-Trace? I never did this, so I can do that and get back to you.

 

Secondly, I have checked well carefully the SPCI command that drives the instrument and its termination, from instrument manual, and even displayed what string I'm carrying to the instrument before and after the execution of the SendToGenrator function. 

 

If required I have provided my code in .txt format in the past discussion. please take look.

 

looking forward to hearing from you soon

         

 

 

0 Kudos
Message 9 of 9
(2,270 Views)