* * *

Author Topic: FreePascal bindings for National Instrument oscilloscope/digitizer cards  (Read 8051 times)

mig-31

  • Full Member
  • ***
  • Posts: 208
Hello all,
I opened this topic because there is no subforum for Automation and Measurement.

National Instruments provide ANSI C headers for library NI-Scope for working with their oscilloscope/digitazer cards, for example NI PCI-5122 http://sine.ni.com/nips/cds/view/p/lang/cs/nid/13309.

NI-Scope for Windows http://www.ni.com/download/ni-scope-4.1.3/4598/en/
NI-Scope for Linux http://www.ni.com/download/ni-scope-3.1/1633/en/

I discovered C headers (approx. 5 files) and its have macros and some other definitions, which need deeper C knowledge.
From my side i can also propose bindings testing on real harware, because we will have two NI PXI-5122 card this year or at the start of New Year.

I think it will be good to create binding for FreePascal.
« Last Edit: December 19, 2014, 01:45:43 pm by mig-31 »
Lazarus 1.6 - Linux 32/64 bit, win32

Laksen

  • Hero Member
  • *****
  • Posts: 584
    • J-Software
Well where are the C headers? Are they just a raw VISA register interface, or maybe an IVI driver interface?

If it's just the VISA(visa.h and visatype.h) headers plus a header for the register table in the specific card then you can find a conversion of the VISA headers here: https://github.com/Laksen/FP-VISA

mig-31

  • Full Member
  • ***
  • Posts: 208
It Ivi driver interface.
From my discovering it six C headers files:
ivi.h
IviScope.h
niScope.h
visa.h
visatype.h
vpptype.h

The most problem is how to convert macros:
its do something or not?
remove all of them?
terrible stringification? >:(


If it's just the VISA(visa.h and visatype.h) headers plus a header for the register table in the specific card then you can find a conversion of the VISA headers here: https://github.com/Laksen/FP-VISA

Two of them you have already translated.

Well where are the C headers? Are they just a raw VISA register interface, or maybe an IVI driver interface?
I don't know if I can upload C headers here, due to copyright restrictions?
« Last Edit: December 04, 2014, 09:13:52 am by mig-31 »
Lazarus 1.6 - Linux 32/64 bit, win32

Laksen

  • Hero Member
  • *****
  • Posts: 584
    • J-Software
IviScope sounds like it could be used from IVI-COM. The other headers are probably for a IVI-C interface

If you are on windows you should be able to generate that a header for IVI-COM with importtl. Just run it on the DLL that NI supplies and you should have an autogenerated IVI-COM wrapper right away without the need for the VISA header stuff

mig-31

  • Full Member
  • ***
  • Posts: 208
What is importtl?
I can't find this tool
Lazarus 1.6 - Linux 32/64 bit, win32

Laksen

  • Hero Member
  • *****
  • Posts: 584
    • J-Software
It should come with fpc. At least it does in SVN trunk

mig-31

  • Full Member
  • ***
  • Posts: 208
Thanks, I will try it.

Did you convert visa.h and visatypes.h by partly using h2pas utility or just manually?
Lazarus 1.6 - Linux 32/64 bit, win32

Laksen

  • Hero Member
  • *****
  • Posts: 584
    • J-Software
I used Chelper and some manual fiddling

Paul Breneman

  • Full Member
  • ***
  • Posts: 208
    • Control Pascal
I hope to add information from these messages to this page: http://controlpascal.com/

The Comedi page (http://controlpascal.com/comedi.htm) has similar material.
Regards,
Paul Breneman
www.ControlPascal.com

mig-31

  • Full Member
  • ***
  • Posts: 208
It will be good, but now we only have binding for NI-VISA, not complete NI-Scope. Thanks for @Laksen.
And also comedy drivers are not supported NI oscilloscopes/digitazers. I hope, yet.
Lazarus 1.6 - Linux 32/64 bit, win32

mig-31

  • Full Member
  • ***
  • Posts: 208
Re: FreePascal bindings for National Instrument oscilloscope/digitazer cards
« Reply #10 on: December 04, 2014, 03:53:37 pm »
I have a problem to convert this part form ivi.h, because i don't what it is

#define IVI_VAL_NAN             (*Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NAN))
#define IVI_VAL_PINF            (*Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_PINF))
#define IVI_VAL_NINF            (*Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NINF))


It looks like macro to pointer of function
Lazarus 1.6 - Linux 32/64 bit, win32

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5183
Re: FreePascal bindings for National Instrument oscilloscope/digitazer cards
« Reply #11 on: December 04, 2014, 04:05:18 pm »

Quote
Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NAN)

run that macro or function, which returns a pointer.

The asterix then dereferences that pointer. (

So  literally it is
Code: [Select]
{$define IVI_VAL_NAN   := (Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NAN)^)}

though while possible, making it a macro doesn't make much sense in Pascal.

mig-31

  • Full Member
  • ***
  • Posts: 208
Re: FreePascal bindings for National Instrument oscilloscope/digitazer cards
« Reply #12 on: December 04, 2014, 04:50:35 pm »
Thank,
I think so.
Code: [Select]
{$define IVI_VAL_NAN   := (Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NAN)^)}
Ivi_GetPtrToSpecialViReal64Value - function, IVI_VAL_TYPE_NAN -parametr and defined in other header

I check it not used in other parts of header and other headers.

Only for understanding, can we rewrite it using constant variable like
Code: [Select]
var
  IVI_VAL_NAN:Pointer=Ivi_GetPtrToSpecialViReal64Value(IVI_VAL_TYPE_NAN)^;
Lazarus 1.6 - Linux 32/64 bit, win32

mig-31

  • Full Member
  • ***
  • Posts: 208
Re: FreePascal bindings for National Instrument oscilloscope/digitazer cards
« Reply #13 on: December 08, 2014, 02:02:47 pm »
Still I don't know if I can upload here C headers to NI-Scope driver.
Lazarus 1.6 - Linux 32/64 bit, win32

mig-31

  • Full Member
  • ***
  • Posts: 208
Re: FreePascal bindings for National Instrument oscilloscope/digitazer cards
« Reply #14 on: December 08, 2014, 02:12:39 pm »
Hi, all

there are Pascal bindings for NI-Scope 14.0 driver for Win32 (probably works with Win64) and NI-Scope 3.1 fo Linux 32-bit.
Not tested on real hardware.

Simply add niscope.pas to your project to test it with your hardware. You can find information how to work with it in ANSI C examples, which are distributed with NI-Scope driver.
I hope, when I have real hardware, I will upload some basic examples in Pascal. Without real hardware, I think there is no sense to rewrite some ANSI C examples to Pascal.
There is a good guard to make first steps with NI-Scope on National Instruments web http://www.ni.com/white-paper/3382/en/

Linux version probably works only for linux kernel 2.6.x, which still supported https://www.kernel.org/ and used in RHEL5,6, Scientific Linux 5,6 (supported until 2017) and old distributions like Mandriva 2006 or Suse Linux.

Bindings are in the attachments.

« Last Edit: December 11, 2014, 11:08:24 am by mig-31 »
Lazarus 1.6 - Linux 32/64 bit, win32

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus