04-17-2010 01:32 PM
04-17-2010 03:43 PM - edited 04-17-2010 03:47 PM
Your code is incompletely posted, referring to VIs scattered all over that are not included: E:\Take Home Work, HP34970a.llb, other VIs in the same folder, etc. Hard to make sense of it that way.
You say that "all 10 devices can be active at once", yet you have a single shift register that stores -THE- active device.
But when I try to add code in the "TimeCheck" case of the Producer loop things do not work.
--- I don't understand. The way I see it, the Producer is the upper loop, since it produces some sort of task-control cluster for the other loop to use.
The bottom loop looks for these clusters and executes them, therefore it is the consumer.
I see no code in the TIMECHECK case of the consumer.
--- You have a TYPEDEF for the control cluster definition - why in the world don't you use the names it provides? the BUNDLE BY NAME function would be clearer than just a BUNDLE.
I recommend a state-machine approach for each device.
Make a single CORE VI that handles ONE device, and stores all info needed about that one device in shift regs.
Make it re-entrant.
Make a "Master" that has the same inputs and outputs, but ALSO has a device-select input.
The master holds 10 copies of the CORE VI, and chooses which one to call based on the device-select input.
It's a WHOLE LOT less pain for you.
My blog has an entry for that : State of the Machine
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-17-2010 03:59 PM
WOW!
uhmmmm.... OK you need to add a lot of comments to your code- and look at the style guide. And YES- there is a lot of WEC in there (WEC- Wire equivalent code)
That being said the " TimCheck" state is the default state that you enter whenever the dequeue element function returns- Like when the queue is destroyed or a "Default" is enqueued. turn on highlighting and see what's really happening.... and what you expect
You are getting bit by the "use default if unwired" tunnel in the producer loop.
I would suggest enqueueing INSIDE the event structure.
04-19-2010 07:31 AM
I've posted the remaining VIs. The reason I don't use a state machine for each device is because I'm uning only one CAN device.
04-19-2010 08:35 AM
Jeff,
I believe I made the changes that you suggested in 3.vi. I don't understand why the "For Loop" in "Time Check" (which is where I want to put all my VIs in the form of a state machine for periodic checking) doesn't work.
Thank you.
04-19-2010 08:54 AM
OK I still cannot load your code completely, because it refers to things that don't exist on my system.
Something called "Test 1.vi" in LabVIEW 8.6/Examples. It's not a good plan to have code scattered all over your file system.
I assume you're judging that the FOR loop doesn't run, by the fact that the NUMERIC 2 does not increment.
If that loop is not running, it has to be because the CASE containing it is not executing.
That would be indicated by the NEXT STATE indicator NOT showing "TIME CHECK" - does it do that or not?
If it does NOT, then it's not coming out of the queue. I wonder why not?
You carry the ERROR line around, but you don't ever check it, that I see. Maybe there's an error occurring - probe it and find out.
If it's not coming OUT of the queue, then maybe it's not going INTO the queue.
Chase the problem from the end backward, and from the start forward. These are basic debugging skills that you will need.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-19-2010 09:07 AM
Steve,
I think your right on it here! Either a type def is out of sync- causing the dequeue element to fail or an error is occeuing in the consumer loop and being passed back to the dequeue element function. and the consumer loop is halted.
Try replacing the error Shift Register with a tunnel.
04-19-2010 09:17 AM
There's some basic misunderstanding here - there's a WHILE loop with a TRUE constant tied to the STOP terminal. That means it will never loop. Since there are no SRs in that loop, the loop does nothing except obfuscate the intent. Another loop has a TRUE constant tied to the STOP terminal. It has shift registers, but they are never changed within the loop, and since they are initialized outside the loop, the loop is completely pointless.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
04-19-2010 09:31 AM
04-19-2010 09:41 AM
That didn't seem to make a difference.
Just so you know, I can't tell to whom you are replying, nor what the "that" refers to.
Blog for (mostly LabVIEW) programmers: Tips And Tricks