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

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 PWMfor 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 ama beginner..I am in need of some help..!!

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_walloffset=Constant*(Distance_from_wall - Desired_Distance_From_Wall) if offset>(255-150), offset=(255-150)Left_motor_speed=150+offsetRight_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.