Jump to content

problem with while loop


Recommended Posts

Hi all,

I am novice in Labview! I ve just started to work and learn it a month ago. I would like to create a program to pump system which is controlled by a lynx4 microcontroller what I can program through serial port! I did a vi for this purpose (with your help :worship: )

Everything is in a while loop to run it continously and I can stop things in the same time.

my case structure (which send the command to through the serial port to the controller) is also in the while loop. The problem is this ... becouse it is in the loop it is send the command continously (the pump is not stop after finishing a task) but when i put the case structure out of the loop (nothing changes) it still run again continously (i think because the lines came from the structure go into the loop ---but I am not sure)

So how can i make the case structure to send the commands only once?

thank you for your help in advance!

i attached pictures and the vi!!

I've got labview 5.1 and 7.1

post-5296-1150888248.jpg?width=400

post-5296-1150888266.jpg?width=400

Download File:post-5296-1150888281.llb

Link to comment
Hi all,

I am novice in Labview! I ve just started to work and learn it a month ago. I would like to create a program to pump system which is controlled by a lynx4 microcontroller what I can program through serial port! I did a vi for this purpose (with your help :worship: )

Everything is in a while loop to run it continously and I can stop things in the same time.

my case structure (which send the command to through the serial port to the controller) is also in the while loop. The problem is this ... becouse it is in the loop it is send the command continously (the pump is not stop after finishing a task) but when i put the case structure out of the loop (nothing changes) it still run again continously (i think because the lines came from the structure go into the loop ---but I am not sure)

So how can i make the case structure to send the commands only once?

thank you for your help in advance!

I have changed your VI to:

1 Initialize the Serial Port outside the main loop.

2 Added a Send Command button which you hit once you have selected which command to send and the params for it. The command is only sent when you click this button.

3 Replaced your Action I32 with a Enumerated Type. This allows you to see what the action that is taking place.

4 During the first execution of the VI, the Initialize command is automatically sent. Subsequently, you can re-initialize by hitting the Initialize button.

You should really look at a State machine architecture to clean up your code.

Init State>Monitor State>Monitor State. If any change in button values >Send Command State>Read Serial State>back to Monitor...

Somethign like that.

Neville.

PS your uploaded example is missing Serial Read.vi and Serial Write.vi but no matter, you get the idea from my changesDownload File:post-2680-1150911420.vi

Link to comment
I have changed your VI to:

1 Initialize the Serial Port outside the main loop.

2 Added a Send Command button which you hit once you have selected which command to send and the params for it. The command is only sent when you click this button.

3 Replaced your Action I32 with a Enumerated Type. This allows you to see what the action that is taking place.

4 During the first execution of the VI, the Initialize command is automatically sent. Subsequently, you can re-initialize by hitting the Initialize button.

You should really look at a State machine architecture to clean up your code.

Init State>Monitor State>Monitor State. If any change in button values >Send Command State>Read Serial State>back to Monitor...

Somethign like that.

Neville.

PS your uploaded example is missing Serial Read.vi and Serial Write.vi but no matter, you get the idea from my changesDownload File:post-2680-1150911420.vi

WOOW!!

Thank you for your help!!!

:worship:

Link to comment
WOOW!!

Thank you for your help!!!

:worship:

Thank you again, it should work with labview 7.1 I could run the vi (at home), but could not check with the pump because, at my work we use labview 5.1 which as I saw has no first call? option...

Could you suggest me some other opportunities how to solve it in 5.1?

Link to comment
no first call? option...

You can create your own first call VI fairly easilty - just make a Boolean-based functional global and initialize it to true when you first start your software. Then have a case that checks the value and if it's true then change it to false and report back that it is the first call - if it's false, leave it false and report back that it isn't the first call. I can put something like this together pretty quickly if you are having problems...

Link to comment
You can create your own first call VI fairly easilty - just make a Boolean-based functional global and initialize it to true when you first start your software. Then have a case that checks the value and if it's true then change it to false and report back that it is the first call - if it's false, leave it false and report back that it isn't the first call. I can put something like this together pretty quickly if you are having problems...

Yes, thanks! During lunch time I was thinking about the problem and found the same disposal what you suggested!

It is work!

thanks so much

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.