I2C Motor Driver
From Ywiki
This project is part my robot project called Maggie. This robot has two sets of motors. They both have to be driven with individual h-bridges.
Contents |
Hardware
Schematics
The schemetics can be devided in two parts. The first part is the Microcontroller, which is responsible for recieving I2C messages and generating PWM signals. The second part is the motor driver, which drives the two pair of motors.
Microcontroler
For the microntroller I used a PIC16F690. This controller has a few features why I've choosing this one:
- Internal RC oscilator
- Low cost
- I2C support
- 4 PWM outputs
Motor driver
For the motor driver I've choosen a L298 motor driver. This is a dual reversible motor driver. Why I've choosing this one:
- Easy to control
- Single component
- Low cost
- Overheat/current protected
- Drive up 2A per h-bridge
Each pair of motors has its own screw connectors. I2C, power and other signals are connected via an 10-way connector. See schematics for details.
PCB
The PCB is a professional made one. I designed it myself and let manufacture in China. This way I get nice looking PCP whiteout high costs. A piece of aluminum is bolted to the L298 to prevent it from overheating. See pictures below:
software
I have uploaded the source file to this wiki. here I've also uploaded a compiled version of this software: here
protocol decription
The motor driver can be identified by a type number and by a version number.
Reading the type identifier
To read the type identifier write 0x00 to the device, then read a single byte from it. The read byte is the type identifier, and is always 0x01 for a i2c motor driver.
Reading the version number
To read the version number write 0x01 to the device, then read two bytes from it. The first byte represents the major version number, the second byte represents the minor versin numner. The current released version is 1.4
Driving the motors
To drive driver the motors three bytes must be written to the device.
- The first byte is static 0x02.
- The second byte contains the configuration.
- The first nibble sets the operation mode. For now only 0x1, DC operation is supported.
- The second nibble sets the direction for both DC motors. 0 = right, 1 = left. Bit0 represents the motor connected to 1, j5. Bit1 represents the motor connected to 2, j1
- The third byte contains the speed in a range of 0 to 255.
If you have any questions please send me a email.
