Difference between revisions of "IntelliFrank"

From NURDspace

Jump to: navigation, search
(Updates: stepper motor)
(Yay! It works!)
Line 24: Line 24:
 
* 14/03/2012: Works! Unfortunately there's an electrical problem somewhere in the steering and/or engines, so Frank does not steer well. Next step will be either to try to fix that or get another RC car.
 
* 14/03/2012: Works! Unfortunately there's an electrical problem somewhere in the steering and/or engines, so Frank does not steer well. Next step will be either to try to fix that or get another RC car.
 
* 17/03/2012: Steering is done by a stepper motor, it seems. Maybe we can drive the motors directly by using a Motorshield. Info on stepper motors with six wires, like the one in Frank: http://www.imagesco.com/articles/picstepper/02.html
 
* 17/03/2012: Steering is done by a stepper motor, it seems. Maybe we can drive the motors directly by using a Motorshield. Info on stepper motors with six wires, like the one in Frank: http://www.imagesco.com/articles/picstepper/02.html
 
+
* 30/03/2012: [user:ID] found out that Frank does not have a stepper motor, but a "normal" DC motor and a sensor system to detect the position of the steering system. We also got another car, Nicky, who is easier to use because of the steering: this is done by electromagnet instead of a motor.
 +
* 31/03/2012: It turned out that the Arduino we used has a problem after all. So we used another Arduino + the Motorshield and lo and behold! everything works! So we now have a small, autonomous car! As soon as the battery has been recharged, we'll shoot some video :-)
  
 
<code>
 
<code>

Revision as of 18:26, 31 March 2012

NURDspace Project
link=File:{{{Name}}}.jpg
Participants Bjornl, Buzz
Skills
Status
Niche
Purpose
Tool
Location
Cost
Tool category
{{{Name}}}
"{{{Name}}}" cannot be used as a page name in this wiki.
"File:{{{Picture}}}" cannot be used as a page name in this wiki.

{{{Picture}}} {{#if:{{{Tool}}} | [[Tool Owner::bjornl buZz | }} {{#if:{{{Tool}}} | [[Tool Cost::{{{Cost}}} | }}

buZz has an autonomous electric toy car, "Frank". Frank should be upgraded with sensors to avoid collisions and software to act more intelligently (and possibly execute small furry animals simple tasks).

This is probably a good way to get acquainted with Arduino programming.

  • create new, more intelligent programs
  • add sensors and programming for those sensors


Updates

  • 29/02/2012: Attached a Devantech SRF04 Ultrasonic Range Finder to Franks Arduino and got readings! Now working on more intelligent code.
  • 01/03/2012: Uploaded code (see below), works, but _only_ when USB cable is attached, otherwise Frank _always_ retreats!
  • 14/03/2012: Works! Unfortunately there's an electrical problem somewhere in the steering and/or engines, so Frank does not steer well. Next step will be either to try to fix that or get another RC car.
  • 17/03/2012: Steering is done by a stepper motor, it seems. Maybe we can drive the motors directly by using a Motorshield. Info on stepper motors with six wires, like the one in Frank: http://www.imagesco.com/articles/picstepper/02.html
  • 30/03/2012: [user:ID] found out that Frank does not have a stepper motor, but a "normal" DC motor and a sensor system to detect the position of the steering system. We also got another car, Nicky, who is easier to use because of the steering: this is done by electromagnet instead of a motor.
  • 31/03/2012: It turned out that the Arduino we used has a problem after all. So we used another Arduino + the Motorshield and lo and behold! everything works! So we now have a small, autonomous car! As soon as the battery has been recharged, we'll shoot some video :-)

/*

Semi-intelligent steering for RC car
bjornl
29-02-2012
  • /
  1. define NO_MEASUREMENT 0
  2. define TOO_CLOSE 2000
  3. define QUITE_CLOSE 5000
  4. define NOT_SO_CLOSE 15000
  1. define CAREFUL_FORWARD 200
  2. define STEP_FORWARD 400
  3. define RUN_FORWARD 800

// these pins are connected straight to the receiver chip of the RC car const int leftPin = 2; const int rightPin = 3; const int fwdPin = 4; const int bwdPin = 5;

// between this pin and ground, there is a roller ball switch const int rollerPin = 13;

// little 5mm led, red :) const int ledPin = 8;

// rangefinder const int triggerPin = 9; const int echoPin = 10;

void setup() {

 Serial.begin(9600);
 // set up the outputs
 pinMode( leftPin, OUTPUT);
 pinMode(rightPin, OUTPUT);
 pinMode( fwdPin, OUTPUT);
 pinMode( bwdPin, OUTPUT);
 pinMode( ledPin, OUTPUT);
 
 // set up the inputs
 pinMode(triggerPin, OUTPUT);
 pinMode(echoPin, INPUT);

}

void loop() {

 int measurement;
 
 // Get a measurement
 measurement = getMeasurement();
 
 if (measurement == NO_MEASUREMENT) {
   // No valid signal was given, panic!
   panic();
 } else if (measurement < TOO_CLOSE) {
   // Too close to wall, retreat!
   retreat();
 } else {
   // Determine amount of time to run forward
   int runTime;
   
   if (measurement < QUITE_CLOSE) {
     runTime = CAREFUL_FORWARD;
   } else if (measurement < NOT_SO_CLOSE) {
     runTime = STEP_FORWARD;
   } else {
     runTime = RUN_FORWARD;
   }
   goForward(runTime);
 }

}

void panic() {

 Serial.println("Panic!");
 // flash LED
 for (int i = 0; i < 10; i++) {
   digitalWrite(ledPin, HIGH);
   delay(100);
   digitalWrite(ledPin, LOW);
   delay(100);
 }

}

void retreat() {

 Serial.println("Retreat!");
 // Go backward left for the given amount of time
 digitalWrite(rightPin, HIGH);
 digitalWrite(leftPin, LOW);
 delay(200);
 digitalWrite(fwdPin, LOW);
 digitalWrite(bwdPin, HIGH);
 delay(500);
 digitalWrite(bwdPin, LOW);
 delay(200);
 digitalWrite(rightPin, LOW);

}

void goForward(int runTime) {

 Serial.print("Forward: ");
 Serial.println(runTime);
 // Go forward for the given amount of time
 digitalWrite(fwdPin, HIGH);
 digitalWrite(bwdPin, LOW);
 digitalWrite(rightPin, LOW);
 digitalWrite(leftPin, LOW);
 delay(runTime);
 digitalWrite(fwdPin, LOW);

}

int getMeasurement() {

 Serial.print("Measurement: ");
 int measurement;
 // wait for some time, make it look like we are thinking ;)
 digitalWrite(ledPin,HIGH);
 delay(1000);
 
 // send trigger pulse
 digitalWrite(triggerPin, HIGH);
 delayMicroseconds(10);
 digitalWrite(triggerPin, LOW);
 measurement = pulseIn(echoPin, HIGH);
 Serial.println(measurement);
 digitalWrite(ledPin, LOW);
 return measurement;

}

/* end */

 
Our site is hosted by Site4U
Site4U
Our connectivity is made available by BIT
To BIT's website