LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Doubt in event structure

Solved!
Go to solution

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

0 Kudos
Message 1 of 11
(2,740 Views)

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.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 2 of 11
(2,717 Views)

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

0 Kudos
Message 3 of 11
(2,700 Views)

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.


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
(2,685 Views)

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.

_____________________________
- Cheers, Ed
0 Kudos
Message 5 of 11
(2,672 Views)

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 ? 

0 Kudos
Message 6 of 11
(2,635 Views)
Solution
Accepted by topic author kumuch

Here is an example. Sorry the diagram is a bit untidy.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
Message 7 of 11
(2,608 Views)

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

0 Kudos
Message 8 of 11
(2,570 Views)

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 

0 Kudos
Message 9 of 11
(2,558 Views)

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.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 10 of 11
(2,548 Views)