Delphi for UD - Windows | LabJack
 
« Close

Datasheets and User Guides

App Notes

Software & Driver

 
Thursday April 9th, 2020
Support: LabJack engineers available through email and chat.
Shipping: We are processing and shipping all orders.
Stock: 54/56 products in stock. More details.
Supply Chain: Some disruptions. More details.

Delphi for UD - Windows

Delphi wrapper and examples for the Windows UD library. The Windows UD library is the high-level Windows library/driver for the LabJack U3, U6 and UE9. For other LabJack devices, go to the Software page.

Refer to the text file in the download for more information.

 

UD Examples Overview (Referencable)

UD Library Overview

First read the general overview of the UD library:

https://labjack.com/support/software/api/ud/overview

The UD driver has a handful of functions, many with the same 4 to 6 parameters.

Functions

The main functions are used to build a list of requests (Add), execute the list (Go), and read the result of each request (Get).  Some functions (e.g. eGet) combine a single add/go/get into one function call.

Parameters

The parameters are described at the bottom of the Overview page.  The meaning of each parameter should be apparent (e.g. Channel is the channel number you are operating on), but when it is not the pseudocode section of the device's datasheet has the extra information needed.

  • Handle:  Always the handle.
  • IOType:  Always the IOType.
  • Channel:  If something besides a channel number the pseudocode section will tell you.
  • Value:  Always the value.
  • X1:  Usually not used, but if used the pseudocode section will tell you.
  • UserData:  Usually not used, but if used the pseudocode section will tell you.

Pseudocode

Device specific pseudocode can be found in datasheet section 4.3:

U3: https://labjack.com/support/datasheets/u3/high-level-driver/example-pseudocode
U6: https://labjack.com/support/datasheets/u6/high-level-driver/example-pseudocode
UE9: https://labjack.com/support/datasheets/ue9/high-level-driver/example-pseudocode

File Attachment: 

5 comments

In order to get this to work with newer versions of Delphi (Delphi 2009 and up), change all PChar parameters to PAnsiChar (simply search and replace "PChar" by PAnsiChar"). In old versions of Delphi, PChar was an alias for PAnsiChar, with newer versions, it is an alias for PWideChar, which will not work with the labjack DLL. Note that the updated unit is still compatible with old versions of Delphi.

Thank you for commenting on this issue and reminding us about it. I am currently updating the examples and they will use PAnsiChar instead. I will post again when they are updated.

The examples have been updated and use PAnsiChar/AnsiChar now.

Bram's picture

I want the simplest code for Analog In (U3). This code only produces 00000 .... what is wrong

//---------------------------------------------------------------------------
//  Read 16 port AIN
//---------------------------------------------------------------------------

program TestAnaIn01;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Windows,
  Math,
  LJUDDelphi in '..\..\..\Wrapper\LJUDDelphi.pas';
var
  j: integer;
  ValueAIN: array[0..16] of double;
  ch:char;
begin
  for j := 0 to 10 do
   begin
     Writeln(ValueAIN[j]);
   end;
  ReadLn(ch);
end.

 

Thanks Bram

LabJack Support's picture

We have a programmer that is familiar with Delphi who will be available later.  I'm not a Delphi expert, but I don't see any UD calls in your code.  Is "ReadLn" a function you wrote or something we provide?  Do you have error checking and handling as I don't see any in your code?

Perhaps try our Delphi_LJUD example U3eFunctions.  Run it as is first, but then once you confirm that works you can remove the calls to eDAC(), eDI() and eDO(), along with the timer/counter stuff, to leave you with just 3 calls:  OpenLabJack(), ePut() and eAIN().  This example also demonstrates error catching and handling, and that routine uses a 4th call which is ErrorToString().