|
HB3x2 Dual 3 Amp H-Bridge for Robotics
| |
How To Use the HB3x2 with an AVR Microprocessor
This guide uses WinAVR for the programming language and an ATmega328P as the target chip. Some internal register names may change with a different target but the concepts will remain the same.
We are going to connect the AVR to the HB3x2 with 2 standard I/O pins and 2 PWM outputs. We have chosen PortB0 and PortB1 as the standard I/O pins and OC0A(PortD6) and OC0B(PortD5) as the PWM outputs.
We will use PortB0 and OC0A for Motor1, and PortB1 and OC0B for Motor2.
We will consider PortBx high as forward, and PortBx low as reverse. This may not be the same as your hardware so you may have to change this in your code.
We have chosen to use "phase correct PWM" from the ATmega328P data sheet.
AVR Hookup Diagram
For this code we are going to wire up the circuit as follows:
AVR |
HB3x2 |
PortB0 |
1A |
OCR0A (PortD6) |
1B |
PortB1 |
2A |
OC0B (PortD5) |
2B |
AVR Source Code
You can get a copy of the source code in C here.
If you have any questions email me here: jason (at) efundies.com
* Free shipping offer valid only in the United States.
|