LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Vi works in highlight execution but not in normal

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

 

0 Kudos
Message 1 of 11
(312 Views)

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.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 11
(309 Views)

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.

Screenshot 2024-05-03 14.09.05.png

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.

 

0 Kudos
Message 3 of 11
(306 Views)

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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 11
(250 Views)

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.


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
0 Kudos
Message 5 of 11
(240 Views)

Hi 

I saved it in 2017 version of labview as you requested.

Hopefully you can open it now.

0 Kudos
Message 6 of 11
(217 Views)

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.

0 Kudos
Message 7 of 11
(214 Views)

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

0 Kudos
Message 8 of 11
(212 Views)

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.

 

errrrrCapture.PNG returns the string 060020D0A with no termination character in between commands.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 11
(203 Views)

Yes, the termination character is SOH.

Thanks

0 Kudos
Message 10 of 11
(137 Views)