07-27-2022 12:59 PM
Hello, I am doing a VI to communicate via serial with a inverter using ASCII telegrams standardized by the manufacterer. I already tried bytes at port, for loops, while loops, connecting in series and in parallel, among other solutions I saw on this forum. I was expecting a return string everytime I send a write, but my read keeps reading the previous "write" command and doesn't show any return. How can I solve this and how can I know if it is a inverter or a labview problem.
I will attach the inverter manual too so you can know the protocol (topic 8.13).
07-27-2022 01:09 PM - edited 07-27-2022 01:14 PM
Hi Luigi,
@luigimiotti wrote:
I already tried bytes at port, for loops, while loops, connecting in series and in parallel, among other solutions I saw on this forum.
Using BytesAtPort is not recommended.
But you even did it worst: placing BytesAtPort inside a FOR loop with a wait function. Iterating 5 times and using only the value of the last iteration!? Why not wait 5*100ms and call BytesAtPort only once???
Before you do anything more with this VI you should carefully watch this video (even more than once)!
More comments on your VI:
07-27-2022 01:50 PM - edited 07-27-2022 02:27 PM
Thanks for your tips, I started this project from complete zero and it just became a megazord of lots of projects found. Actually I have a update, I tried both "simple serial" and "continuous serial" example vi's and on both of them my inverter returned exactally the same code I sent. This means the problem is on the inverter?
And I tried to put the exact amount of bytes I expect from read but then nothing works on my code anymore. The I put the read in a while loop with delay and one iteration but the same problem remains. How can I correctly do it?
07-27-2022 05:07 PM
@luigimiotti wrote:
Hello, I am doing a VI to communicate via serial with a inverter using ASCII telegrams standardized by the manufacterer. I already tried bytes at port, for loops, while loops, connecting in series and in parallel, among other solutions I saw on this forum. I was expecting a return string everytime I send a write, but my read keeps reading the previous "write" command and doesn't show any return. How can I solve this and how can I know if it is a inverter or a labview problem.
I will attach the inverter manual too so you can know the protocol (topic 8.13).
Your inverter uses a MODBUS interface. While MODBUS is inherently serial (one bit at a time on the physical layer) it has some specific features required to exchange information with "Coils" and "Registers" at the "Address" of the target.
Reading a register requires a different "command code" than writing a "Coil". There are MODBUS libraries available to help! But, you will need to learn from reading manuals, help files and internet searches.
And yes, I did once Architect a DES lab with that inverter as one of many possible ones.
07-28-2022 04:47 AM
@luigimiotti ha scritto:
I was expecting a return string everytime I send a write, but my read keeps reading the previous "write" command and doesn't show any return.
This suggests that you are using a RS485 interface with ECHO enabled, that is what you send is also echoed to the serial input buffer. Usually there is a way to disable ECHO on such interfaces (this function may have a different name). In case this is not possible, your program should be aware that any answer will be prepended by the sent command.
Another option is, as already suggested, to enable the Modbus protocol and use a suitable communication library.
07-28-2022 05:47 AM - edited 07-28-2022 06:34 AM
Please can you include a screen shot of the block diagram?
(I cannot open the VI because I am running an earlier version of LabVIEW.)
Are you using RS485? and/or an RS232 to RS422 / RS485 adapter?
The TX and RX lines of an RS485 bus are the same.
If the connector has separate TX and RX terminals, there is also usually some switches or jumpers that connect the TX and RX lines together.
If the TX and RX lines are connected together, you can expect to receive back the data that was sent.
You can either deactivate the receiver during transmission or perform a double read.
07-28-2022 06:26 AM
Considering that much have been said, i would like to send 2 links from my youtube channel that i uploaded recently on how to use modbus library with LabVIEW, even though the videos are in portuguese, you may contact me from comment section that i will be happy to help.
Como fazer um multimedidor de energia utilizando PZEM 004T no LabVIEW comunicando Modbus RTU
https://www.youtube.com/watch?v=YhC4yg3O58Y
Medição de energia com LabVIEW utilizando Raspberry Pi e PZEM com rede Modbus RTU e Hobbyist toolkit
https://www.youtube.com/watch?v=ja2TWlfPCUE
regarding your code, i recommend a different architecture, maybe a producer consumer with events to read and write from your inverter.