06-11-2020 01:03 PM
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
06-11-2020 01:16 PM
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.
06-12-2020 05:19 AM
@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
06-12-2020 09:43 AM
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.
06-12-2020 10:14 AM
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).
06-12-2020 11:00 AM
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
06-12-2020 01:24 PM - edited 06-12-2020 01:26 PM
@Hemagopal wrote:
VI is attached.
Thank you.
Oh my... Besides what everyone else has said...
Instead of One Big Loop consider a simple State Machine architecture.