Recent

Author Topic: NIDAQmxBase header translation  (Read 52289 times)

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #45 on: January 09, 2015, 12:59:21 pm »
Hi,tonbo

I appologize, I forgot to write, that I changed array of byte to Pointer in digital port function like you
Code: [Select]
function DAQmxReadDigitalU8(taskHandle:TTaskHandle; numSampsPerChan:LongInt; timeout:Double; fillMode:Cardinal; readArray:PByte;
           arraySizeInSamps:Cardinal; sampsPerChanRead:PLongInt; reserved:Pointer):LongInt;stdcall;external External_library name 'DAQmxReadDigitalU8';
function DAQmxReadDigitalU32(taskHandle:TTaskHandle; numSampsPerChan:LongInt; timeout:Double; fillMode:Cardinal; readArray:PLongint;
           arraySizeInSamps:Cardinal; sampsPerChanRead:PLongInt; reserved:Pointer):LongInt;stdcall;external External_library name 'DAQmxReadDigitalU32';
I think nidaqxm_laz.7z file, uploaded to this forum thread, have some errors.
In case of TaskHandler could be normal interger variable, but also a integer pointer. You can choose.
« Last Edit: January 09, 2015, 02:12:16 pm by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #46 on: January 11, 2015, 12:56:25 am »
Hi, mig-31

I'm very thankful to you.
I could move 2 of your sample program 'devicelist''diport' in latest NIDAQmx.

Thanks.
« Last Edit: January 12, 2015, 01:22:54 pm by tonbo »

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #47 on: January 12, 2015, 05:12:20 pm »
Hi, tonbo

Today I made nidaqmx bindings (h2pas) by myself and tested it on deviceinfo and diport programs. Of course it needed to change some parameters to pointer variable. You can find it in attachment.

Before translation I wrapped all lines down to 200 chars. Divided nidamx.h on two parts: first one with consts and second with functions. I also removed all macros.
I don't know why, but key -w doesn't work in h2pas =Remove all __CFUNC and __CFUNCC in function declaration and made comment in lines with __CFUNCC.
After it I replaced all cdecl to stdcall convention. Found all comments near functions with __CFUNCC and replaced stdcall by cdecl. It very important, because GUI program crashed, when function is called with wrong convention.
stdcall is Windows specific. 
« Last Edit: January 14, 2015, 01:32:23 pm by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #48 on: January 13, 2015, 02:36:01 am »
Hi, mig-31

I'm thankful for the valuable advice and new nidaxmx.pas.

First, I check the operation of your sample programs in new nidaxmx.pas.
Please wait for several days.

Next, I'll try a h2pas change with your advice.

I'm looking forward to it.

Thanks.

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #49 on: January 18, 2015, 01:21:04 am »
Hi, mig-31

I tested your sample programs.

Environment
  Windows7, 32bit (It isn't 64bit.)

Result
(a)nidaqmx.pas, nidaqmx_const.inc
   OK!
   That doesn't need correction.

(b)Sample programs
  Several correction is needed as follows.
  But those are a trivial thing. It isn't a problem.
  Those changes are indicated in "//change".

.Addition of @ is needed.
 channelnames[0] -> @channelnames[0] etc

.DAQmxxxxxDigitalU8, U16 aren't supported.
 DAQmxReadDigitalU8 -> DAQmxReadDigitalU32
 DAQmxWriteDigitalU8 -> DAQmxWriteDigitalU32

.A program doesn't stop.
 DAQmx_Val_RSE -> DAQmx_Val_Cfg_Default

Nidaqmx.pas for windows is very effective.
I'd like to utilize by various situations from now on.

Thanks.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #50 on: January 20, 2015, 11:30:02 am »
Hi, tonbo
It good to hear that pascal bindings is good.
I tested your sample programs.
Environment
  Windows7, 32bit (It isn't 64bit.)
I also tested it under Windows and Linux 32-bit.
DAQmxxxxxDigitalU8, U16 aren't supported.
 DAQmxReadDigitalU8 -> DAQmxReadDigitalU32
 DAQmxWriteDigitalU8 -> DAQmxWriteDigitalU32
It depend on card digital port. Some cards have 32bit digital port, other one 8bit or 16bit or both 32bit and 8bit. You must use an appropriate function to operate digital port.
DAQmx_Val_RSE -> DAQmx_Val_Cfg_Default
It is strange, because by this constant you set, how you electrically connect your signal.
DAQmx_Val_Cfg_Default = DAQmx_Val_Diff.
Probably, you should check card documentation. There is a page from manual for my card about signal connection.
Nidaqmx.pas for windows is very effective.
I'd like to utilize by various situations from now on.
Of course it more effective, than Labview, especially when you need to modify source code.

Mostly, I checked examples under Linux 32bit and win32 with old  bindings. And all examples are the same, but with newest bindings it needs correction in code by adding @.
I think it will be better to add notes on wiki for using it with win32?

Thanks for checking.
« Last Edit: January 20, 2015, 11:42:30 am by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

tonbo

  • New Member
  • *
  • Posts: 11
Re: NIDAQmxBase header translation
« Reply #51 on: January 22, 2015, 12:22:44 pm »
Hi, mig-31

Thank you very much for your reply.

> It depend on card digital port.

I understand.

> There is a page from manual for my card about signal connection.

I'm thankful for your kindness.
I have read "X Series User Manual NI 632x/634x/635x/636x/637x Devices".
I understand.

> I think it will be better to add notes on wiki for using it with win32?

I think it's better when there are notes.

ps:
Sample program aichan was missing.
Sorry.
Only 1.
  DAQmx_Val_RSE -> DAQmx_Val_Diff

Thanks.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #52 on: February 16, 2015, 06:08:57 pm »
NI DAQmx example of data acquisition on analog input starts by digital trigger.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

CM630

  • Hero Member
  • *****
  • Posts: 1081
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: NIDAQmxBase header translation
« Reply #53 on: February 17, 2015, 09:09:56 am »
It is worth to mention, that many DAQs do not have analogue triggers, but only digital.
It means that according the triggering front selected, the trigger is actuated either when voltage becomes higher than 2,7 V or lower than 2,3 V.

Лазар 3,2 32 bit (sometimes 64 bit); FPC3,2,2; rev: Lazarus_3_0 on Win10 64bit.

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #54 on: February 17, 2015, 09:55:46 am »
I don't know if very low cost NI DAQmx can't configure one analog input channel as analog trigger, but for example M-series does using function DAQmxAnglEdgeStartTrig.
 
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #55 on: February 27, 2015, 10:40:42 am »
I have added a new example to Wiki - start analog channel acquisition by the digital signal.
« Last Edit: March 12, 2015, 12:39:05 pm by mig-31 »
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

mig-31

  • Sr. Member
  • ****
  • Posts: 305
Re: NIDAQmxBase header translation
« Reply #56 on: June 19, 2015, 10:32:05 am »
Hi, all

I have added hardware- and software-timed analog output examples on wiki.

Thanks Jean-Claude for testing its on NI US-6003 card.
Lazarus 2.2.6 - OpenSuse Leap 15.4, Mageia 8, CentOS 7

 

TinyPortal © 2005-2018