use of DrDAQ from Pascal under Linux, Raspbian and Windows

Pascal wrapper of the usbDrDaqApi.h for Free pascal, Lazarus and maybe Delphi.

What do you need to start using the DrDAQ with Pascal?


For testing the driver installation and DrDAQ connection, you may use my program DrDAQ_cnt below.

Programming manual Pico-DrDAQ-pmen.pdf and a piece of working brain.

Example source code with comments:

program example_drdaq;

uses sysutils, usbDrDaqApi, PicoStatus;

var
DrDAQhandle : int16;
ivalue : int16;
overflow : word;
InfoStr : array[0..63] of char;
Status : PICO_STATUS;
fValue : single;

begin
Status := UsbDrDaqOpenUnit(DrDAQhandle); //try to open DrDAQ
if Status = 0 then //opened succesfully
begin
UsbDrDaqEnableRGBLED(DrDAQhandle,1); //enable RGB LED
UsbDrDaqSetRGBLED(DrDAQhandle, 0, 40, 0); //set little bit of GREEN

UsbDrDaqSetSigGenBuiltIn(DrDAQhandle, 0, 1000000, 56, USB_DRDAQ_SINE); //set signal generator to 1 Vpp, 56 Hz, Sine

UsbDrDaqGetSingle(DrDAQhandle, USB_DRDAQ_CHANNEL_LIGHT, ivalue, overflow); //read raw value from light sensor
Writeln('Light sensor raw output: ', ivalue);

UsbDrDaqSetScalings(DrDAQhandle, USB_DRDAQ_CHANNEL_TEMP, 0); //set Degree Celsius scale
UsbDrDaqGetSingleF(DrDAQhandle, USB_DRDAQ_CHANNEL_TEMP, fvalue, overflow); //read single floating value
Writeln('Temperature sensor output: ', format('%4f '#$00b0'C',[fvalue*0.1]));

Status := UsbDrDaqGetUnitInfo(DrDAQhandle, InfoStr, 64, ivalue, PICO_BATCH_AND_SERIAL); //read info string
Writeln('DrDAQ batch and serial: ',InfoStr);

UsbDrDaqCloseUnit(DrDAQhandle);
end
else
Writeln('Error during open: ',Status);
end.

Possible issues:

  • Windows
    • check correct DLL architecture 32/64 bit
  • Linux
    • If you get issues with library 'libusbdrdaq.so.2' under linux try one of the following options:
      • in Lazarus project options: Compiler Options -> Paths -> Libraries add /opt/picoscope/lib/libusbdrdaq.so.2.0.0
      • Create symlink in folder where is your program compiled, pointing to /opt/picoscope/lib/libusbdrdaq.so.2.0.0
        with this command while you are in your binary output folder: ln -s /opt/picoscope/lib/libusbdrdaq.so.2.0.0 libusbdrdaq.so.2
        and from Lazarus project options: Compiler Options -> Compilation and Linking:
        Enable setting: "Pass options to linker with "-k", delimiter is space" and add: -R ./ 
      • try to run as root

    Pascal version of usbDrDaqApi.h file usbDrDaqApi.pas and PicoStatus.h as well PicoStatus.pas.
    Example project for Lazarus: picoDrDaq-Lazarus.zip.


    Program for testing Driver installation and USB connection, source code DrDAQ_cnt.lpr (download and compile by command fpc DrDAQ_cnt.lpr). Complete project in single archive: DrDAQ_cnt.zip. Tested under Linux x64, Raspbian on Raspi 3B+, Win32 and Win64.
    Compiled binaries

    Some useful files are also in https://www.elso.sk/download/pico/

     

    Raspbian - driver quick installation

     type following commands into terminal window:

    1. download driver from Picotech website: wget https://labs.picotech.com/debian/pool/main/libu/libusbdrdaq/libusbdrdaq_2.0.40-1r2131_armhf.deb
    2. install downloaded file: sudo dpkg -i libusbdrdaq_2.0.40-1r2131_armhf.deb
    3. download compiled test program: wget https://www.elso.sk/drdaq/DrDAQ_cnt-arm
    4. set execute bit: chmod -x DrDAQ_cnt-arm
    5. run it: ./DrDAQ_cnt-arm

    Product added to compare.

    Webové stránky spoločnosti Elso Philips Service používajú súbory cookies na svoju správnu funkciu a pre zabezpečenie lepších služieb pre Vás.