Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linking to gpib-32.dll with NI 488 drivers (MinGW)
Forum Updated to NodeBB v4.3 + New Features

Linking to gpib-32.dll with NI 488 drivers (MinGW)

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 955 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MrShawn
    wrote on last edited by
    #1

    Hi, I wanted to make this post in hopes that it helps others in the future.

    To start I found the following links:
    http://alex.mellnik.net/application-notesusing-nis-gpib-drivers-in-qt/
    https://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Access-ni4882-dll-with-Qt-and-MinGW/td-p/1985471?profile.language=en

    Ultimately they were helpful but I believe I found a much simpler solution.

    First thing is obviously install the NI 488(.2) drivers. I believe you want to make sure you have the .net support packages. To be safe on my end I shot-gunned the installer and said to install everything.

    Check that you now have the following files, if not reinstall with more options/updated versions:
    C:/Program Files (x86)/National Instruments/Shared/ExternalCompilerSupport/C/include/ni488.h
    C:/Windows/SysWOW64/gpib-32.dll
    //At this point I hope whoever is trying to do this has a solid handle on dynamic linking.

    Onto Qt.
    You need to make sure you have the 32 bit mingw compiler/binaries. gpib-32.dll is 32 bit so 64 bit program will not work.
    Make sure when you configure your kit for the project it is a 32 bit version with the 32 bit compiler etc.

    As for the project itself, I used the qmake build system. I am less familiar with the CMake despite it being the new de facto in Qt 6. (If anyone knows the equivalent lines in cmake I would greatly appreciate as I am working diligently on that transition.)

    In your .pro file, add these lines. It will tell the project where to find the ni488.h header and to look for the dll in the SysWOW64 folder.

    INCLUDEPATH += "C:/Program Files (x86)/National Instruments/Shared/ExternalCompilerSupport/C/include"
    LIBS += "C:/Windows/SysWOW64/gpib-32.dll"
    

    For convenience here is a simple main program demonstrating some usage.

    #include <QCoreApplication>
    #include "windows.h"
    #include "ni488.h"
    #include <QThread>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        while (1)
        {
            int handle = ibdev(0,18,NO_SAD,T10s,1,0);
            char buff[150];
            ibwrt(handle,const_cast<char*>("*TRG"),4);
            QThread::msleep(250);
            ibrd(handle,&buff,150);
    
            QString string(buff);
            foreach (auto component, string.split(","))
            {
                qDebug() << component.simplified().toDouble();
            }
        }
    
        return a.exec();
    }
    

    Important things. PUT windows.h BEFORE ni488.h!!

    Before you shred my code, this was very quick toss together to proof of concept, nothing more. The keys are that it demonstrates ibdev, ibwrt, and ibrd commands. From this it can now be easily dumped into a simple handler class and built out into something far more sophisticated.

    I also had already sent the SCPI commands to configure the device. You do not see those in this code.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved