LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While Loop doesnt stop inside a case structure

Solved!
Go to solution

Asad,

 

It is a little difficult to tell what is going on because I do not have your subVIs. ResetMotor.vi, Rotation.vi, and MotorOn.vi are the names in the false case.  Do you really want to reset the motor each time this state starts? 

 

How do you read the encoders?  What other information does the p-controller use? Does anything els use the encoder data?

 

Typically in a state machine the while loop is the outermost structure.  The shift registers are on that loop.  The state is usually specified by a typedefed enum with the value of the enum passed through the shift register.  Any other data which is read or generated in one state and used by another (your magnetic sensor data or perhaps the encoders) amy also be passed in shift registers.

 

I doubt that two states will be enough.  It is often useful to have Initialize, Idle, and Shutdown states. When you read the NXT button which apparently stops the loop, you could go to the Shutdown state where the vehicle gets sent a command to stop before the loop stops. It may be useful to separate the reading of the sensors from the running of the vehicle.  Does it ever reverse? Is swerve only one direction or can it go to the left or right? How does it decide? Does it have variable speed?  Even if you are not doing any of these things now, a state machine will allow you to add the capability later. Simple states are usually more flexible than one big complicated state.

 

Lynn

0 Kudos
Message 11 of 13
(602 Views)

Great point, but how does ´my vehicle decide between these states. I am giving no inputs to the program once its embedded. its supposed to be an autonomous vehicle. so as far as i can think i can only switch by checking inputs from the magnetic sensor. Which can be either magnet is detected or it is not detected. I was considering using separate states initially. but then i decided against for this very reason. But great idea lynn it made a lot of things clear to me.

Regards
Asad Tirmizi
Design Engineer
Institute of Avionics and Aeronautics

" Its never too late to be, what u want to be"
Using LabVIEW 8.2
0 Kudos
Message 12 of 13
(601 Views)

Asad,

 

You only have two states for the behavior of the device based on the magnet.  You may have more states related to the speed based on the encoder inputs.

 

As the vehicle develops you may want to monitor the charge in the batteries or the fuel supply so that the vehicle does not get stranded.  You may want to add some kind of goal seeking, which will then require more navigation than simple obstacle avoidance.  More states.  States are almost free after you initially set up the state machine properly.

 

Lynn

0 Kudos
Message 13 of 13
(599 Views)