LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA serial Read is not giving consistent output

Hello 

 

I am using VISA serial communication VIs in LabVIEW 2016.

I open the COM port and Write to Serial port using VISA Write. I have added termination character CR to my Write string.

I do not get error.

Then I give a delay and Read data using VISA Read vi. I wire bytes at port property node to VISA Read bye count input. 

I do not get error. But I get output of VISA Read vi as Blank most of the times and sometimes I get some characters as output sometimes. Why does this happen? Please let me know.

Thank you

0 Kudos
Message 1 of 7
(2,802 Views)

1.  No VI attached for us to see what you are doing.

2.  No name of what device you are trying to talk to.

 

That is like calling the repair shop saying your car won't start, what is wrong?  Then not even telling them what brand of car it is.

 

Bytes at Port is the wrong thing to use 99% of the time.

 

For a good tutorial on good methods to talk to a variety of devices, look at CrossRulz's recent presentation VIWeek 2020/Proper way to communicate over serial

0 Kudos
Message 2 of 7
(2,798 Views)

@Hemagopal wrote:

I open the COM port and Write to Serial port using VISA Write. I have added termination character CR to my Write string.

I do not get error.

Then I give a delay and Read data using VISA Read vi. I wire bytes at port property node to VISA Read bye count input. 

I do not get error. But I get output of VISA Read vi as Blank most of the times and sometimes I get some characters as output sometimes. Why does this happen?


What is the serial port connected to?  What is it's data format protocol?  Are you sending a valid command?  Are you using the settings (Baud Rate, parity, data bits, handshaking, etc.)?  These are just my starter questions when it comes to serial communication issues.  And each of these often lead to a myriad of more questions.

 

But I have macros set up for just this kind of occasion...

DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)

Why?  Go here to find out: VIWeek 2020/Proper way to communicate over serial


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 7
(2,727 Views)

Hello,

The device we are using to communicate is Long range communication antenna connected to COM port. User is using Teraterm tool to communicate.

These are the commands

sendln 'ATZ'
pause 5

sendln 'AT+TCONF=868000000:14:125:7:4/8:1:1'
pause 1

sendln 'AT+TPING=50'
pause 1

 

which I am giving in VISA write. 

Instead of pause, I used wait timer and added CR 

 

VI is attached.

Thank you.

0 Kudos
Message 4 of 7
(2,716 Views)

I see you are using LabVIEW 2016.  I just down-converted my example code so you can look at it.  Again, you really need to go through the presentation.  It will likely solve most of your issues (the main reason I gave the presentation in the first place).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 7
(2,706 Views)

Check your termination character.  I see it is a control on the front panel that says 0D.  Right click on the control and make the Display Style visible.

It says it is in normal style, that means you are sending a literal "0" and "D".  Not the single byte with a value of 0D hex.

 

That should not be a control, but a constant.  And I would just add it to the end of the write commands rather than doing an explicit concatenation.

 

But to start with, change the display style to hex.  Then retype in 0D

Message 6 of 7
(2,703 Views)

@Hemagopal wrote:

 

VI is attached.

Thank you.


Oh my... Besides what everyone else has said...

 

  1. Remove the Flat Sequence Structure.
    1. It's superfluous (think data flow)
    2. Use the Error Cluster wire to force sequential operation
    3. Use the "Time Delay" vi in the Error Cluster for time delays 

                   TDCapture.PNG

Instead of One Big Loop consider a simple State Machine architecture. 

 

========================
=== Engineer Ambiguously ===
========================
Message 7 of 7
(2,685 Views)