LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging State Machine

Highlighted

Hi all,

 

For example, let's say I have a state machine with 8 states.  I just finished coding my first state, but I want to test it before I move on to the next state.  Since I have shift registers and tunnels from the state that I just programmed, I would have to go to all the 7 states to connect all the shift registers and tunnels with dummy constants before I can test the finished state, or the program won't run for testing purposes. 

 

Is there a better way to test a state machine one state at a time without using dummy constants, making the code in a state a subiv, etc.  I want to be able to lay down my main flow, program my first state, and test my first state without messing with my other states.

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 7
(1,079 Views)
Highlighted

Two choices.

 

1.  Don't put in all the other cases for your state machine until you are ready to use them.

2.  If you are using LV 8.6, you can wire the tunnels going into and out of the case structure and set them for Linked Input tunnels, and then set Create and Wire Unwired cases.

0 Kudos
Message 2 of 7
(1,068 Views)
Highlighted
Well, why don't you program a state individually in one application, test it and then put it in the state machine. Also, you don't have to create all states at once with nothing in them; build all of them state after state.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 3 of 7
(1,067 Views)
Highlighted

You could place the contents of a single state into a single sub-vi, this would make unit testing very easy.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 7
(1,053 Views)
Highlighted

Hi Ravens Fan,

 

Can you explain option 2 a bit more?  Thanks!

 

Yik

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 7
(1,009 Views)
Highlighted

I guess I can't resist using the "adding a case for each value" after I have connected my enum constant with all my cases in it to the case structure.  When I do connect it, several cases would appear in the case structure, and I can't select which one to appear first.

 

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 6 of 7
(1,008 Views)
Highlighted

Make your enum a type-def. Add one case at the time and test it.

Also see this

0 Kudos
Message 7 of 7
(993 Views)