mezga Posted June 21, 2006 Report Share Posted June 21, 2006 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 Download File:post-5296-1150888281.llb Quote Link to comment
Neville D Posted June 21, 2006 Report Share Posted June 21, 2006 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 Quote Link to comment
mezga Posted June 22, 2006 Author Report Share Posted June 22, 2006 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: Quote Link to comment
mezga Posted June 23, 2006 Author Report Share Posted June 23, 2006 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? Quote Link to comment
crelf Posted June 23, 2006 Report Share Posted June 23, 2006 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... Quote Link to comment
mezga Posted June 23, 2006 Author Report Share Posted June 23, 2006 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 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.