Difference between revisions of "IntelliFrank"

From NURDspace

Jump to: navigation, search
(updated code)
m (Text replacement - "ProjectNiche=" to "Niche=")
 
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Project
 
{{Project
 +
|Name=IntelliFrank
 +
|Skills=programming, micro-electronics
 +
|Status=Dormant
 +
|Niche=Electronics
 +
|Purpose=Education
 +
|Picture=Nicky.jpg
 +
|Tool=No
 
|ProjectParticipants=bjornl buZz
 
|ProjectParticipants=bjornl buZz
|ProjectSkills=programming, micro-electronics
 
|ProjectStatus=Active
 
|ProjectNiche=Electronics
 
|ProjectPurpose=Education
 
 
}}
 
}}
 
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 <strike>small furry animals</strike> simple tasks).
 
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 <strike>small furry animals</strike> simple tasks).
Line 14: Line 17:
  
  
 +
* range finder tech info: http://www.robotstorehk.com/srf04tech.pdf
 +
* range finder data sheet: http://faculty.kfupm.edu.sa/COE/masud/RichText/R93-SRF04p%20UltraSonic.pdf
 
* original sourcecode : http://etc.servehttp.com/Frank_Brain.pde.gz
 
* original sourcecode : http://etc.servehttp.com/Frank_Brain.pde.gz
 +
 +
== Updates ==
  
 
* 29/02/2012: Attached a Devantech SRF04 Ultrasonic Range Finder to Franks Arduino and got readings! Now working on more intelligent code.
 
* 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!
 
* 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: 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 :-)
 +
* video: http://www.youtube.com/watch?v=f47ACLyZS88
  
<nowiki><pre>/*
+
== Sources ==
 
+
All sources have been committed to the Subversion repository 'nurdspace' in folder /intellifrank
Semi-intelligent steering for RC car
+
bjornl
+
29-02-2012
+
 
+
*/
+
 
+
#define NO_MEASUREMENT 0
+
#define TOO_CLOSE 2000
+
#define QUITE_CLOSE 5000
+
#define NOT_SO_CLOSE 15000
+
 
+
#define CAREFUL_FORWARD 200
+
#define STEP_FORWARD 400
+
#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 */
+
</pre></nowiki>
+

Latest revision as of 10:04, 25 August 2014

IntelliFrank
Nicky.jpg
Participants Bjornl, Buzz
Skills programming, micro-electronics
Status Dormant
Niche Electronics
Purpose Education
Tool No
Location
Cost
Tool category

IntelliFrank

Nicky.jpg {{#if:No | [[Tool Owner::bjornl buZz | }} {{#if:No | [[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: 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 :-)
  • video: http://www.youtube.com/watch?v=f47ACLyZS88

Sources

All sources have been committed to the Subversion repository 'nurdspace' in folder /intellifrank

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