2 DOF robotic arm, (double pendulum)

This program i have written for controlling of 2 DOF arm. When i give inputs as X and Y values…motor positioning should be done according to inverse kinematics calculations. The problem here is Sensor value is not updating continuously and motor is not stopping at specified sensor value.

  1. 2 dc motors
  2. 2 rotary encoders - feedback
  3. L293D motor driver.

me.ino (5.3 KB)

If I didn't miss anything you read the encoders exactly once per command received from the serial interface. These polls have to be done continuously, at least while the motors are turning.

In encoderinit() you have to blocks of code. What's the reason for that? The compiler doesn't need it.

If you want to position the arm accurately with DC motors, you will most definitely need PID closed loop control. Without some sort of closed loop control algorithm, your arm will be useless.