Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Replace Teraterm using CP210x with labview

Hi,

 

I'm having some problems with the CP2101 driver. I have already manage to set up a connection to my machine using Teraterm and the virtual COM-Port, but the connection with labview wasn't successful yet.

 

I wrote a vi initializing the connection with the serial.llb (Serial Port Init.vi) and changed it a little, so I can set the mask to 48. I read somewhere, that buffer should be high enough, so I set it to 10000.

 

Initializing the com port and writing to visa (Serial Port Write.vi) run without an error code, but when reading the com port the message is empty. Between writing and reading out the bytes I've implemented a 200ms delay.

 

My write string is the same command I'm using in Teraterm. Is that wrong and that's why my machine does not respond?

 

Thanks for your help!

0 Kudos
Message 1 of 16
(7,904 Views)

You should not be using Serial Port Init or Serial Port Write. They are old and obsolete. How did you even find those and not use the functions on the Serial palette?

 

Since you do not provide the command you are sending, impossible to say what might be wrong. Are you appending a termination character? What is the exact driver and where did you get it from?

 

0 Kudos
Message 2 of 16
(7,892 Views)

Hi,

 

the driver is teh CP2101 from Silicon Labs (silabs.com) and can be used for all kind of puposes. It allows you to use a physical USB connection through a virtual COM-Port. The manufacturer of my machine also gave me the Teraterm Pro, so I can use some commands eg for requesting actual data ("alldata") from the machine controller. the controller responds with a list of all sensor values, each value in one line.

 

I'd like to replace all the actions in Teraterm and use labview instead. labview should request "alldata" and read out the response.

 

I changed now all the visas with the ones from the actual pallette (Instr/_visa.llb). This includes:

 

Configure Serial Port (no further settings)

Set I/O Buffer Size (buffer=10000, mask=48)

Visa write (String=alldata)

wait (200ms)

Property node (bytes at port)

Visa Read

Visa Close

 

When running the vi the byte count is zero, therefore the Visa Read complains with the error code 1073676294. I also tried 50ms and 500ms waiting times. Using a fix amount of bytes greater zero when reading leads to the same error code.

 

I assume the machine does not answer to my request, either because Teraterm usually adds something to the manually typed request command, or..well, I don't really know.

 

 

0 Kudos
Message 3 of 16
(7,878 Views)
0 Kudos
Message 4 of 16
(7,876 Views)

I'm really trying hard to understand the Visas, but something's not working well. I installed the HDD Fre Serial Port Monitor, which tracks all the traffic and data communicated with a serial port. The write command sends the right telegramm, but visa read does nothing (see attachment)

 

I noticed, that many other serial port vis dont use a timeout between write and read, some use a fix number of bytes at Visa read instead of first reading it out.

 

 

 

 

0 Kudos
Message 5 of 16
(7,871 Views)

You have not provided the manual to the instrument. I asked what termination character you are using. You apparently don't know what a termination character is. I would suggest appending a CR/LF. The basic serial example does this by enabling '\' Code Display in the string control and using \r\n. Try this or different combinations.

0 Kudos
Message 6 of 16
(7,866 Views)

I'd love to provide a manual, but all I have is the CP2101 driver, the Teraterm Pro Terminal and a list of commands I can call. Therefore a have no idea what termination character is necessary.

 

I attached some screenshots of the relevant Teraterm settings.

 

What does Teraterm do after I type in the command and I hit enter? What termination character could it possibly add? All combinations with \r, \n, and ? were not successful.

Download All
0 Kudos
Message 7 of 16
(7,855 Views)

TerraTerm is sending a CR/LF. Why haven't you posted the code you are using? If you are using one of the shipping examples, which one?

0 Kudos
Message 8 of 16
(7,844 Views)

I can call functions like "alldata", "analogs", "digitals" and so on which in Teraterm lead to the machine responding accordingly.

 

As you could see in TT1.jpg the settings are CR, the other choice Teraterm is giving me is "CR+LF" (TT4.jpg).

 

See attached how I tried it (lv1.jpg)..With the setting being "CR", would the String just be "alldata\r"? Didn't work, just like every other combination..

Download All
0 Kudos
Message 9 of 16
(7,839 Views)

All I see is an image - not an actual VI. And sorry, I mispoke about tera term. It seems it is only sending a CR (a \r).

 

Instead of trying to write your own code at this point, first use one of the shipping examples. Start with Basic Serial Write and Read.vi. This has a front panel control with '\' Codes Display enabled so you would enter 'alldata' followed by a \r.

0 Kudos
Message 10 of 16
(7,828 Views)