LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Advantech (USB-4704) for LabWindows

Solved!
Go to solution

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

0 Kudos
Message 1 of 8
(4,767 Views)

Dear I have the some things do you solved please ?

0 Kudos
Message 2 of 8
(4,738 Views)

Hi, I manage to solve my problem.

I used the example code for C++ and built a "wrapper-dll" that I now can use.

0 Kudos
Message 3 of 8
(4,728 Views)

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 

0 Kudos
Message 4 of 8
(4,724 Views)
Solution
Accepted by topic author viktor_morin

I have uploaded both the Visual Studio example and LabWindows example where we use the DLL/Wrapper.

Welcome!

0 Kudos
Message 5 of 8
(4,712 Views)

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,

0 Kudos
Message 6 of 8
(4,640 Views)

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

0 Kudos
Message 7 of 8
(4,622 Views)

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.

0 Kudos
Message 8 of 8
(2,162 Views)