Author Topic: Need help in a robotic project!!  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Offline mavTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Need help in a robotic project!!
« on: December 18, 2011, 03:26:30 AM »
Hello to all  :)
I am currently working on a wall following,obstacle avoiding bot.
It works on differential drive using two dc motors.
I am using an arduino mega2560.
For distance measurement-sharp GP2D120.
For obstacle sensing-[http://robokits.co.in/shop/index.php?main_page=product_info&products_id=45]
And L293D for motor direction control.
Now i am stuck..there are two inputs to the microcontroller from the driver circuit..I want to use PWM
for controlling the motor speed and direction..WHERE TO PUT THESE TWO INPUTS ON MY MCU??
And how do i maintain a fixed distance from the wall using the sharp sensor..this is all programming part and i am
a beginner..I am in need of some help..!!

Offline seawolf

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 2
Re: Need help in a robotic project!!
« Reply #1 on: December 18, 2011, 06:55:18 AM »
The driver circuit has 2 inputs, a direction and a speed. The direction input should be wired to a digital output on the arduino, and the speed input should be wired to an analog output.

Once you get the sensors working you'll need to start working on the controller. A simple controller would be:
a=distance_from_wall
offset=Constant*(Distance_from_wall - Desired_Distance_From_Wall)
 if offset>(255-150), offset=(255-150)
Left_motor_speed=150+offset
Right_motor_speed=150-offset

This would give you proportional control, which should get you up and running.
Note that the 255 is the max speed of the motor, and 150 is the default speed of the robot. You can change the 150 to something higher once you get the lower speed version to work. Don't change the 255 though.

Once you get it working decently with proportional gain, you might want to try PID control.

Offline mavTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Need help in a robotic project!!
« Reply #2 on: December 20, 2011, 01:02:08 AM »
Thanks for the reply.
Quote
The driver circuit has 2 inputs, a direction and a speed. The direction input should be wired to a digital output on the arduino, and the speed input should be wired to an analog output.
How to know which one is for direction or speed control?
Could you please provide some code for the PID control?
Thanks!!

Offline seawolf

  • Jr. Member
  • **
  • Posts: 10
  • Helpful? 2
Re: Need help in a robotic project!!
« Reply #3 on: December 20, 2011, 02:23:17 PM »
If you bought a motor controller board then the inputs are usually labeled. If you just have the IC then you can look at the datasheet and figure out how it's supposed to be wired up.

I don't have any arduino code handy, but try implementing the pseudocode I gave you. That should get you started. Full PID control may actually be a little overkill.

 


Get Your Ad Here