From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-11-2007 03:15 AM
12-11-2007 07:30 AM
nice!
i didnt look at Ni's solution, so idont know how complicated they make it.
yet, here are my 2Euro cents:
try avoiding local variable all together. use instead (if necessary), global variable (called also Action Engines, see Ben's nugget)
try also avoiding sequences. see Atenbach nugget
reasons: in your solution, the possibilities to expand your code, or use it in larger systems, is a bit limited.
good luck on your exam!
12-11-2007 12:08 PM
12-11-2007 12:55 PM
try avoiding local variable all together. use instead (if necessary), global variable (called also Action Engines, see Ben's nugget)
12-11-2007 12:58 PM
exam is 4 hours.
I guess I have to learn as much as I can from the solution and then proceed to the next sample exam.
ThanX for all the feedback Gabi1
12-11-2007 01:22 PM
12-26-2007 06:40 PM
12-26-2007 06:57 PM
12-27-2007 10:18 AM
About queues vs shift registers. Queues allow you the ability to insert elements into either end of the queue. You can also write code to insert several elements at one time. With shift registers, only one new element can be carried over to the next loop at one time.
Lets say you have a state machine that always executes in the same order, no matter what the outcome, like State1 then State 2 then State 3. A shift register works fine for this simple example. However with queues, you can use a loop to insert the 3 states before the main state machine loop, then dequeue in the state machine. This is really a matter of preference.
Next example. Lets say you had a situation where you want to run 3 states, but if the second one fails, you want to run 2 other states before going to the third one. You could use a shift register, and you would have to look at each state to see which is next. A queue would allow you to insert the 2 extra states in between states 2 and 3. Of if you want to exit on some failure during a state. You can use the queue to insert the exit state at the opposite end so that it is the next to be dequeued.
Another situation is if you allow the user to call certain actions that require running several states. When the user presses button A, you enqueue states 1,2,3. If the user presses button C you enqueue states 7,8,9. So now you have a state machine in which states are defined by some user action. This would be more difficult to do with a shift register.
There are many other situations where a queued state machine is better than just a simple shift register. For the simplest of situations, I might use a shift register only. But I like to make it a habit to always use queues because of their versatility, and for the fact that I can go back and upgrade a simple state machine to a more complex one easily if it is done with queues. Be sure to use shift registers on the queue error in and error out so that errors can be propogated from one state to the next. On each state, check the error status. If one occures, enqueue a state at the other end to jump to your error handling state (or exit).