Page 1 of 1

Dual Concurrent Loop Problem

Posted: 31 Mar 2012, 14:39
by bcox5351
Writing in NXTG ver 2

While writing this program, I came across an almost identical snippit solution from Brian Davis. A perfect match I thought!
The only problem is that it does not work (at least mine doesn't). The program hunts down targets (Bottles) inside a ring
of black tape. When it encounters the ring, it stops right on cue in the exception loop. The problem is that it remains locked
in the exception loop. The mode changes appropriately but it will not transit back to the original loop. I have attached a pack
and go for inspection. The normal (lower loop) runs fine,hunting and attacking objects as it finds them.

Any assistance would be welcomed.

Thanks,

Bill C.

Re: Dual Concurrent Loop Problem

Posted: 02 Apr 2012, 14:07
by hassenplug
I'm not totally sure, but I'll take a guess on this one.

One thing that you're doing in this program that can cause problems is that you're trying to control the motors from two different loops. Meaning the main loop may tell motor A to go forward 5 degrees, but the sensor sees a line, so the exception loop tells the motor to back up. The motor will backup and wait for the next command, but the main loop is still waiting for the motor to drive forward 5 degrees.

Using a "State Machine" like you have is an excellent way to control the robot. The ability to change the "Mode" value from different places in the program can work very well. You just want to control your motor from a single location (in the switch), and have another Mode that causes it to backup if it sees a line.

Hope that helps

Steve