On our company's Christmas celebration (December 2013) all employees got a small present: A Raspberry Pi. This was the initial event for me to investigate what (internet of) things can be done driven by this tiny computer.

This blog is to document my findings and to share what others shared with me.

Freitag, 17. Januar 2014

Control motors - Part 2: PWM

"Control motors - Part 1" showed that there are less downsides on step motors than on gear-backed motors. Nevertheless to move a mowing robot of a weight of about 10kg (sometimes uphill) we need a force of about 2-4 Nm per wheel (having a diameter of 12 cm). Only gear-backed step motors can put about this level of force and those are rare and expensive. If you put gears between a wheel and a motor the motor has to rotate at the rate of the gears faster to achieve the same rotating speed of the wheel. A step motor needs 200 impulses to turn its axis around. So using a gear-backed stepper with a gear-ratio of 1:50 results in doing 26315 steps per second to gain a speed of 1 meter per second. As I found in the web it seems that stepper motors are limited to 2000 sometimes 3000 steps per second. Even if there is a stepper out there which is twice as fast it would be 4-5 times to slow. Another fact is that step motors have less torque the faster they turn. So I think this is it: I need to use ordinary gear-backed motors.

So the first challenge at using non-step-motors (ordinary dc-motors) is to control their speed. If you look at the specification of a dc-motor you will find the voltage they need to run. This value is valid for the full speed. If you want half of the speed you have to halve the voltage you putting on. But how can we achieve this by using Raspberry Pi's gpio-pins? As I said in my preceding post we have to use PWM (pulse width modulation). But what is PWM and how does it work?

PWM means switching an electric current on and off very fast. Depending on the frequency of this switching the average voltage changes. This is very useful for digital controllers (as our Raspberry Pi is) which only know 0 and 1 (current off or on).
But PWM is a special way of switching current on and off: Within a period of a choosen frequency electric current is switched on and off proportionately. I found this image at http://www.societyofrobots.com which shows how it works very well:

These three examples use all the same frequency but different pulse width (electric current is switched on) and they produce different values of average voltage.

For my first actual project I decided to build PWM as a curcuit. In the electronic tutorials I looked at the NE555 IC was used to produce timed signals. I bought the parts for exercising those tutorials, so let's ask the world for instructions. I googled and found http://www.domnick-elektronik.de/elek555.htm (written in german) showing this tiny curcuit:

I built this curcuit on my breadboard and put a LED and a proper resistor on OUT (pin 3 of NE555). Guess what: The LED dimed by turning the potentiometer. For educational reasons I replaced C1 by 10μF and voilà: The LED blinks in the way of the PWM signal.

UPDATE:
Here is a video showing the result:

Keine Kommentare:

Kommentar veröffentlichen