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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State Machine back and forth

Hello everybody, 

 

I´ve made a state machine with different orders: 

 

- Move Y0position

- Move X0position

- Measurement

- Move NextX (if ActualX < Final X, then runs Measurement again; if not, go to Move Next Y)

- Move NextY (if Actual Y< Final Y, then go to Move X0position; if not, Finish)

- Finish

 

The problem comes with Move NextY. I´ve put a selector to choose the next step but insted of coming back to X0position and follow the Measurements, it does other thing and doesn´t follow my instructions (just goes Move NextY). 

 

Could someone take a look at my program (attached) and help me with this??

 

Thank you very much!!!

 

0 Kudos
Message 1 of 12
(3,232 Views)

Replace the Boolean control in your Finish state with a Boolean constant with a value of TRUE. Right now, your Finish state is sending a FALSE to the loop stop condition (the "Boolean" control is hidden on the front panel, and its value is always FALSE). Since you don't have a state enum wired in the Finish state, the default value of the enum is used, which appears to be "Move Y0position".

 

Also, I recommend using a type definition for your state enum. That way, when you add/modify/remove a state, all instances of the enum will be updated.

Message 2 of 12
(3,207 Views)

Hi Darren, 

 

I´ve just made your suggested modifications, but something wrong happens since the program doesn´t come back to Move X0position. I´ll try to put some variables outside case structure and see what happens (I don´t know if this will mean something).

 

Thanks

 

 

0 Kudos
Message 3 of 12
(3,195 Views)

You shouldn't have two references going to the same thing.  You should be able to just use 1 reference for each motor.  Move the controls to outside of your case structure.  That could be causing issues when you do your measurement.  Is your Actual Y position less than Final Y position?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 12
(3,188 Views)

Hi crossrulz,

 

I did what you said, put the motor references outside case stucture. I also did the same with some variables, but the program still doesn´t work properly.

 

In the last step "Move NextY", it should decide between go to "Move X0position" and "Finish". None of these things happen. In fact, it carries on running "Move NextX" and "Move NextY", and when FinalY is reached, then the program stops.

 

About your question, yes, ActualY is less than FinalY position, that´s why I don´t understand what is happening here. Smiley Sad

 

 

 

 

0 Kudos
Message 5 of 12
(3,127 Views)

Thanks Darren.

 

I´m working with Labview 9 in an old xp computer. I´ve tried to use a type definition for the state enum but I´m not able to find it (however I can do it in Labview 2013, but for some reason I can not save for previous versions of Labview, so...).

 

 

0 Kudos
Message 6 of 12
(3,126 Views)

@lacorgui wrote:

Thanks Darren.

 

I´m working with Labview 9 in an old xp computer. I´ve tried to use a type definition for the state enum but I´m not able to find it (however I can do it in Labview 2013, but for some reason I can not save for previous versions of Labview, so...).

 

 


In LabVIEW 2009, you have to right-click on the enum and go to Advanced->Customize.  That will open up the control editor.  Change the type to a Type Def (the default was Control, which is useless in this situation).

 

And you can save for previous in 2013.  File->Save For Previous Version.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 12
(3,116 Views)

I would like to make this type def but the problem is that the "Advanced" buttom is disabled (no idea why). And when working in Labview 2013, I try to save for previous versions but it tells me that some errors occur Smiley Surprised

 

I´ve been trying to add new cases to the case structure but I´m not able to do that, is because of this type def problem?

 

Thanks

0 Kudos
Message 8 of 12
(3,087 Views)

You can only add cases that your enum defines.  This is why we told you to make the enum a type def.  Because now you will need to go through all of those enums and update them.  Here, this control file should work for you in 2009.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 12
(3,077 Views)

@lacorgui wrote:

I would like to make this type def but the problem is that the "Advanced" buttom is disabled (no idea why). And when working in Labview 2013, I try to save for previous versions but it tells me that some errors occur Smiley Surprised

 

I´ve been trying to add new cases to the case structure but I´m not able to do that, is because of this type def problem?

 

Thanks


If you are trying to typedef a constant, you'll have to temporarily change it to a control first, then change it back after you're done.  I can't recall exactly when the right-click typdef thing was implemented, but this is the same time it enabled you to vreate a typdef from a constant.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 10 of 12
(3,076 Views)