Go Down

Topic: Turning a motor into a servo (Read 2 times) previous topic - next topic

Fons1302

#10
Feb 14, 2011, 05:05 pm Last Edit: Feb 14, 2011, 09:20 pm by Fons1302 Reason: 1
@ jackrae:

I have a mechanical setup in mind that is quite compact and simple.
I have some problems with using accelerometers:
- I need the orientation (and not the movement) of my head relative to my torso. If I move my whole body (running in all directions) the accelerometer will give values while I keep my head still relative to my torso.
- The accuracy is not great, I would like to have about 1,5° of accuracy. I think it is not the case with acelerometers.
- I need a sensor that detects the horizontal plane and measures the difference with its plane relative to the horizontal. I don't know if accelerometers can do that. Which sensors can measure the deviation from the horizontal plane? I know that an Iphone can sense the horizontal.
- I would like to try mechanical feedback (if you can't move your robot head it should give you the feeling you can't move your head).
- I must convert the accelerometers data into angles. With my mechanical approach I must only copy-paste the absolute position of the encoder to the robot head. OK once you got the code this is not an issue.

Correct me if I'am wrong, judging with falls information is not a good judge.

UPDATE:

When I use PWM signals at 10kHz the motor makes a small noise but doesn't move. I guess 10kHz is too much for my DC motor?? If that is the case my motors are not good for precision positioning (http://www.pololu.com/catalog/product/1107) and I need other ones, perhaps with a larger gearing? Or what else can make precision positioning possible?? The motor driver can handle 20kHz PWM pulses so no problem with that.

fliggygeek

http://www.sparkfun.com/products/9238 Stepper Motor
http://www.sparkfun.com/products/10267 Stepper Driver board (does two steppers)

http://translate.google.com/translate?js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&sl=auto&tl=en&u=http%3A%2F%2Flusorobotica.com%2Findex.php%2Ftopic%2C106.0.html Tutorial (Sorry its in translated Portuguese)

Whole setup should cost you no more than $60USD, will get you running in no time.
Use the analog inputs for your continuous rotation pots, the serial for the driver board, you'll be all set.
"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Fons1302

Great links fliggygeek!

I must make a tough decision now. I consider three choices:
- continue with what I have and look for a good working PID code. Not sure if I ever can achieve good results but it is the cheapest choice.
- Use a stepper motor setup (from sparkfun) like fliggygeek proposed. It fits in my budget and looks straightforward and relatively simple to set up and use.
- Get a Jrk motor controller from Pololu. Here I'am sure about the results (seen a video and goes fast and accurate). The price for a single controller is not cheap but maybe I can use the motors I have.

For the first and third option I doubt that my 131:1 motors are good for it. At high PWM frequency it doesn't move at all (just makes noise). My motor driver looks pretty useless for positioning tasks as long as I don't have good code. Maybe I can sell them!

Thanks everybody for the input. My view on the subject has surely improved and I am reconsidering different aspects of my project (which is good cause I went a bit to fast for a beginner).

fliggygeek

"Output loads can be pulse width modulated (PWM-ed) at frequencies up to 20 kHz." got that off your motor driver site, seems the driver IC works, I might suggest getting some cheap DC motors and chuck them on the driver to see if they work at the higher frequency. This will determine if it is an issue with your motors or the driver circuit.
"Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent di

Fons1302

#14
Feb 16, 2011, 07:58 pm Last Edit: Feb 16, 2011, 08:01 pm by Fons1302 Reason: 1
Yes indeed. It can make up to 20kHz PWM signals. But the limitation is the Arduino's PWM frequency limits I think. I don't know how much it is but I use the code below to test the motor at variable pulse width and frequency. Should it work?? Cause I can only get the motor turning (sloooow) at freq= 900 with pusle=850 and freq=1000 with pulse=900 (all in microseconds). If this code is correct its clearly the motor reached its limits (1kHz is too much).

void setup()
{
 Serial.begin(9600);
 pinMode(13, OUTPUT); //motor B output
 pinMode(12, OUTPUT); //motor A output
 pinMode(11, OUTPUT); //PWM output
}

void loop()
{
 int freq = analogRead(0); //change PWM frequency in microseconds (100 = 10kHz)
 int pulse = analogRead(1); //change pulse width in microseconds (1000 = 1kHz)
 freq = map(freq, 0, 1023, 50, 1000);
 pulse = map(pulse, 0, 1023, 50, 1000);
 Serial.print("pulse:"); // use this code so I can check both values during testing
 Serial.print(pulse, DEC);
 Serial.println();
 Serial.print("freq:");
 Serial.print(freq, DEC);
 digitalWrite(13, LOW);
 digitalWrite(12, HIGH);
 digitalWrite(11, HIGH);
 delayMicroseconds(pulse);
 digitalWrite(11, LOW);
 delayMicroseconds(freq-pulse);
}

Go Up