Showing results for 
Search instead for 
Did you mean: 

Event structure variable problem


I’m a dutch student bachelor electrical engineering. We have to make a sorting system witch can sort out lego peaces (this are plastic block’s of different color and shape). We have a webcam mounted above a belt witch transports the lego. At the end of the belt the lego is swept of the belt by some servo’s. The control of the servo’s is done by a PIC microcontroller. The communication will also be done by this PIC by RS-232. The PIC microcontroller will send a ‘1’ or ‘0’ to labview (by RS-232) when it detects a object, it toggles the value that has send before. When this toggle has occurred labview has to take one frame from the webcam and than analyse it in the recognition unit (which I left away for a better overview). We cannot analyse every frame because the system would get to slow. In the main vi we have created three while loops. We have done this to create 3 threads that can run simultaneous so the system is faster. Now the real problem.
The problem is that when the while loop with the serial communication in it receive a ‘1’ or ‘0’ (current value changes) the event structure won’t run. We tried every thing we could imagine to let it work. We created a shift register in the while loop, a local variable, placed the event structure without while loop, placed the event structure together with the Read bytes at port in the same case but nothing worked. The solutions we tried resulted in different results, some didn’t let the system run at all, some a part. We have to work with the toggle value because of the PIC program. Is there a way to make the Boolean ‘object sensor’ some kind of variable that can let the event structure work? We have choosen for a event structure because a event structure finishes al the code that is in it and than stops. I hope there is someone on this forum that can help us because we are running out of time. We searched the forum but could not find something which could help us. If we have missed a topic which contains the answer we are sorry. I have attached a stripped (in according to our real application) vi with the webcam and serial communication in it and one without them so the vi can be runned. The font-panel is a bit chaos but that's because this is striped version. I hope someone could help us with this problem. If there are any other fault's in it we would like to hear it, we are reasonable new to labview. I hope I could make our problem clear. Thanks in advance.

With kind regards,
0 Kudos
Message 1 of 5
I'm sorry but I forgot the attachment and could not see a button to edit my previous message. So I put it in an reply.
0 Kudos
Message 2 of 5
The event structure will not trigger by a simple programmatic value change (writing to e.g. indicator, local variable, value property). It is primarily designed to handle operator events of the front panel.

If you want to trigger a value changed event, you need to write the new value to a property node of your boolean set to Value(signaling).

See attached image.

(btw: you can edit your post for a limited time via the options menu in the upper right of the porst)

Message Edited by altenbach on 06-12-2005 02:23 PM

Message 3 of 5
A few more comments:

You don't need an event structure in a seperate loop, I would use a simple shift register for the boolean as in the attached image to see if the value has changed.

Also (see image):
- You should not create a new visa session from scratch at every iteration, you can do it once outside the loop.
- many of your formatting and comparison operations can be simplified significantly.
- You only check once for errors, then switch three different sequential case structures with the same boolean. This is equivalent of combining the three cases into one. You should check for new errors after each case structure. This is easiest done by wiring the error cluster to the case selector terminal.
- There probably should be a small wait statement in the loop so it plays nice.

I'm sure the code will run much better this way.
Message 4 of 5
Hi altenbach,

Thank you so much. We were getting desperate but your reply helped us a lot. I'm not able to test it with the whole hardware but only with my other PC for RS-232 commication but it seems to work perfect. I can't test it with the whole hardware before wednesday but I think we solved the problem.
I have one other question. We use IMAQ Vision for our picture analysis. When we run the main vi with the by IMAQ Vision generated subvi's in it we sometimes get the message as in the attachment. I occurs only sometimes. We can push continue and than the systems works. Do you know how to fix this?
Thanks for your answers, our system is much faster at the moment and it finally works.

Message Edited by J-W on 06-13-2005 02:47 PM

0 Kudos
Message 5 of 5