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
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
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:
![](/news/x.gif) | | 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: ![Questions about Differential -lego-robotics@crynwr.com (Alan G. Smith) (21-Dec-98 to lugnet.robotics)](/news/x.gif) ![](/news/246.gif) ![Re: Questions about Differential -lego-robotics@crynwr.com (Don Hewitt) (21-Dec-98 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/268.gif) ![Re: Questions about Differential -Alex Wetmore (21-Dec-98 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Questions about Differential -Matthew Miller (21-Dec-98 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/268.gif) ![Re: Questions about Differential -Joshua Delahunty (21-Dec-98 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/268.gif) ![(long) Rotation Sensor from "Extreme Creatures" Fiber Optics -lego-robotics@crynwr.com (Don Hewitt) (22-Dec-98 to lugnet.robotics)](/news/x.gif) ![](/news/246.gif) ![Re: (long) Rotation Sensor from "Extreme Creatures" Fiber Optics -Robert Fay (22-Dec-98 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: (long) Rotation Sensor from "Extreme Creatures" Fiber Optics -Eric Brok (5-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/246.gif) ![Re: (long) Rotation Sensor from "Extreme Creatures" Fiber Optics -lego-robotics@crynwr.com (S. Crawshaw) (5-Jan-99 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/28.gif) ![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Cybermaster pricing -lego-robotics@crynwr.com (Medical Informatics Consulting) (5-Jan-99 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![Re: Questions about Differential -Mark Tarrabain (3-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/246.gif) ![Re: Questions about Differential -lego-robotics@crynwr.com (Medical Informatics Consulting) (3-Jan-99 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/x.gif) ![](/news/268.gif) ![Re: Questions about Differential -Alex Wetmore (4-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Questions about Differential -Linc Smith (4-Jan-99 to lugnet.robotics)](/news/x.gif)
![](/news/x.gif) ![](/news/x.gif) ![](/news/68.gif) ![Re: Questions about Differential -Dean Lovell (4-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Questions about Differential -lego-robotics@crynwr.com (Nancy Gold) (4-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Questions about Differential -Jasper Janssen (12-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![Re: Questions about Differential -lego-robotics@crynwr.com (Nancy Gold) (12-Jan-99 to lugnet.robotics)](/news/x.gif) ![](/news/46.gif) ![You are here](/news/here.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|