Arduino as a dc motor controler

A

Thread Starter

amatic

Hello,

I'm learning control theory. I'm building a robot arm and I'm making my own servos for each joint. An arduino is used as a digital controller for the angular position of joints.

It works, and I am interested in ways to improve it's functioning, and which way of improving would be most cost-effective.

I'm using mini dc geared motors, like these: https://www.sparkfun.com/products/8910
I'm using a 9V power supply. Arduino provides logic and pwm signals to h-bridge chip SN754410.

Sensor is a 2.5 kOhm linear potentiometer, mounted on the output shaft of the motor.

Arduino has a 10 bit ADC to read from the sensor (last digit noisy). Velocity is estimated as the change of position from previous loop. Loop frequency is 100Hz.

I have an inner velocity loop and an outer position loop. Gains and other variables can be set from the computer. Velocity estimation is noisy.

Does any of this sound improvable so far?

Here is some relevant code:<pre>
[p]
starttime = micros ();
ref = analogRead (1);
pos = analogRead (0);

err = ref - pos;
vel = pos-lastpos;

lastpos = pos;

Qo = Kp*err - Kv*vel;

Qo = constrain (Qo, -255, 255);
Output (Qo);

DebugOutput();

if (starttime-micros() < period) // period is 10 000 microseconds
{ };
[/p]</pre>
 
Top