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 / 2673
2672  |  2674
Subject: 
Re: Questions about Differential
Newsgroups: 
lugnet.robotics
Date: 
Tue, 12 Jan 1999 05:12:05 GMT
Reply-To: 
nospam-dcchen@!spamless!pacbell.net-nospam
Viewed: 
1430 times
  
Nancy Gold wrote:
I'm going to need distance sensing for the final model also. If I succeed in
automating the transmission it will pick up a lot of speed by the time it
gets to forth gear. Waiting for a collision would be suicidal.

Try using the IR Port as a proximity sensor as has been discussed in
this newsgroup.  Search for subject:  IR Port as Proximity Sensor.  One
guy put up a website w/ sample Botcode program to do this.

Here is a NQC program called IRPing that puts out IR signals and beeps
if there is something within a certain distance.  Adjust for the
distance with the THRESHOLD constant.  This program allows you to change
the threshold levels by pushing on the touch sensor buttons.  Sensor 1
decreases the level, Sensor 2 increases the level.  This way you can
play with the settings w/o re-compiling each time and see which
threshold has the detection range you need.  Feel free to use the Ping
task as you need for detection.

The problem with the IR Proximity detection may be that the reliable far
detection range may not be as far as you need to avert a crash.

Dave

NQC code as follows:
/*
* IRPing2
* ===========
* Reads light level into Level, transmitts it out via SendMessage.
* If level > Thresh, a beep will sound to indicate proximity detection.
*
* Adjust threshold from initial THRESHOLD value by pushing touch
*  sensors, IN_1 decreases Thresh, IN_3 increases Thresh.
*
* Mount Light Sensor, IN_2, pointing in same direction as the IR Port
*
* Adjust the duty cycle of the pinging by playing with the constants
* DCYCLE and OFF.  Not having the IR Port on all the time may save on
* Battery Life.
*
* Mapping:
*   OUT_A: left wheel
*   OUT_B: empty
*   OUT_C: right wheel
*    IN_1: left touch sensor
*    IN_2: light sensor
*    IN_3: right touch sensors
*
*/
#define DCYCLE 10
#define OFF 100
#define THRESHOLD 70

int Thresh;
int Level;
int Active;
int Lt;
int Rt;
int Max;
int Min;

task Control
{
  while(true)
  {
    Lt = IN_1;
    Rt = IN_3;

    if((Lt == 1) && (Rt == 1))
    {
      wait((IN_1 == 0) && (IN_3 == 0));  //if both pushed, toggle Ping
// on and off
      if(Active == 1)
      {
        stop Ping;
        Active = 0;
      }
      else
      {
        start Ping;
        Active = 1;
      }
      PlaySound(2);
      Lt = 0;
      Rt = 0;
    }
    if(Lt == 1) // if Left button pushed decrease Thresh
    {
      wait(IN_1 == 0);
      Thresh -= 1;
      PlayNote(400,5);
    }
    if(Rt == 1) // If Right button pushed increase Thresh
    {
      wait(IN_3 == 0);
      Thresh += 1;
      PlayNote(480,5);
    }
  }
}

task Ping
// Beeps if IN_2 > Threshold indicating proximity detection
{
  while(true)
  {
    repeat(DCYCLE) // Send active Pings DCYCLE times
    {
      SendMessage(Level);
      Level = IN_2;
      if(Level > THRESHOLD) // You've detected something!
        PlayNote(360,1); // Play a sound or do whatever you want to do
in event of a collision
      if(Level > Max)
        Max = Level; // Keep track of Max and Min Readings for test
purposes
      if(Level < Min)
        Min = Level;
    }
    Sleep(OFF); // Rest for awhile and save juice
  }
}

task main
{
  // Set up the sensors
  Sensor(IN_1,IN_SWITCH);
  Sensor(IN_2,IN_CFG(STYPE_LIGHT, SMODE_PERCENT));
  Sensor(IN_3,IN_SWITCH);

  // Initialize variables
  Thresh = THRESHOLD;
  Active = 1;
  Max = 0;
  Min = 100;

  // Start Tasks
  start Control;
  start Ping;
}



Message is in Reply To:
  Re: Questions about Differential
 
Initially I'm trying to shoehorn a new style motor into the existing form. The old motor wouldn't have a chance at driving the model. The new one might do it just fine by driving the "crankshaft". My final model will require redesigning the model (...) (25 years ago, 12-Jan-99, to lugnet.robotics)

19 Messages in This Thread:









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

Custom Search

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