From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-16-2016 03:22 AM
Hi,
I try to write a VI for an USB Relay card (USB Interface: Silabs CP2104). Sadly, befor using the available CP210xRuntime.DLL´, you need to call CreateFile function (windows.h) where I struggle with getting a handle.
I tried writing an own .DLL where I call this function in and just start it over LabVIEW but I only get the ERROR 0xC0000005 (with disabled Error in the dll node) or 0x449 (enabled Error in dll node).
I have a c++ programmed test program vom Silabs which works fine, also I programmed my own c++ programm which also works fine, but I want to use the Relay card in an existing VI where I need to call the CP210xRuntimeDLL with that windows COM-Handle.
I also tried to get a communication over MAX, but I don´t know which Commands to use so I didn´t get any reaction from the device. An attempt of a serial Communication over VISA was also not successful.
Google is no help, I find plenty of people with the same Problem, but noone seemed to get it done saying how?.
Hope someone has an idea.
Thanks!
Greetings from Germany
Jooris
12-19-2016 07:39 AM
I solved the problem. If anyone is interested in LabVIEW communication withe the Conrad 39 39 05 4x USB Relais card, here is my VI.
03-29-2018 03:07 AM
10-01-2019 08:40 AM
Due to a Version Conversion request, I am adding a version that has been converted to LabVIEW 2012.
10-01-2019 10:02 AM - edited 10-01-2019 10:04 AM
That VI will sooner or later crash as the call to the CP210xRT_GetPartNumber() function passes an empty LabVIEW string handle to the function whereas this function absolutely positively never ever will be able to deal with a LabVIEW string handle. Even if it doesn't crash it corrupts memory anyhow.
The extra DLL to wrap CreateFile() is a noble approach but pretty much overkill too.
A better approach would be this (attached VIs are in 2009 format):
10-31-2019 04:15 AM
Very happy to read you guys were able to get this card to work with LabView. I tried your VI and indeed a handle is assigned. Thanks!
Next step, however, is still a bit of a mystery to me; how to actually control the board? I see the commands in the manual, but I don't know how to send these. I guess this is something trivial that I'm not getting?
Hope anyone of you can help - many thanks in advance!
11-13-2019 10:27 AM - edited 11-13-2019 10:31 AM
You will need to use the Call Library Node to call the function CP210xRT_WriteLatch() function in the CP210xRuntime.dll.
This function will need to be configured as follows:
Library Name: CP210xRuntime.dll
Function Name: CP210xRT_WriteLatch
calling convention: stdcall
return value: int32
1st parameter: handle, pointer sized integer, pass by value
2nd parameter: mask, 8 bit unsigned integer, pass by value
3rd parameter: value, 8 bit unsigned integer, pass by value
The first parameter is connected to the handle value that comes from the Conrad_4x_Relaiskarte_USB_StartUp.vi.
The second variable defines which channels should be modified, with one bit per relay and the least significant 4 bits are used.
The third variable defines if the relay should be closed (bit cleared to 0) or if the relay should be opened (bit set to 1).
Only the relays are changed for which the bit in the mask is set to 1.
You can also read back the current relay settings by calling the function CP210xRT_ReadLatch().
Library Name: CP210xRuntime.dll
Function Name: CP210xRT_ReadLatch
calling convention: stdcall
return value: int32
1st parameter: handle, pointer sized integer, pass by value
2nd parameter: value, 8 bit unsigned integer, pass pointer to value
The first parameter is connected to the handle value that comes from the Conrad_4x_Relaiskarte_USB_StartUp.vi.
The second value will return after a call the current setting of the relays in the lowest significant 4 bits.
For both functions you also should evaluate the return value. If it is not 0, there was an error and the function was not successful.