12-04-2018 06:59 AM - edited 12-04-2018 07:01 AM
Hi everyone,
I'm using Advantech USB-4704 as a replacing card for our current A/D card which has gone EOL.
Advantech is only "officially" supporting LabWindows, but since they have ANSI_C examples, I have been looking into them.
Except for one line, which i replace everything else seems to be supported:
//wcscpy(devInfo.Description, deviceDescription); strcpy(devInfo.Description, deviceDescription);
The code runs perfectly using Visual Studio 2017, but not CVI 2015SP1.
Could someone help me out to get this to work with LabWindows?
Or is there another approach that is better? Thinking of maybe wrap the example that builds in VS2017 and export the DLL to CVI?
I have attached both VS2017 and CVI example, where one works and one fails.
You would need to install Advantech SDK to make it work, I assume (http://downloadt.advantech.com/download/downloadsr.aspx?File_Id=1-1MENNIH).
Thanks
Solved! Go to Solution.
12-06-2018 12:25 PM
Dear I have the some things do you solved please ?
12-06-2018 03:08 PM
Hi, I manage to solve my problem.
I used the example code for C++ and built a "wrapper-dll" that I now can use.
12-06-2018 03:22 PM
Thank’s for your reponse dear
Can you bring to me the dll that you built and the exemple which helped you to do it
12-07-2018 01:26 AM
I have uploaded both the Visual Studio example and LabWindows example where we use the DLL/Wrapper.
Welcome!
12-11-2018 09:31 AM
Dear viktor_morin,
Please I want to use the USB-5856 board for my application "with inductive input sensors and actuators such as pneumatic output valves".
So I must use the Read/Write DI and Read/Write DO can you tell me which finction I will need for my application from the bdaqctrl.h
cordially,
12-12-2018 01:29 AM
Hi again,
The wrapper (DLL) I made for my project looks like following:
#include <stdlib.h> #include <stdio.h> #include "stdafx.h" #include "bdaqctrl.h" #include "compatibility.h" #include "AdvantechWrapper.h" using namespace Automation::BDaq; #define deviceDescription L"USB-4704,BID#0" const wchar_t* profilePath = L"USB4704.xml"; const int32 analogInputstartChannel = 0; const int32 analogInputchannelCount = 1; const int32 analogOutputchannelCount = 1; InstantAiCtrl * instantAiCtrl; InstantAoCtrl * instantAoCtrl; InstantDoCtrl * instantDoCtrl; extern "C" { __declspec(dllexport) void Initialize() { DeviceInformation devInfo(deviceDescription); instantAiCtrl = InstantAiCtrl::Create(); instantAoCtrl = InstantAoCtrl::Create(); instantDoCtrl = InstantDoCtrl::Create(); instantAiCtrl->setSelectedDevice(devInfo); instantAoCtrl->setSelectedDevice(devInfo); instantDoCtrl->setSelectedDevice(devInfo); instantAiCtrl->LoadProfile(profilePath); instantAoCtrl->LoadProfile(profilePath); instantDoCtrl->LoadProfile(profilePath); } __declspec(dllexport) void Dispose() { instantAiCtrl->Dispose(); instantAoCtrl->Dispose(); instantDoCtrl->Dispose(); } __declspec(dllexport) void ReadAnalogInput(int channel, double *value) { instantAiCtrl->Read(channel, *value); } __declspec(dllexport) void WriteAnalogOutput(int channel, double *value) { instantAoCtrl->Write(channel, *value); } __declspec(dllexport)void WriteDigitalOutput(int channel, int *value) { instantDoCtrl->Write(channel, *value); } }
So you should use similar, just change the deviceDescription to your card. You won't need the xml-profile if default settings is okay for you. When I the DLL inside my applicaiton, just take a look at the sample i provided before (LabWindows example project), but more or less, I load the DLL and then execute wanted functions. Just start with Initialize().
Cheers
09-01-2022 10:27 AM - edited 09-01-2022 10:30 AM
Hi Viktor
Try this:
memcpy(devInfo.Description, "USB-4751L,BID#1", 15);
or this:
mbstowcs(devInfo.Description,"USB-4751L,BID#1", 15); // 15 = sizeof("USB-4751L,BID#1")
cheers.