Pages: [1]   Go Down
Author Topic: autonomous car  (Read 3388 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm doing a school project and i want to build a car that goes in a set path with object avoidance.
I want to put an IR-proximity sensors and an Ultrasonic distance sensors.With a SN754410 based dc motor driver.I can do all the circuity but I am not that good at the programming.Can anyone help me and give me a code please using these parts or any suggestions it would really help.In a later ver. I want to add an gps.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 40
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No offense, but as a school project this would be a good learning opportunity for you.  If there is something that bugs me it is electrical engineers who refuse to program.
Logged

http://ilektron-x.blogspot.com - Hacking and General Electronics Goodness

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to learn but it still makes no senses to me and it has a do date,so by the time it does make  senses to me it will probably be due or have one day left to program. I want to do projects for fun later when I learn to program.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9701
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Google is your friend as this is a very common project. Are you allowed to use a purchased kit?

http://www.google.com/search?q=object+avoidance+robot+site%3Ahttp%3A%2F%2Farduino.cc%2Fforum%2Findex.php&hl=en&num=100&lr=&ft=i&cr=&safe=images

http://www.google.com/search?q=object+avoidance+robot&hl=en&num=100&lr=&ft=i&cr=&safe=images
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Good links and no kits.I don't want it just to randomly drive around.I want it to drive to a specific location with object avoidance, good link still helped me understand the coding better.
Logged

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9701
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't want it just to randomly drive around.I want it to drive to a specific location with object avoidance,

Your project has several parts. You may want to work on just making the bot drive to a specific location first.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes,I was but then I thought to throw in the sensors.I am going to do that first tho. Then later on add more sensors to it and ultimately have i control an airplane for fun.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


My school project is that of an autonomous vehicle as well, am having an issue with the timing of things if someone has some ideas, would be much appreciated.

Firstly, my hardware:

Arduino2560
SN754410 (H-Bridge)
Sharp IR GP2D120 (sensors)
Two motors with gear reduction of unknown specs. (an old RC car)

Now my issue is with the timing from the sensor (object detection) to the output of the motor. If I disable my motor when my sensor value is at a range, by the time the motor shuts off, slows down from momentum, it hits the wall.

So I used the PWM output pin to half the duty cycle, this improved things, but its still not stopping quick enough.
(at quarter, there wasn't enough power to move the vehicle, I thought about changing this mid-cycle, like a gear change, haven't tried it yet)

I thought about throwing the motor in reverse, by switching the outputs, for delay(x) then disabling, but not sure how much damage and strain this will do on the Arduino, batteries, H-Bridge.

If someone can confirm if any damage occurs to the SN754410 , or arduino whilst switching from forward to reverse immediately, would be appreciated.

If you require code, I will need to change comps, let us know.


 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It shouldn't strain the arduino,h brige,or motor,as many people do this to slow down there cars. Just don't hold the car in place with the motor on as electric motors have 100% of there torque when stopped an on full power witch in this case can do it if you don't have metal gearing like in more top brand cars. Hope this helps
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the fast confirmation, appreciate it!!

No need to worry about full power stall, as its only locking up with my bad tuning when it hits a wall, with the confirmation of being able to slow it down, will fix this soon.

The steering drive, has a slip gear on the reduction, so once its full left/right, nothing stalls the motor. 

 

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First I can understand your feeling so far as a student in the school. All I want to know is you don' t have the coach from the teacher.Anyway I'm still a beginner for the Arduino. I purchase board from Taobao.com in China. And I'd like to share you some of my material for you. All the following is not exactly what you really need maybe, but I positively think you can start it up and just put the ultrasonic sensor together in the Arduino.
The vehicle platform. You also can visit the link(I don't mean a adv.) hope you don't mind the chinese web page. you can build the whole picture in this project.
http://trade.taobao.com/trade/itemlist/listBoughtItems.htm?action=itemlist/QueryAction&event_submit_do_query=1&prePageNo=1&clickMore=0&pageNum=2
Attach the program code as following, please ignore the chinese comment. I manually comment in English, wish it's helpful to you.
Code:
void setup()
{
  pinMode(8,OUTPUT);//定义I1接口                                define I1 port
  pinMode(9,OUTPUT);//定义I2接口                                define I2 port
  pinMode(10,OUTPUT);//定义EA(PWM调速)接口                      define EA PWM
  pinMode(5,OUTPUT);//定义EB(PWM调速)接口                       define EB PWM
  pinMode(6,OUTPUT);//定义I4接口                                define I4                            
  pinMode(7,OUTPUT);//定义I3接口                                define I3
  pinMode(3,INPUT);//定义左侧避障                               define left aviod obstacle sensor
  pinMode(4,INPUT);//定义中间避障                               define middle aviod obstacle sensor
  pinMode(11,INPUT);//定义右侧避障                              define right aviod obstacle sensor

}
void qianjin(int a)//前进                                      go forward sub
{
     analogWrite(10,a);//输入模拟值进行设定速度                analog value to set the speed
     analogWrite(5,a);                                        
     digitalWrite(7,LOW);//使直流电机(右)顺时针转            enable Right DC Motor clockwise rotate
     digitalWrite(6,HIGH);
     digitalWrite(8,HIGH);//使直流电机(左)逆时针转           enable Left DC Motor counter-clockwise rotate
     digitalWrite(9,LOW);

}
void youzhuan(int b)//右转                                     Turn right
{
     analogWrite(10,b);//输入模拟值进行设定速度                analog value to set the speed        
     analogWrite(5,b);
     digitalWrite(7,HIGH);//使直流电机(右)逆时针转           enable Right DC Motor counter-clockwise rotate
     digitalWrite(6,LOW);
     digitalWrite(8,HIGH);//使直流电机(左)顺时针转           enable Left DC Motor clockwise rotate
     digitalWrite(9,LOW);

}
void zuozhuan(int c)//左转                                    Turn Left
{
     analogWrite(10,c);//输入模拟值进行设定速度              analog value to set the speed  
     analogWrite(5,c);
     digitalWrite(7,LOW);//使直流电机(右)顺时针转          enable Right DC Motor clockwise rotate
     digitalWrite(6,HIGH);
     digitalWrite(8,LOW);//使直流电机(左)顺时针转          enable Left DC Motor clockwise rotate
     digitalWrite(9,HIGH);

}
void tingzhi()//停止                                         Stop
{
     digitalWrite(7,HIGH);//使直流电机(右)停转            enable Right DC Motor stop
     digitalWrite(6,HIGH);
     digitalWrite(8,HIGH);//使直流电机(左)停转            enable Left DC Motor stop
     digitalWrite(9,HIGH);
}
void houtui(int d)//后退                                    Go backward
{
     analogWrite(10,d);//输入模拟值进行设定速度             analog value to set the speed      

     analogWrite(5,d);
     digitalWrite(7,HIGH);//使直流电机(右)逆时针转       enable Right DC Motor counter-clockwise rotate  
     digitalWrite(6,LOW);
     digitalWrite(8,LOW);//使直流电机(左)顺时针转        enable Left DC Motor clockwise rotate
     digitalWrite(9,HIGH);
}
void loop()
{
    int r,m,l;
    r=digitalRead(11);
    m=digitalRead(4);
    l=digitalRead(3);
    if(l==HIGH &&m==HIGH && r==HIGH)
    qianjin(200);
    if(l==LOW &&m==LOW  && r==LOW )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==LOW &&m==HIGH  && r==LOW )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==HIGH  &&m==LOW  && r==HIGH  )
      {
        houtui(200);
        delay(300);
        youzhuan(200);
        delay(300);
      }
    if(l==LOW &&m==LOW  && r==HIGH )
    youzhuan(200);
    if(l==LOW && m==HIGH && r==HIGH)
    youzhuan(200);
    if(l==HIGH &&m==LOW  && r==LOW )
    zuozhuan(200);
    if(l==HIGH &&m==HIGH  && r==LOW )
    zuozhuan(200);
}




