Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

sending pointer to data record delphi to instrument

Hi

 

I'm using the gpib-32.dll interface in Delphi and need to send a packed record object to an instrument via the 488 card. I have managed to send single commands (and get responses) using the ibwrt() and ibrd() methods but can't find the function to send a pointer to the structure. Can anyone help with some example code?

 

Thanks

0 Kudos
Message 1 of 8
(5,439 Views)

Hi Anton,

 

Thanks for usinf the forums.

Could you please tell me what National Instruments software and hardware you are trying to use? and what the application is trying to achive.

Can you explain what you mean by Packed Record Object? 

 

 

many thanks

Jordan Power
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(5,404 Views)

 Hi

 

I'm using the dpib32.pas file to access the 32-bit GPIB DLL (gpib-32.dll). The card is an NI PCI-GPIB+

 

What I'm trying to do is control a HPLC instrument (for pharma labs). So far I have figured out how to 'connect' to the GPIB card and do basic communications with the instrument.

 

For example:

   res := ibwrt(separationsModule, 'ID', 2);

   res := ibrd(AInstrumentID, ValueStr, 100);

 

gives me the result I expect, the instrument id and firmware version etc...

 

The same is true for many of the 'string' commands I need to use to query the instrument. e.g. 'GTR' works to set the instrument to remote control.

 

However there are some more complex things I need to send to the instrument, for example:

 

  TAnExampleRecord = packed record
    time : Single;
    FlowRate : Single;
    percentA : Single;
    percentB : Single;
    percentC : Single;
    percentD : Single;
    curve : Byte;
  end;

 

....

var

  ARecord :   TAnExampleRecord

begin

  ARecord.time := 10

 etc...

 

I now need to send this record to the instrument but the ibwrt() and Send() functions only accept a string as a command parameter. How can I convert the record to send it to the instrument?

 

Many thanks

Anton.

0 Kudos
Message 3 of 8
(5,401 Views)

Hi Anton,

 

The code will transimit strings is it not possible for you to input your data from the record as a number of strings, like a indexed arry. are you using labView for anything?

 

thanks

Jordan Power
Applications Engineer
National Instruments
0 Kudos
Message 4 of 8
(5,398 Views)

Hi

 

No, I'm not using LabView, all the code will be written in Delphi for a stand alone application. 

 

Thanks

Anton.

0 Kudos
Message 5 of 8
(5,391 Views)

Hi AntonNID,

 

I have been looking at your delphi problem with GPIB. I've attached a couple of pages that relate to integrating Delphi with GPIB and I recommend you review them. 

 

Windows Direct Entry GPIB Sample Programs for 32-bit Borland Delphi 2.0

 

Language Interface: 16-bit Borland Delphi

 

I would have thought it would be easiest to write a C Dll with all of your GPIB communications setup and call this from Delphi. 

 

Many thanks,

Andrew McLennan
Applications Engineer
National Instruments
0 Kudos
Message 6 of 8
(5,360 Views)

Hi

 

I've taken a look at the examples but unfortunately they don't take me any further then I already am. I can send (and receive) data to the instrument with either ibwrt() or Send(). My difficulty is I guess more to do with Delphi and sending a structure of data to the instrument. I'm in contact with the instrument manufacturer for help.

 

Thanks

0 Kudos
Message 7 of 8
(5,322 Views)

Hi

 

Getting back to this problem: In the C++ header file the send commands are listed as :

 

void __stdcall Send           (int boardID, Addr4882_t addr, const void * databuf, size_t datacnt, int eotMode);
void __stdcall SendCmds       (int boardID, const void * buffer, size_t cnt);
void __stdcall SendDataBytes  (int boardID, const void * buffer, size_t cnt, int eot_mode);

 

The Delphi code is as follows:

 

procedure Send(boardID: integer; address: Addr4882_t; buffer: string; count: longint; eotmode:integer); stdcall;
procedure SendCmds(boardID: integer; buffer: string; count: longint); stdcall;
procedure SendDataBytes(boardID: integer; buffer: string; count: longint; eot: integer); stdcall;

 

My question is regarding the buffer type. In C it is untyped and you can therefore simply send a byte array as the command but in Delphi you are forced to send a String. Is the Delphi header correct?

 

Thanks,

Anton.

0 Kudos
Message 8 of 8
(5,215 Views)