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.

Samstag, 25. Januar 2014

Control motors - Part 4: H-Bridge

As I mentioned in my last post I have to wait for the delivery of the parts I ordered. In the meantime I will continue blogging. So what we've got until now is: We have chosen a proper type of motor, we have discovered how to control the speed of the motors and we figured out how this can be done by Raspberry Pi's gpio-pins. If we want to plug these things together we have to buy a test-motor to be sure that everything works as expected.

One of the characteristic features of a motor is the voltage needed to run in full speed. But unfortunately most motors have different voltage values as Raspberry Pis 5V output. Additionally the 5V port gives insufficient power to run one motor let alone two of them (see http://elinux.org/RPi_Low-level_peripherals). So it seems that we need different power sources for the Raspberry Pi and the motors. This would allow us to choose the motor (nearly) independently to the current the Raspberry Pi needs to run. There is one thing to be considered if doing so: the motors voltage value should not be too close to 5V.

Finally the mowing robot's power source will be a battery. For the sake of simplification I decided to connect the motors to the accumulator directly. The controlling Raspberry Pi has to be connected to a battery, too. However, accus usually have voltages of multiples of 1.2V. So you will get 4.8V with using four cells or 6V with using five cells. But the range of voltage for Raspberry Pi's power supply is between 4.75 and 5.25V. Additionally fully charged batteries have more voltage than nearly discharged ones.
So we need a step-down constant voltage module if the batteries voltage is higher than 5V or a step-up if it is lower. Those modules work best if there is enough scope between the source voltage and the destination voltage (I read it has to be at least 1.5V).

So as I have to use a battery different to 5V (at least 6.5V) I can connect the constant voltage module to the motors' accu, too. The only condition is that the nearly discharged accus voltage is at least at 6.5V. I have chosen 12V. The main reason for this is that the motors I want to use (http://m.conrad.at/ce/de/product/233132/) are only available at 6V or 12V and 6V is too less.
I also want to mention that it would be possible to use 8.4V accus and two step-down converters: one for the Raspberry Pi's 5V and one for the two motors. In this situation I could also use the 6V motors. But I read that motors of higher voltages need less electrical current because the electrical resistance is lower as higher the voltage is (this is also the reason for using high voltages in high-tension lines).
Another challenge is to enable the motor to run in both directions (forward and backward). This can be done by exchanging plus and minus. But if the robot has to go backward we cannot unplug the motor and plug it in the other way again. This has to be done by an electronic circuit. Additionally the circuit has to manage the connection of Raspberry Pi's 5V and the motors 12V. Both features are covered by an h-bridge (see http://en.m.wikipedia.org/wiki/H_bridge).

If you do some research you will find out that there are many other things which has to be considered in conjunction with h-bridges: Motors produce inductive currents on stopping which have to be discharged, the PWM-signal has to be applied to the motors power supply, not running at full speed will produce heat which has to be dissipated and also monitored. There are many things which can go wrong so I decided to look for an IC which is able to handle all these things for me. What I found is this http://www.shop.robotikhardware.de/shop/catalog/product_info.php?products_id=89 (I'm sorry this site is written in German). Only a few parts have to be assembled and once done the motor can be controlled by four pins at 5V-level:
  • IN A at high and IN B at low: The motor goes forward
  • IN A at low and IN B at high: The motor goes backward
  • IN A and IN B at high or low: The motor breaks if rotating
  • PWM: Input-pin for the PWM-signal
  • GND: The 5V-level ground
...and four pins at 12V-level:
  • POWER and POWER-GND: The place where the battery has to be connected.
  • MOTOR and MOTOR-GND: The place where the motor has to be connected.
Pretty easy, isn't it?


Once I have received the parts (including the IC used as the h-bridge) I will do the assembling and report about it in an upcoming post.

Keine Kommentare:

Kommentar veröffentlichen