To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 21913
21912  |  21914
Subject: 
Re: Pneumatic valve mystery
Newsgroups: 
lugnet.robotics
Date: 
Fri, 26 Dec 2003 21:51:10 GMT
Original-From: 
T. Alexander Popiel <popiel@(saynotospam)wolfskeep.com>
Viewed: 
897 times
  
In message:  <6.1f06df4e.2d1de590@aol.com>
             FirstCool@aol.com writes:

My problem is a mystery behavior where the system misses a command.  This has
happened on the very first cycle;  the most cycles without the mystery
behavior is 129.  It appears to be random.

I suspect you're having problems with indeterminate values in the
whichPosition variable.  This might happen due to the SensorListener
getting called in the middle of one of the tests for your while loops...
or it might have some other cause.

In any case, I'd remove LCD.showNumber from the SensorListener,
and rewrite pOne, pTwo, and PBlock as follows:

  static void pOne()  {
    int pos = whichPosition;
    while (whichPosition != 1) {
      valveMotor.forward();
      pos = whichPosition;
    }
    LCD.showNumber(pos);
    valveMotor.stop();
  }

  static void pTwo()  {
    int pos = whichPosition;
    while (whichPosition != 2) {
      valveMotor.backward();
      pos = whichPosition;
    }
    LCD.showNumber(pos);
    valveMotor.stop();
  }

  static void pBlock()  {
    int pos = whichPosition;
    while (whichPosition == 1) {
      valveMotor.backward();
      pos = whichPosition;
    }
    while (whichPosition == 2) {
      valveMotor.forward();
      pos = whichPosition;
    }
    LCD.showNumber(pos);
    valveMotor.stop();
  }

This will at least show why pOne(), pTwo(), and pBlock() are
unexpectedly exiting their while loops.

- Alex



Message has 1 Reply:
  Re: Pneumatic valve mystery
 
(...) What about tighten the things a bit more with: int pos = whichPosition; valveMotor.forward(); while( pos != 1 ) { pos = whichPosition; } valveMotor.stop(); LCD.showNumber( pos ); This should be the fastest loop I can think of in terms of (...) (21 years ago, 26-Dec-03, to lugnet.robotics)

Message is in Reply To:
  Pneumatic valve mystery
 
I am a novice robot builder and programmer who needs some help with a random problem that affects a pneumatic system I have built. I want a general purpose basic pneumatic system that can be programmed to use any of the three positions of the (...) (21 years ago, 26-Dec-03, to lugnet.robotics)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR