Hi, I've been trying to interface with a device that has a USB chip from Silicon Labs (CP210x USB to UART Bridge). I've got DLLs from the website and VIs (not officlal or recognized bi Sillicon Labs) to interface with it. I am trying to use CP210xRuntime and CP210xManufacturing (DLLs) but I have not been succesful so far. I can interface succesfully with the device when it is connected for the first time, however if I try to run the code again the connectaion is lost so I suspect I am not closing the session with the device correctly. I would like to know if anyone has had any success interfacing with these kind of devices using LabVIEW, if so... How did you do it and which libraries, drivers or VIs were used to get connection? Thank you.
Here's a basic construct:
First, we open the connection. Then we write a message to the device. The appropriate syntax is specific to your device. We wait 100ms for a response, and if there's bytes at the port, wait another 100ms (in case your message hasn't completely come in yet) and read in the exactly the number of bytes that are at the port. The response is usually in ASCII. After, we close the connection (this is what you missed) and handle error. I attached the VI for you to look at.
You can also use the "Find Examples" menu in LabVIEW, look for "VISA" or "Serial".
There is a driver from Silicon Labs which installs this USB device as Virtual COM port under Windows. After that you can use NI-VISA to access this COM port just like a physical COM port in the way as shown by ijustlovemath.
However, use of the Bytes at Serial Port is almost always the wrong thing to use when you communicate with a device. Most serial devices use a text based protocol with a specific termination character (carriage return or line feed) and then you need to configure VISA to use this termination character as end of message indicator and after that you can simply issue a VISA Read with the number of bytes to read greater than the longest message you expect. VISA Read will return at any of these conditionst:
- The requested number of bytes has been received
- The end of message character has been received
- an error has occured
- the timeout specified for this session has elapsed
Hi ijustlovemath and rolfk, thank you so much for your response.
I've tried with VISA and I currently have the drivers needed (they're called CP210x VCP for Windows -or something live that-). But when I try the select the COM port (the device appear as Sillicon Labs CP210x USB to UART Bridge (COM4)) the VISA resource control/constant does not show any COM ports and If I write the COM4 myself I get the following error: VISA: (Hex 0xBFFF0012) Invalid resource reference specified. Parsing error. Any ideas why this could be happening? Thank you.
First run NI MAX (Measurement and Automation Explorer) at least once. Try if it sees the new COM port. If it doesn't show up press F5 to refresh the device configuration once more. Until the COM port shows up in NI MAX, NI-VISA will not be able to access it.
Hi rolfk, it does not appear in NI MAX and I know it should appear but it just does not. I've used VISA before but with GPIB and it was really easy, I understand this device is differente but I talked to other people and consulted different forums and the VCP should be accessible, I might be missing something but I am not quite sure what it is.
This is what I've done so far.....
Install VPC drivers for Sillicon Labs device
Try to get the device to show up on MAX
Try dlls from Silicon Labs
Check for device functionality with software from Sillicon Labs and with the software the device comes with (it works)