Pages: 1 [2] 3   Go Down
Author Topic: Autonomous Car  (Read 5807 times)
0 Members and 1 Guest are viewing this topic.
Newcastle, England
Offline Offline
Sr. Member
****
Karma: 3
Posts: 489
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This sounds like a col project! Tell me when you completed it!
Logged

My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) smiley-grin

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I built an Arduino based robomagellan truck this summer and I just wanted to share a couple of lessons learned.

1) A sweeping ping works awesome with two things to keep in mind. ping too high car hits curb(destructive). ping too low car sees grass (runs constant avoidance).
2) The NMEA library is awesome!
3) Use a servo for steering. I tried using the dc motor steering boxes that came with the trucks I modded (being cheap) and it was a disaster.
4) Trees are not your GPS's friend.... Have a secondary system for staying on course (digital compass, etc).
5) Keep the power for your board and sensors separate from your power for servos and motors.
6) Keep the car's speed down until everything is dialed. Replacing ping sensors, etc sucks.
7) Don't skimp on the batteries.

Hope this saves someone a few broken parts.....
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks aroma of tacoma. i heard a little about the NMEA library and im going to look further into it.

newbie thanks for the clarification and from looking at the schematic i followed the pins would be 3 and 6 correct? because those are the motors leads.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

im having a little bit of trouble testing this rc car because im not sure if my code is wrong. i used what newbie gave me and changed the pins to where he used 8 and 9 to 3 and 6 (look at the schematic i posted) or if its my wiring/connections that are causing nothing to happen.
Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

arrording to the schematic you posted the pin no's for the motors are [size=14]3 & 4[/size]
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

can you explain as to why its 3 and 4. sorry for these stupid questions.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can use any pins on the Arduino you want. Choosing a PWM as one of them gets you speed control.

3 is a pin with PWM capability.

An analogwrite to pin 3 sets the speed you want to go.
0 = stop.
255 = full speed.

Now digitalwrite to 4.
1 = one direction.
0 = the other direction.
« Last Edit: December 06, 2010, 10:38:33 pm by p.00.ter » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so i completely re wired my circuit using this schematic. and this code. still not spinning the motor.
 ignore the switch. i am not using that.


 const int switchPin = 2;    // switch input
  const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
  const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
  const int enablePin = 9;    // H-bridge enable pin
  const int ledPin = 13;      // LED

  void setup() {
    // set the switch as an input:
    pinMode(switchPin, INPUT);

    // set all the other pins you're using as outputs:
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(enablePin, OUTPUT);
    pinMode(ledPin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH);

    // blink the LED 3 times. This should happen only once.
    // if you see the LED blink three times, it means that the module
    // reset itself,. probably because the motor caused a brownout
    // or a short.
    blink(ledPin, 3, 100);
  }

  void loop() {
    // if the switch is high, motor will turn on one direction:
    if (digitalRead(switchPin) == HIGH) {
      digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
      digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
    }
    // if the switch is low, motor will turn in the other direction:
    else {
      digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
      digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low
    }
  }

  /*
    blinks an LED
   */
  void blink(int whatPin, int howManyTimes, int milliSecs) {
    int i = 0;
    for ( i = 0; i < howManyTimes; i++) {
      digitalWrite(whatPin, HIGH);
      delay(milliSecs/2);
      digitalWrite(whatPin, LOW);
      delay(milliSecs/2);
    }
« Last Edit: December 07, 2010, 10:55:47 am by chizzad » Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
ignore the switch. i am not using that.
The code is designed to check the switch and then run the motors  ;D
well in that case you could modify the sketch or just short out the place wher the switch  should be there ( the diagram looks correct )
Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

or Use this code ( i wrote it so that you could learn xomething out of it )
remove the entire switchey thing and
Code:
const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
 const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
 const int enablePin = 9;    // H-bridge enable pin
Void MAin()
{
 pinMode(motor1Pin, OUTPUT);
   pinMode(motor2Pin, OUTPUT);
   pinMode(enablePin, OUTPUT);
}
void loop ()
{
digitalWrite(motor1pin,HIGH);
digitalWrite(motor2pin,LOW);
digitalWrite(enablePin,HIGH); //you could use analog write on pwm pins to alter speed
dealy(10000);//motor spins in one diredtion for ten seconds
digitalWrite(motor1pin,LOW);
digitalWrite(motor2pin,HIGH);
digitalWrite(enablePin,HIGH); //you could use analog write on pwm pins to alter speed
dealy(10000);//motor spins in the other diredtion for ten seconds
}



Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i sure wish i knew that before. thanks for putting up with all my dumb mistakes. youre saying replace the switch code with that or that is what will be left. i will read through and try to make sense of that. thanks.

EDIT:

so i fixed up some little capitalization and spelling errors in your code and its compiling fine. now is that to be used alone or is that to be put in  the other?
« Last Edit: December 08, 2010, 10:56:32 am by chizzad » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so im trying to do this basic code to get the motor to spin...

const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
 const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
 const int enablePin = 9;    // H-bridge enable pin

 
void setup()
{
   pinMode(motor1Pin, OUTPUT);
   pinMode(motor2Pin, OUTPUT);
   pinMode(enablePin, OUTPUT);

    
    // set enablePin high so that motor can turn on: ADDED
    digitalWrite(enablePin, HIGH);
}
void loop()
{
  digitalWrite(motor1Pin, HIGH);
  digitalWrite(motor2Pin, LOW);
}

if this is all correct it must be something with the connections i have. can someone verify this code should work so that i can move on from editing code to trying to fix my circuit.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

also im using this schematic with the capacitor. http://itp.nyu.edu/physcomp/Labs/DCMotorControl im not using the switch though. is this schematic still good if i did everything but the switch?
Logged

Hyderabad , India
Offline Offline
God Member
*****
Karma: 6
Posts: 621
can't help not to think arduinaizing something !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
is this schematic still good if i did everything but the switch?
Yes
but you need to use the code which dosent neeed a switch to activate the motor
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

exactly, so is the simple code i posted correct? because im still having issues and im not sure if its my code or my connections.
Logged

Pages: 1 [2] 3   Go Up
Jump to: