From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way for read and write?

Solved!
Go to solution

Hello

 

I'm working on project with labview .

with this program i connecting PC to the MCU through sreial RTU modbus .

in this program there are some data need to be read and some data need to write .

 

what i need is most of my time reading polet exuted exept when some of  control element (like edit box) has changed by user .

when ever some thing changed by user write polet excuted .

 

now what is the best way to do this ?

 

Best Regards.

0 Kudos
Message 1 of 11
(3,329 Views)
Solution
Accepted by topic author mori64

Event Structure inside of a While loop.  With the event structure, you detect the changing of values and send the appropriate commands.  You could use the Timeout case for reading the status from the MCU.


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 2 of 11
(3,319 Views)

Thanks crossrluz

 

I did it but with this way  while loop's stop button dosen't work ! 

 

Best regards

 

0 Kudos
Message 3 of 11
(3,303 Views)

Code?  It is impossible to debug your application without it.


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 4 of 11
(3,300 Views)

sorry you are right .

 

 

0 Kudos
Message 5 of 11
(3,283 Views)

It works for me.  Granted, I had to remove all of the Modbus communications in order to run it.  Are the statuses taking a long time to come in?  I would also recommend using an event case for the stop button.


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 6 of 11
(3,272 Views)

Here is a good "rule" that will help your LabVIEW coding -- NEVER use a Stacked Frame!  If you want to do a multi-step procedure on a set of variables, use a State Machine, a While loop inside of which is a Case Statement, with something wired to the Case Selector that "steps" you through the various steps.  Use Shift Registers on the While loop to pass the variables seamlessly from one Case to the next (none of these "the wire goes out on this edge and pops back in over there" guesswork with Stacked sequences).  Note that you can also use a For loop and wire the Loop Index to your Case Selector to do Steps 0, 1, 2, 3 (you'll need to add a "default" case in this model).  Here is a snippet, where the Enum has been given the less-than-descriptive names "Step 1", "Step 2", etc.  If using a While, wire the last Case to the Stop indicator, of course.

 

Here is a Very Simple example.

(Very) Simple State Machine.png

Bob Schor

Message 7 of 11
(3,268 Views)

Thanks 

 

I think my USb->Serial had problem after restart my pc my code work too.

 

this is  my Secend project with labview.  i'll be happy if you have any comment about my code .

 

best Regards .

 

0 Kudos
Message 8 of 11
(3,264 Views)

Thanks Bob 

 

What uou said sound complicated to me .

i'm trying to undrestand your solution .

i'll be happy if you upload sample program .

 

 

0 Kudos
Message 9 of 11
(3,250 Views)

mori64 wrote:

What uou said sound complicated to me .

i'm trying to undrestand your solution .

i'll be happy if you upload sample program .


State Machine


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 10 of 11
(3,245 Views)