LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

local variable problem

I'm sorry to be a pain tst but I really can't get my head round what you so kindly explained.

Slightly ill and my brain is certainly not firing on all cylinders today!
0 Kudos
Message 11 of 14
(1,107 Views)
Michael,

You seem to misuse event structures solely as a way to get at the current and previous values of an indicator. This does not work! Events are only triggered by user interaction on the front panel (for good reason!), not by a programmatic change as you are trying to do (Well, there's also writing to signaling properties, but that's a different chapter ;))

To get previous values, a shift register is the way to go. A shift register is also a great way to store variables to be incremented, eliminating local variables.

I have dabbled around a bit in your VIs and it seem to me you are trying to do things way too complicated. Your two big loops in run.vi can be combined into one and one set of notifications eliminated. There is no reason to put two code segments into two different loops, then lock them together via notifiers, because they would execute synchronous via the notifier dependency anyway.

For efficiency, you should also worry a bit more about data types. Some if your subVIs require I16, but their inputs are set to DBL, then you feed it an I32 when you call it on the diagram (See for example your calls inside setup.vi).

Notice that inside setup.vi you are running three identical FOR loops in parallel. There is no reason to do so, because the called VI is not reentrant and thus can only be called sequentially anyway. You can combine it all in one FOR loop. Also the local variable is not necessary, the wire is right there.).

I've done some simple modifications (All Vis end in "01"), have a look and let me know if anything is not clear to you. Good luck! 🙂
There could be bugs, because I cannot test without your hardware. YMMV.
0 Kudos
Message 12 of 14
(919 Views)
Blimey - thanks for that! looks far more efficient I must add!

The only reason I was seperating everything is because on the device I am coding the VI for, I have identified 6 subsystems - and my tutor and I decided that to have 6 seperate while loops to house the code for each section would be good visually when it comes to the code being marked.

Along with these 6 subsystems, I planned to have another loop for input from the card, another for output to the card and then any surplus ones for other system tasks.

I can understand how this may then drop the overall efficiency, but it will still be a relatively small app, so there's not too much of an issue in my eyes.

I'd planned to lay it out as like a journey through the system

1) Chain Conveyor Area (Oh, BTW, I hadn't added code for that area yet!)
2) Sort Area
3) Conveyor Area
4) Assembly Area
5) Inspection Area
6) Reject Area

It's for this little beauty: http://www.bytronic.co.uk/ict1.htm

Maybe, instead of me trying to split everything up, I should just use block diagram containers to draw out sections, but still maintaining a relatively efficient setup with minimal loops?

For the InpVal, PortModeSet and SetBit subVIs, they were provided for me.

Going to take a good look at what you have done now and try to get my head round it fully - you're an absolute star - planning to go into Uni first thing and crack on! Will post back if i'm puzzled by anything!

Muchos thanks!
0 Kudos
Message 13 of 14
(909 Views)
A big thanks to everyone that replied, especially Altenbach - made some good progress today and understanding the concepts much more - so far the system is behaving! 😄
0 Kudos
Message 14 of 14
(895 Views)