06-11-2013 04:45 AM
Hello all,
I am developing one application for my instruments which is user interfaced.i am new to make architecture in VI. In my program i am using Producer and consumer architecture, case structure and event structure. In this program first four frame are working properly but fifth frame of case structure is not responding well. i attached my program so please view it tell me the solution what i did wrong?.
Thanks in advance
Solved! Go to Solution.
06-11-2013 05:43 AM
Hello,
You have made a start but I think it needs a lot of work.
I am sorry to say this, your program is an abuse of while loops and event structures. One of the loop contains producer/consumer implementation but I think it can be simplified much more. I admit, I don't know the details of your final application, but I still think it can be simplified. LabVIEW is a data flow language and this can be easily achieved by wiring error clusters when available, so please use that.
Set your Boolean controls to Latch when pressed mechanical action and use the value change event instead of Mouse up. Ensure that your Boolean control is inside that particular case and a lot of your trouble will go away. But please consider redesigning your application, it will serve you well in the long run. One thing you can be proud of, you haven't used flat sequence structures.
06-11-2013 06:29 AM
Yes it is a skeleton of my application only, I considered my fault I am new one to develope application by using architecture so suggest me which way is good ? In my program objective is control the two stepper motor by using labjack
1. In 1st frame of case structure, subVI will check whether instrument is connected or not
2. In 2nd frame, Instrument license checking program will come
3. In 3rd frame, user need to give some details regarding samples so I used to pop up on there
4. In 4th frame, I need run motor1 alone, motor2 alone and both motor run at same time which is depend upon user input so I am using producer and consumer architecture
5. in 5th frame, I gave two option such as start fresh and quit. I would like to make if user press the start fresh button, program will start from first frame and if user press the quit button, it will move into sixth frame and come out from the while loop and program finish.
But I am Not able to press the start fresh and quit button when the program is entering into the fifth frame. So run the program which is attached in the previous post and see the difficulties and give me the suggestion for this problem.
For this application if anyone give another logic also I will accept it., I am willing to learn and I would like to develope robust code
thanks in advance
06-11-2013 07:02 AM
Having multiple event structures in a VI is generally a major red flag. You should probably have a separate loop just for handling the event structure. You can use a queue to send data to your state machine from the event loop.
06-11-2013 07:19 AM
Take a look at the Events producer/consumer template VI. New... -> From Template -> Producer/Consumer Design Pattern (Events)
Expand that template to include your functionality
It is unlikely that you will need to use a 'value' prioperty node for what you are trying to do
As noted, queues are a many-to-one data synchronisation tool, you should only have one dequeue VI
Use one Event structure in each VI
Your encasing case structure [pardon the pun] is unnecessary, and using separate producer and consumer loops will remove this case structure.
06-11-2013 09:36 AM
Thank You for reply all
Dear yenknip,
1.IS it correct to use two architecture in one VI ?
2.according to your suggestion , In my program I changed queues into notifier which is one to many synchronasation tool. whether it is correct or wrong ?
3.If i am using value change event for my control, two times event will happend such as on and off state
I already mentioned my task i think this logic may be simple if i remove encashing case structure, how can i run my program from frame one to sixth without using case struture ?
06-11-2013 11:02 AM
Here is an example. Sorry the diagram is a bit untidy.
06-12-2013 01:04 AM
Dear ace,
You gave a very nice simple program with same logic. your program is too good, i learned many new things from your program and i will upload my final program after i finsh my whole application. please view it and send me the comments thank you lot
06-12-2013 03:49 AM
Dear aCe,
I need some clarifiaction regarding your architecture which you posted in the last message
My application requirements are following given below
1.whether Instrument is connected or not ?
2..Check the licence validity of the instrument once when start the program
3.I need to get some details from user
4.Two stepper motor are here. so i gave the option such as forward and reverse for both the motor which can rotate depend upon the user input. i would like to make if user press motor1 forward button, the motor1 will rotate in clock wise direction , if user press motor1 reverse button, motor1 will rotate in anticlockwise direction and same logic for motor2 also.
for my above 4th point requirement producer/consumer architecture is more than enough but i would like to make if user want to run motor2 while motor1 is running. we are using queue connectivity so motor2 will start to rotate after stop the motor1 so for this case i feel producer/consumer architecture is not sufficent shall i move onto master/slave architecture? one master and two slave
5.After completing the four requirement i can give two option such start fresh and quit from program if user press start button, it will start from first point nad if user press the quit button, program will quit
06-12-2013 05:12 AM
Hello,
If you look at the program, it loads an initiliase state to the queue right at the begining. Which inturn loads the instrument check and License check states. So you should be able to do 1 & 2.
You can have two consumers if you wish, you just have to have two different queues but I dont think that is necessary. I am not sure how your motor works but you can use http://zone.ni.com/reference/en-XX/help/371361H-01/glang/enqueue_opposite_end/ to add priority messages so that they execute first as well.
Hope this helps.