Lazarus

Programming => Packages and Libraries => Lazarus Extra Components => Topic started by: wimpie on November 10, 2009, 07:14:46 am

Title: NIDAQmxBase header translation
Post by: wimpie on November 10, 2009, 07:14:46 am
Hi,

Has someone made a translation of the National Instruments DAQmxBase header file? I want to use the USB DAQ devices in linux.

Thanks
Title: Re: NIDAQmxBase header translation
Post by: wimpie on November 26, 2009, 05:44:26 pm
If someone is interested, the translation is attached.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 21, 2012, 07:47:43 am
It would be nice, if there was some demo, working with this.
I have tried (Antillasoft's solution (http://antillasoft.com/main/en/mndescargasen/21-catdownloadscomponents/catdownloadscomponentspascal/39-pgdescargascomponentslazarusnidaqmx)), but its source is closed.
Title: Re: NIDAQmxBase header translation
Post by: chor on December 23, 2012, 06:11:17 pm
I am trying to use the Antillasoft's solution, but it will not link because of version mismatch. I am using Lazarus 1.1, do anyone know the work around? :)
Title: Re: NIDAQmxBase header translation
Post by: chor on December 26, 2012, 11:22:40 am
Is nidaqmxbase.pas.zip version specific? Will I be able to use it with the latest NI libraries? What are the requirements to use it under Ubuntu 12.04?
Any chance of a demo sample?  :D
Title: Re: NIDAQmxBase header translation
Post by: CM630 on June 10, 2013, 02:04:30 pm
MX means, that it should be used with the latest NI daqs.
It's another question if nidaqmxbase.pas.zip is good for anything.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on June 19, 2013, 09:53:44 am
So, here is the story:
1. I have read a post by a NI staff member (or got the same impression), that NIDAQmxBase has problems even with VC++ and VB6, and that some people had success in running NIDAQmx in Delphi. So we should better forget about the BASE version and use NIDAQmx.

2. Finally I came across that (https://github.com/chandranorth/RTSPM).
I took two files from there: NIDAQmxCAPI_TLB.pas and nidaqmx.pas and fixed one of them a bit (removed three brackets).
So a working snippet is attached to the post.
It is running on Lazarus 1.1; SVN revision 40379; FPC version: 2,6,1 on Windows XP.
I have installed the latest NIDAQmx, I think it is 9.7.0. A file named nicaiu.dll shall be in the c:\windows\system32 folder.
The snipped works with a virtual DAQ NI PCI-6052E. I still have not tested it on a real one.

3. BTW, I tried to contact Antillasoft on the email, but it was returned to me buy the mail server. I suppose they are defunct.

EDIT: There is a bug in the snippet. I will update it when I have the time, but so far
line    DAQmxError:=DAQmxReadAnalogF64(taskHandle,SamplesPerChannel,10,{DAQmx_Val_GroupByScanNumber}DAQmx_Val_GroupByChannel,@DAQData[0],SamplesCount,@SampsPerChanRead,nil);

shall become
   DAQmxError:=DAQmxReadAnalogF64(taskHandle,SamplesPerChannel,TimeOut,{DAQmx_Val_GroupByScanNumber}DAQmx_Val_GroupByChannel,@DAQData[0],SamplesCount,@SampsPerChanRead,nil);
where
Code: [Select]
var
Timeot: double'
begin
...
TimeOut:=SamplesPerChannel/RefreshRate+1;

+1 seems to be enough for me, but I am not sure if it does not depend on the PC.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on June 17, 2014, 02:38:21 pm
Any other news about it in this topic?

I think it better to use NIDaqmx Base, because this library is crossplatform compare to NIDAQmx, which is now supported only under Windows  >:(
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 10, 2014, 01:23:38 pm
Hi,

I tested both pascal binding for NIDAQmxBase under Linux and NIDAQmx  under Windows on real NI hardware NI PCI-6250 and NI PCI-6244 and it works:
1) NIDAQmxBase 3.7, Scientific Linux 6.3 and Mageia 2 32-bit:
    hadrware clocked and software controlled analog inputs - works,
    software controlled digital input/output - works,
    digital input/output clocked by internal counter output signal - works, but limited to 2047 samples of card buffer,
    hadrware clocked and software controlled counter output - works,
    software controlled counter input works - limited by CPU speed, DMA is not implemented in the driver
This year National Instruments planes to release 64-bit version of NIDAQmxBase. LabView2014 64-bit released this year.
2) NIDAQmx 14.0 Windows 7 32-bit
    all hardware futures are work, without limition in NIDAQmxBase.

Read readme to check limitaton of NIDAQmxBase driver.
I attached a small test project, which I created for testing and learn working with hardware and then implemented it to my measurement-data logging application:
Created and tested  on Lazarus 1.2.2, NIDAQmxBase 3.7, Scientific Linux 6.3 and Mageia 2 32 bit. 
Probably it could be useful for others, who want to use Pascal for NI measurement harware instend of C and horrible LabView.
 
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 10, 2014, 02:31:10 pm
I gave it a glimpse.
Do you intend to rewrite the lib references for dynamical linking?
If you don't I will, but I have no idea when  :-X

Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 10, 2014, 02:53:04 pm
I didn't make any changes on pascal bindings for NIDAQmxBase and NIDAQmx.
I'm primary interested on using NI hardware under Linux.

I read (I'm not sure), that dynamic linking don't work good on FreePascal.

Do you test pascal bindining on real hardware - you wrote above that tested it only on virtual card? If yes, which cards?
We also have PXI system with two counters cards NI PXIe-6612. I plans to tested nidaqmx.pas on it.


Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 10, 2014, 03:58:59 pm
We use NI and Measurement Computing (MCC a NI company) DAQs with Lazarus.
I have headers for dynamic linking for MCC devices. I have a problem with some calls of several functions but still I am not sure that the problem is in Lazarus and I have not reported it as a bug.
Still I have not uploaded it, because it is not fully complete, but if someone needs to use MCC devices with Lazarus, I will take my time to.

We have a measuring device, which might be a PXI, but I personally don't use so I have written nothing for it.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 10, 2014, 05:12:13 pm
On this time, I'm not interested on MCC devices, because we make a dission to use National Instruments hardware.
But I'm suprised, that they provide good linux support.
We also have one Labview licence for Windows and Linux and I can compare results, but LabView horrible for big application creation.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 10, 2014, 05:30:04 pm
Btw, in latest MCC drivers there is some support for Android, I suppose NI have too.
We use NI for PCI devices and MCC for USB.
Static linking requires that all drivers by all kinds of DAQs shall be installed. That is why it is a huge problem, when writing SW supporting devices by multiple manufacturers.
And BTW one day you might come to the idea, that you can get better performance and price if you order a device designed and manufactured especially for you.
I have really huge experience with LabView, 10 years ago it still was something impressive, but I doubt it made any progress since then. Some two years ago I was told that it still has no zoom in/out abilities.
But, I still have no proper replacement for LV's graphs.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 12, 2014, 07:22:21 am
I'm primary interested on using NI hardware under Linux.
Are you sure that NIDAQmx does not work on Linux and only NIDAQmxBase works on it?
As far as remember, I found the  NIDAQmx bindings in a project for Linux.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 12, 2014, 06:42:31 pm
A new version of NIDAQmx doen't support Linux. Only NIDAQmx 8.0.2 exists for Linux and run under Linux distribution with kernel 2.6.x, actually long time supported Red Nat Linux 6 and it clones CentOS 6 and Scientific Linux 6. It works with Labview, but i didn't discover it with C examples.
A last version of NIDAQmxBase 3.7.0 supports newer linux distributions, like OpenSuse, with kernel around 3.3.x.

I'm primary interested on using NI hardware under Linux.
Are you sure that NIDAQmx does not work on Linux and only NIDAQmxBase works on it?
As far as remember, I found the  NIDAQmx bindings in a project for Linux.
Is the so library name of the last Linux NIDAQmx the same as in Windows nicaiu?
Could you upload pascal bindings for NIDAQmx for Linux to this topic (NIDAQmxCAPI_TLB.pas have ActiveX dependence in uses part )?
Thanks
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 16, 2014, 08:47:31 pm
Is the so library name of the last Linux NIDAQmx the same as in Windows nicaiu?
 


 nicaiu does not sound familiar to me though I might have seen it. Any way I did not understand your question.
Could you upload pascal bindings for NIDAQmx for Linux to this topic (NIDAQmxCAPI_TLB.pas have ActiveX dependence in uses part )?

I have posted the link a few posts above (http://forum.lazarus.freepascal.org/index.php/topic,7894.msg123938.html#msg123938)  :D Here is the same link (https://github.com/chandranorth/RTSPM).
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 18, 2014, 08:58:25 am
Hi,

nidaqmx_snippet.7z  includes NIDAQmxCAPI_TLB.pas, which has in uses section ActiveX. ActiveX doesn't support under Linux. 
Also nidaqmx.pas is a bindings for nicaiu.dll (system32), not for nidaqmx32.dll on Windows 32-bit.
I discovered only NIDAQmxBase under Linux. It installs only nidamxbase.so library and nidaqmxbase.h=nidaqmxbase.pas (uploaded above in this topic).
I will try to install older linux driver NIDAQmx 8.0.2 and discover C header files.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 19, 2014, 07:58:07 am
Hm, I looked at the page (https://github.com/chandranorth/RTSPM) again and I start wondering why did I consider it a Linux project. Maybe I have tried to run it under Windows. And maybe I was wrong to think that is was a Linux app !?

nidaqmx_snippet.7z  includes NIDAQmxCAPI_TLB.pas, which has in uses section ActiveX. ActiveX doesn't support under Linux. 
 


The  nidaqmx_snippet.7z  is made by me for Win, using the libraries from https://github.com/chandranorth/RTSPM (https://github.com/chandranorth/RTSPM). And the the ActiveX statement is commented there (https://github.com/chandranorth/RTSPM/blob/master/NIDAQmxCAPI_TLB.pas).
 

Also nidaqmx.pas is a bindings for nicaiu.dll (system32), not for nidaqmx32.dll on Windows 32-bit.
 

Actually, I did not understand, do you need bindings for nicaiu.dll or for nidaqmx32.dll?
As I have written, my snippet requires nicaiu.dll.

 

Some of our DAQs are manufactured in 2002 and as far as I have understood they won't work with nidaqmxbase so I cannot afford spending time in that direction. If you are making software for your company only, Base libs might be fine, but if you mean wider usage, maybe you should avoid them.


Edit: I just found out that that I have made a .pas for dynamic linking of nicaiu.dll and it seems to work. I will try to upload it somewhere next week.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 29, 2014, 09:35:19 am
Quote
Actually, I did not understand, do you need bindings for nicaiu.dll or for nidaqmx32.dll?
As I have written, my snippet requires nicaiu.dll.
Hi,
I tried bindings for nicaiu.dll and it works. It able me to work with NI hw under Windows.

Question is if you tried NIDAQmx under Linux with the last verison NIDAQmx 8.0.2 http://www.ni.com/download/ni-daqmx-8.0.2/2322/en/ (http://www.ni.com/download/ni-daqmx-8.0.2/2322/en/). Probably NI was stopped develop it. I think your bindings for Windows probably works with it.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 29, 2014, 10:05:13 am
Have you seen that: What Linux Distributions Do National Instruments Drivers and Software Support? (http://digital.ni.com/public.nsf/allkb/4857A755082E9E228625778900709661)
I have no experience with these distros so I cannot be helpful in the recent future. I'd rather spend some time on running a DAQ on Android, but I have no Android device and all our USB DAQs are MCC  :D
Maybe you should start a NI Linux thread, which might attract more Linux aware persons.


Edit: Yesterday I tried to install NIDAQmx and NIDAQmxBase on Ubuntu, but I did not succed. It probably means that I'm done with NI+ Linux.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on September 30, 2014, 09:22:51 am
I am interested on only pascal bindings.
I asked about pascal bindings on, like ANSI C headers, on NI Forum, but nobody answer on it.

Quote
Edit: Yesterday I tried to install NIDAQmx and NIDAQmxBase on Ubuntu, but I did not succed. It probably means that I'm done with NI+ Linux

Generally NIDAQmx or NIDAQmxBase are for rpm Linux distributions and NIDAQmxBase supports kernels around 3.3.x, NIDAQmx 8.2.0 supports only old kernel 2.6.x. On newest Ubuntu you can't install it.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on September 30, 2014, 12:09:20 pm
Generally NIDAQmx or NIDAQmxBase are for rpm Linux distributions and NIDAQmxBase supports kernels around 3.3.x, NIDAQmx 8.2.0 supports only old kernel 2.6.x. On newest Ubuntu you can't install it.
That's exactly what is says- "won't work on anything but 2.6.х".
I have no idea what you are using DAQs for, but maybe for Linux you'd like to try MCC devices. They generally have better drivers, they declare support for a wide range of linuxes and in their latest drivers they have some examples for Android. Also, their devices are cheaper, which is not insignificant- if you want to use a cheaper OS, you are likely to prefer cheaper DAQs, too. As far as HW is concerned- same low quality. I think most boards are assembled in the same factory in Hungary.
I could try to run a MCC device in Linux, if this will be useful for you.

Title: Re: NIDAQmxBase header translation
Post by: rs_ on October 31, 2014, 08:54:21 pm
I post here my work, the translated header file for NIDAQmx. It is the first version, but maybe it could be useful. In the future maybe I write an object wrapper around this, but for most applications this unit should work too.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on November 04, 2014, 09:35:17 am
That's exactly what is says- "won't work on anything but 2.6.х".
I have no idea what you are using DAQs for, but maybe for Linux you'd like to try MCC devices. They generally have better drivers, they declare support for a wide range of linuxes and in their latest drivers they have some examples for Android. Also, their devices are cheaper, which is not insignificant- if you want to use a cheaper OS, you are likely to prefer cheaper DAQs, too. As far as HW is concerned- same low quality. I think most boards are assembled in the same factory in Hungary.
I could try to run a MCC device in Linux, if this will be useful for you.
You are right and I see on MCC web that they provide better Linux support, but now I don't have any project where I could try there devices, but I'm interested for how it works under Linux.
In my case, choice of using Linux, based on fact that it generally more stable and secured.
Old kernel is not big problem for now, because RHEL 6 and there clones Cent OS 6, Scientific Linux 6 will be supported until year 2020. And I think the newest RHEL7 also supported by National Instruments.
The main problem is the difference between NIDAQmxBase and NIDAQmx. Generally, Windows is supported better.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on November 04, 2014, 09:57:01 am
News:
  1. NI PXIe-6612 can be operated using NIDAQmx pascal bindings under Windows;
  2. I created pascal NIDAQmx bindings for Linux 32bit, kernel 2.6.x and NIDAQmx 8.0.2 for Linux:
      http://www.ni.com/download/ni-daqmx-8.0.2/2322/en/ (http://www.ni.com/download/ni-daqmx-8.0.2/2322/en/) 
      Succefully tested with NI PCI-6250 card.
      I attached headers to this discussion.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on November 05, 2014, 11:16:14 am
Hi,

There are a some information about NIDAqmx library and NI DAQ harware in this topic. It wil be good to create wiki page about it. ::)
Title: Re: NIDAQmxBase header translation
Post by: BigChimp on November 05, 2014, 11:44:27 am
Good idea, looking forward to your contribution!
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on November 05, 2014, 02:19:12 pm
@BigChimp

Is it possible to add NIDAQmx and NIDAQmxBase bindings to freepascal sources as a library?
Title: Re: NIDAQmxBase header translation
Post by: CM630 on November 05, 2014, 02:40:57 pm
If you are asking if these libs can become a part of Lazarus/FPC and distributed with it- I am quite that the answer is no.
But you can create a LPK containing your files and create a project in Sourceforge or another repository. And you can list and document it in the Lazarus wiki.
For example I have created such a project (http://sourceforge.net/projects/ludmer/), which besides other items, should contain my DAQ bindings, but I have not started uploading to it.

Title: Re: NIDAQmxBase header translation
Post by: mig-31 on November 14, 2014, 07:00:59 pm
Hi,

I added some code examples to wiki there http://wiki.lazarus.freepascal.org/NI-DAQmx_and_NI-DAQmx_Base_examples (http://wiki.lazarus.freepascal.org/NI-DAQmx_and_NI-DAQmx_Base_examples).
I continue with code examples adding in next days: digital port input/output, counter.

I will be glad, if someone else check it or add something new.  ::)

There is one question, where we can store and maintain nidaqmx.pas and nidaqmxbase.pas
Title: Re: NIDAQmxBase header translation
Post by: tonbo on December 11, 2014, 02:00:51 pm
Hi, mig-31

I read your nice code examples.
We are waiting for your store.
Thanks.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on December 11, 2014, 03:30:48 pm
Hi,

I hope it will be useful for others.

We are waiting for your store.
I don't understand for what you are waiting for.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on December 11, 2014, 09:49:08 pm
Hi,mig-31

Thankful for your reply.

I want the "nidaqmx.pas" you used for "wiki code examples".
I'd like to confirm the movement of your examples.
Title: Re: NIDAQmxBase header translation
Post by: CM630 on December 11, 2014, 10:49:14 pm
Good job!
Or I suppose so, since I have not tested ;)
 
There is one question, where we can store and maintain nidaqmx.pas and nidaqmxbase.pas
SorceForge, for example (http://sourceforge.net/p/lazmer/code/HEAD/tree/trunk/daqlibs/).
I think my bindings for dynamical linking are there.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on December 15, 2014, 09:46:31 am
I want the "nidaqmx.pas" you used for "wiki code examples".
I'd like to confirm the movement of your examples.

I'm glad to hear it.
Could you test analog output? I will add an analog output example, but I don't have any hardware with analog output to test it.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on December 15, 2014, 09:48:38 pm
Hi, mig-31 and Paskal
I'm glad about your reply.

I'd like to confirm of all your examples.

Next...
Continuous sampling above 200kHz 10 seconds.
a: Analog 16bit Differential 3-ch sametime input.
b: A B Z Encoder input.

And...
c: a,b sametime input.

For a while, I have a NI USB-6356.

Thanks.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on December 17, 2014, 09:28:30 am
Hi,

It is nice to hear it.

I added NI USB-6356 to wiki.

I see, this card have 2 analog outputs. I will add example for analog output to wiki. Please test it.

Thanks.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on December 23, 2014, 10:07:05 am
Hi, mig-31

I fail at the first stage.

When I compiled your "devicelist" by arrangement of default, the next error occurred.
.nidaqmx.pas(61,109) Error: Type identifire expected
.nidaqmx.pas(61,109) Fatal: Syntax error. ")" expected but "CONST" found

( Line61: function DAQmxGetTaskAttribute(taskHandle:TaskHandle; attribute:longint; value:pointer; args:array of const):longint;cdecl;external External_library name 'DAQmxGetTaskAttribute';

109: array of const )

Environment
.Windows7 32Bit
.Lazarus Ver.1.2.6
.NI-DAQmx 14.0

I'm a beginner about
.Linux
.Lazarus...
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on December 28, 2014, 10:42:26 pm
Hi, Tonbo
I'm on vacation until 5-th of January. Out of work I use only Linux and I haven't any device. I check it after vacation.

From you description, I think you should check line before, if you have this symbol ")" or you have const word.

Upload you project in .zip here to check error without exe file.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on January 07, 2015, 08:29:22 am
Hi, mig-31

How was a vacation?
I have just taken short vacation days, too.

When you'll check it, I'm happy.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on January 07, 2015, 01:16:26 pm
Hi,
If you open nidaqmx unit, you see that nidaqmx in your project is for linux 32-bit.
If I replace it by nidaqmx Windows unit and try to compile your project I get a same error as you.
But when i create new program and copy/paste code, I compile it without error.
There is a zip project file.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on January 08, 2015, 03:42:42 am
Hi, mig-31

Thank you very much.
I moved safely and was shown as follows.
  -------------------------------------------------------------
  |Device name | Product Type | # Serial number | Is Simulated?
  -------------------------------------------------------------
  |Dev1 | USB-6356 (64 MS) | $015714C0 |No

5 hours have not passed yet from my UP.
It's miracle.

If possible, please tell me.
What kind of tool did you use? H2Pas?
I couldn't use it well.

I'll test your sample programs.
Please wait for some days.

Thanks.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on January 08, 2015, 01:36:11 pm
If possible, please tell me.
What kind of tool did you use? H2Pas?
I couldn't use it well.
Hi, tonbo
If you mean translation tool C headers to Pascal bindings, in our case nidaqmx.h to nidaqmx.pas, yes I use h2pas tool.
In case of nidaqmx.h, there are some issues: you should wrap lines with length more than 255 number of letters(chars) and remove C macros. I think, before translation I devided nidaqmx.h on three parts: part with constants definitions, part with function...
Usually I divide big C header on parts, befor translation.
For wrapping lines I use KWrite text editor under linux.
Title: Re: NIDAQmxBase header translation
Post by: tonbo on January 09, 2015, 10:18:20 am
Hi, mig-31

Thank you very much for your a lot of hints.
I'd like to try someday.

Now, I tested the 'diport' of your sample program.

Your original cord is the 'diport(original).zip'.
Several compile errors occurred by Windows7 32bit.
(Sorry, I can't deal with Linux.)

I rewrote the part of the cord and made them move.
Changed one is the 'diport(change).zip'.
Those changes were marked by '//change'.

Screen indication

  number of readed samples: 10
  data (0) = %00000000
  data [1] = %00000000
  data [2] = %00000000
  data [3] = %00000000
  data [4] = %00000000
  data [5] = %00000000
  data [6] = %00000000
  data [7] = %00000000
  data [8] = %00000000
  data [9] = %00000000

The easy explanation

(a)nidaqmx.pas

I changed it as follows according to the function of 'NIDAQmx.h'.

.function DAQmxCreateTask(taskName:PChar; var taskHandle:TTaskHandle):LongInt;stdcall;external External_library name 'DAQmxCreateTask';
 ->
 function DAQmxCreateTask(taskName:PChar; taskHandle:TTaskHandle):LongInt;stdcall;external External_library name 'DAQmxCreateTask';

.function DAQmxReadDigitalU8(taskHandle:TTaskHandle; numSampsPerChan:LongInt; timeout:Double; fillMode:Cardinal; var readArray:Byte;
           arraySizeInSamps:Cardinal; var sampsPerChanRead:LongInt; reserved:Pointer):LongInt;stdcall;external External_library name 'DAQmxReadDigitalU8';
 ->
 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';

(b)diport.lpr

'ATaskHandle' on the calling side is a Pointer.
So,

.procedure ErrorCheck(AError:longint;ATaskHandle:longint);
 ->
 procedure ErrorCheck(AError:longint;ATaskHandle:Plongint);

.if DITaskHandle<>0 then begin
 ->
 if DITaskHandle^<>0 then begin

Those change may not be best.

Thanks.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 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.
Title: Re: NIDAQmxBase header translation
Post by: tonbo 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.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 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. 
Title: Re: NIDAQmxBase header translation
Post by: tonbo 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.
Title: Re: NIDAQmxBase header translation
Post by: tonbo 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.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 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.
Title: Re: NIDAQmxBase header translation
Post by: tonbo 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.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on February 16, 2015, 06:08:57 pm
NI DAQmx example of data acquisition on analog input starts by digital trigger.
Title: Re: NIDAQmxBase header translation
Post by: CM630 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.

Title: Re: NIDAQmxBase header translation
Post by: mig-31 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.
 
Title: Re: NIDAQmxBase header translation
Post by: mig-31 on February 27, 2015, 10:40:42 am
I have added a new example to Wiki - start analog channel acquisition by the digital signal.
Title: Re: NIDAQmxBase header translation
Post by: mig-31 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.
TinyPortal © 2005-2018