* RP5.jpg (84.34 KB, 600x450 - viewed 26 times.)
« Last Edit: December 11, 2011, 06:33:29 am by crzy_suzhou » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

continue interprete DC driver.
http://robotbase.taobao.com/search.htm?spm=11028vrd.3-1lRnb.6-2sLVzs&scid=123975700&scname=1rHB97Xnu%2FrH%2FbavsOU%3D&checkedRange=true&queryType=cat
There is another project using the ultrasonic sensor to detect thing 50cm and light up the light.  ultrasonic sensor is RB URF v1.1
http://item.taobao.com/item.htm?spm=11028vrd.3-1lRnb.2328234110&id=2723263199&
Code:
int inputPin=4;  // 定义超声波信号接收接口          define the ultrasonic receive port 
int outputPin=5; // 定义超声波信号发出接口          define the ultrasonic emitting port
int ledpin=13;
void setup()
{
  Serial.begin(9600);
  pinMode(ledpin,OUTPUT);
  pinMode(inputPin, INPUT);
  pinMode(outputPin, OUTPUT);
}
void loop()

{
  digitalWrite(outputPin, LOW); // 使发出发出超声波信号接口低电平2μs        disable ultrasonic emitting 
  delayMicroseconds(2);                                                      delay 2μs
  digitalWrite(outputPin, HIGH); // 使发出发出超声波信号接口高电平10μs,这里是至少10μs      enable ultrasonic emitting,
  delayMicroseconds(10);                                                                      delay 10μs
  digitalWrite(outputPin, LOW);    // 保持发出超声波信号接口低电平                           disable ultrasonic emitting 
  int distance = pulseIn(inputPin, HIGH);  // 读出脉冲时间                                    read pulse
  distance= distance/58;   // 将脉冲时间转化为距离(单位:厘米)                              convert pulse into distance
  Serial.println(distance);   //输出距离值                                                   serial output distance
  delay(50);   
  if (distance >=50)
  {//如果距离大于50厘米小灯亮起                                     if distance is greater than 50cm, light the LED
     digitalWrite(ledpin,HIGH);
  }//如果距离小于50厘米小灯熄灭                                       if distance is smaller than 50cm, go out the LED
  else
     digitalWrite(ledpin,LOW);
}


* untrasonic sensor.jpg (47.12 KB, 600x450 - viewed 25 times.)
Logged

Pages: [1]   Go Up
Jump to: