05-03-2024 06:58 AM
Hi
I´m working on a sofware which will read out the metering data from a smart meter, throught the built-in serial port. This data will be written and saved to a txt file. However, this Vi works exactly as predicted in highlight execution, but in normal mode it either does nothing, or saves some invalid data.
The first VISA read loop works fine (in either mode), and I´m fairly certain that the second VISA read loop seems to have some issue. I´ve tried adding a delay to the second read VISA function but, then i lost a lot of data.
I´m new to Labview, so don´t hate too much :D.
Every help would be appreciated.
Thanks
05-03-2024 07:07 AM
File -> Save for previous -> LV2017 or something and reupload. I can't open the code.
However, from the description i'll bet a beer that it's a race condition or possibly a resource conflict. You have 2 parallell loops? Do they read the same Com port? If so, it's probably locked.
Otherwise it's probably the feared race condition that's very easy to get into. Unless execution order is forced through wires you have no idea in which order stuff executes and strange effects can happen.
05-03-2024 07:12 AM
Something may be wrong with timings, probably your device is slow and not able to respond properly at fast execution without highlighted execution.
As the very first step for investigation may be just put delays before and after each comm command, "simulating" slow highlighted execution, then remove or decrease step by step.
Finally once you will found root cause you should have no delays, and the code should be functional with clear "handshakes", because if you will leave some delays, it may sometimes works and sometimes not.
05-03-2024 09:25 AM - edited 05-03-2024 09:25 AM
I can't see your code because I don't have the latest edition.
The most common cause of a failing program running fine in highlight execution mode is a race condition in your code.
05-03-2024 09:47 AM
Exactly what device are you trying to communicate with? I'm seeing conflicting concepts in your code, so I'm not sure what the messaging protocol is even based on.
As others have stated, if it only works with highlight execution being on, you have some kind of race condition. Again, I can clean this up quite a bit if I knew the messaging protocol of the device.
05-03-2024 12:39 PM
Hi
I saved it in 2017 version of labview as you requested.
Hopefully you can open it now.
05-03-2024 12:44 PM
Hi
I´ve already tried something similar, but I lost data in the process, so I abandoned this aproach. The first VISA read cycle seems to work just fine. Anyway, thanks for the help.
05-03-2024 12:56 PM
Hi
The smart meter in question is the EMH LZQJ. I have very limited info about the specific protocol it uses, however it should use the standard RS485 serial communication and it´s associated protocols.
Thanks
05-03-2024 01:19 PM - edited 05-03-2024 01:19 PM
Hmmm.... I don't understand how this works at all.
I question your termination characters
In the VISA Serial setup you set the termination character to 1 that's the ASCII control character SOH.
Is this correct?
A line feed, '\n' carriage return '\r', or both '\r\n' is most commonly used for a termination character.
Also you do not have and termination characters on the commands you are sending.
Turn on the '\' Codes display on your concatenate string and there are no \ codes in your string.
returns the string 060020D0A with no termination character in between commands.
05-05-2024 02:04 PM
Yes, the termination character is SOH.
Thanks