LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Generation control with START/STOP control (State Machine Approach)

Solved!
Go to solution

Hello

 

I've met problem with realisation of signal generation control (START/STOP) using state machine.

There are 4 states in state machine (please see 4 screenshots below).

The problem is when I click on START button, only short series of pulses generated.

Is it problem task_in/task_out staff, that isn't properly managed ?

 

Thanks in advance

 

Pavel.

 

SignalGeneration_with_StateMachine_(1)IDLE.JPG

 

SignalGeneration_with_StateMachine_(2)StartAcquisition.JPG

 

SignalGeneration_with_StateMachine_(3)WriteWaveForm.JPG

 

SignalGeneration_with_StateMachine_(4)StopAcquisition.JPG

0 Kudos
Message 1 of 10
(4,451 Views)

Your waveform gets reset after the first Write because you didn't wire it through. It is being set to a default value for each subsequent write.

 

Some tips:

  • Why have a While loop with a False boolean constant written to the Stop terminal? Create the ability of your program to stop the VI without forcing a stop.
  • Wire all of your error clusters through and stop the loop if there is an error. Right now nothing happens if there's an error.
  • You have no loop timing, so your Idle case will take up all of your CPU. Add a Wait in there.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 10
(4,427 Views)

Thanks James

 

I've followed your suggestions and did some modifications:

  • delay added into while loop
  • stop teminal of While Loop is wired to "error status" for each case

I've run it - any error messages.

Concerning "... after the first Write because you didn't wire it through" I didn't properly understand what you mean.

Regards

Pavel

0 Kudos
Message 3 of 10
(4,415 Views)

You're just writing the same waveform over and over again, right? Your Start Acquisition state creates a square wave and writes it to a shift register. You then read that shift register in Write Waveform, but you don't pass the waveform back through the shift register again, so the waveform is lost.

Waveform.PNG

LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. Here's a simple resource to become more familiar with how it works. The Highlight Execution feature is a great way to watch how your application utilizes dataflow. Your dataflow needs to keep the waveform data through each state.

 

By the way, I meant to add the Wait to your Idle state. You don't necessarily want to program to be waiting during other states, only while idling.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 4 of 10
(4,409 Views)

Thanks you James, Yes it was exactly the case of problem.

Thanks !

The button "STOP" still doesn't work.

0 Kudos
Message 5 of 10
(4,394 Views)

I edited your VI with some improvements. See attached.

The Stop button now only stops acquisition and I added a Stop Application button. The error gets taken in to account with every state along with a boolean output, so it can be stopped other than with the error cluster.

 

You could improve this more with an event structure in the idle state, but if this is all you're doing with this application, that may be overkill. If you plan on scaling this to more functionality, you should look in to the Simple State Machine template that ships with LabVIEW.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 10
(4,391 Views)

When clicked shortly "STOP" doesn't work, but when I keep it pushed about 1 sec, it works

0 Kudos
Message 7 of 10
(4,384 Views)
Solution
Accepted by Pavel_47

Oh... you have it set to the mechanical action Switch Until Released... Right-click it and go to Mechanical Action > Latch When Released. Do the same for your Start button.

It was taking you a second to read the value while held down because your acquisition Write takes about that long apparently.

 

The Stop Application button I made is set to Switch When Released. It is set to Switch so that it can be used as a local variable in the Stop Acquisition state as well as Idle.

Here's more info about mechanical actions.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 10
(4,379 Views)

Ok, it works.

Thanks a lot.

0 Kudos
Message 9 of 10
(4,364 Views)

can you just send me in a 2013 version i want to look out?

0 Kudos
Message 10 of 10
(3,635 Views)