Let's Make Robots!

MCU for custom i2c motor driver

Ok supposing that i want to make my own motor controller, i'd like it to be controlled by i2c. What microcontroller could i use that can be used as i2c slave? Afaik, picaxe can only work as master, right ?

Possibly someone that doesn't need an hardware programmer :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Any microcontroller that can be a master on I2C should also be programmable to be a slave on I2C. Essentially a slave waits for the other end to pull down the SCL line to start communications. So any MCU, even those that do not have I2C or TWI in hardware, could be programmed to use this (or other) protocols. The slang term used when a protocol is programmed in is "bit-banging". It is generally easier to use a micro that supports it natively.

yes, indeed i'd like to avoid bit banging.. Not that it is overly hard, but if it can be native it's better :P

picaxe have Basic instruction to behave as master but not ones to behave as slave (see), differenlty for example Arduino have both.. But arduino is a whole board, not a single chip.. maybe i could use an AVR but i don't really know how to program it :P

well basically isnt an arduino just an atmega168 and a few support components,  like resistors and caps and a 7805?  the only other things really of note is the FTDI USB-Serial chip and resonator. 

you could probably do this with a standard diecimila, the adafruit motor shield(http://www.adafruit.com/index.php?main_page=product_info&cPath=17_21&products_id=81), and some programming.

the total cost of that would be $35(arduino)+$19.50(motor shield) = $54.50  which is cheaper by a long way than an MD22, but certainly nowhere near as powerful.

you could also buy the preprogrammed serial driver chip pololu uses (http://www.pololu.com/catalog/product/210)  and just build a better board to host it. Unfortunately pololu's ones are a bit finicky i've found.  That MCU should theoretically be able to work with any h-bridge that is l293 compatible, like an SN754410 or L298.  It's not I2C, but its an I2C-like serial protocol, in that it has device addresses.

yet another option is to get one of these( and simply improve it's software...


After a brief Google search, a couple links turned up in the PICAxe archive, pointing to this page :


Don't know if it works, but sounds pretty authoratative.

Any MCU can be master or slave if you bit-bang. Any PIC which has I2C hardware can be a slave without bit-banging. Only PICs which have MSSP can be a I2C master without bit-banging.

Look at the Microchip 8-bit parametric search here. Select "I2C <> 0." Hit Search then Detail and you will see a list of all8-bit PICs with I2C hardware (no bit-banging required).

Narrow the search to include flash devices / in production / small pin count / internal clock / whatever other features you want...

Don't forget to set the package type to DIP or you'll prolly end up with a chip that's too small to work with!

Browse the Microchip application notes: they even give you code to do it!

Fraid I can't help with picaxe, though.

thanks! i've found some interesting chip.. but a question: how do you program this pic ? do you need an external programmer ? sorry for my ignorance :)

Hi Nicola,

I know my PICAXE 40X1 can be both I2C master and slave... and you know those critters don't need much programming hardware.

Other than that I have some ATtiny26's that have an USI (universal serial interface or something like that) that can be used for I2C. Basically that means that it will generate interrupt when data is ready and then you need to write a handler for that. I haven't tried it yet though. The ATtiny's need a hardware programmer though.

yes i was just reading about attiny 24 & 26, they're good, but again need a programmer (not so expensive, but..)

could you copy a simple example for i2c slave code for picaxe 40x1 ? 

Check the picaxe manual 2 and look up hi2csetup
Thanks guys.. i completely overlooked that hi2cxxxx stuff. That could be useful :)