LabVIEW

cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Clusters in state machine

Hi,

I have another problem! I think it's because I have the two enqueues..
I want that, when I press the button Impact, the output show a square wave, but just one impulse. Then the button must came to the original position.
I notice that when I activate the impact button, it takes a while to respond.
I think it's because I don't have the flush queue. I read some posts here, but I can't understand them very well, and I don't know how to apply them here.

Thanks for all your help

SĆ­lvia

0 Kudos
Message 21 of 29
(1,956 Views)

Have you sat down with a piece of paper and drawn out the architecture of what you are trying to do.  When working with state machines, it is important to draw out all the states and all of the interactions between them like a big flow chart.  What happens after the impact state?  Do you want it to go back to another state?  What states are set up in the queue still waiting to execute when you want it to jump to the impact state?  What do you want to do with those waiting states, cancel them, or still execute them after the impact case occurs?

 

You have a couple options.  One is that you flush the queue before enqueuing the impact case.  The other is that you can use Enqueue at Opposite End so that the impact case can jump in line and be the next one to execute.  Everything still waiting in the queue will be forced to wait until the impact case as run.

0 Kudos
Message 22 of 29
(1,949 Views)

The impact it's not a state, it belong to the state acquire. I want that the amplitude of the square wave change, when I activate that button. But not always it happen, sometimes I press the button, and nothing happen with the output wave. And other times the output wave takes a long time to change.

0 Kudos
Message 23 of 29
(1,937 Views)

When I dequeue a queue, it shouldn't be empty?

0 Kudos
Message 24 of 29
(1,924 Views)

I'd argue that impact is more of a state than acquire.

 

If anything, acquire should be executing all the time in its own separate loop.  And whether you are acuiring or not should be turned on and off by a notifier, queue, action engine, or some other notifaction method from one your other loops.

 

When you dequeue an element, it removes one element from the queue.  Whether that makes it empty or not depends on how many elements you have enqueued.

0 Kudos
Message 25 of 29
(1,921 Views)

Are you saying  that I should have another state to send a signal with a different amplitude? I don't understand why!

I think that in my code, even if I dequeue an element, the elements are still in the queue! Is that possible!


 

Thanks

SĆ­lvia

0 Kudos
Message 26 of 29
(1,907 Views)

Your impulse event is putting another element in the queue which has not state bundled into it.  So it is getting the default enum of Start.

 

When the Start case runs, you are actually breaking your acquisition because you don't have your DAQmx task wired through that case.  You can also see there is a Use Default if Unwired tunnel on the right hand side of your shift register.  So when Acquire runs again when that element comes through, it can't acquire because now you have an empty DAQ task coming out of the purple shift register.

 

You could wind up loading more queue elements then you meant over time. 

 

If you hit the Start button,  Initialize then Acquire queues up.

Initialize runs, acquire left in queue.

Acquire runs, it reenqueues itself.  Does this repeatedly.  Good.

Impluse  button is hit,  Now acquire and "Start", the default enum are in the queue.

Acquire runs, it reenqueues itself, now Start and Acquire are in the queue.

Start runs.  It breaks the DAQ task wire,  Now Acquire is in the queue.

Acquire runs, it re-enqueue itself.  Does this repeatedly, but with the broken task wire, nothing works.

 

If you hit the Start button again,  Initialize and Acquire queues up.  Now you have Acquire, Init, and another Acquire in the Queue.

Acquire runs, re-enqueues, now you have Init, Acquire, Acquire.

Init runs, it finally fixes the broken DAQ task, now you have Acquire, Acquire.

Acquire runs, it re-enqueues itself, so you still have two acquires in the queue.

Get something else in the queue, you have to get through two acquires before you get to it.

 

Do you see how things can slow down over time, or things wind up breaking?

 

 

0 Kudos
Message 27 of 29
(1,901 Views)

Hi,

Are you saying that I should connect the DAQmx task in the Start case? I didn't do that, because I just initialize the DAQmx in the Initialize case. I think, that the button start shouldn't be press more than one time, is there any way to do that? Nevertheless I think I'll connect the DAQmx task. Regarding the stop case, I don't have the DAQmx task connect there. Is there any problem? Should I have the DAQmx clear task outside the state machine?

Regarding the event structure, Why when I press the Impulse button, I have the start in the queue? I shouldn't have the previous used enum, because of the shift register? How can I fix this?

Thanks
SĆ­lvia

0 Kudos
Message 28 of 29
(1,855 Views)

No, what he is saying is that every time you hit start, you add one more acquire to the queue.  hit it once, there is one acquire, hit it 10 times, you have 10 acquires in queue.

0 Kudos
Message 29 of 29
(1,826 Views)