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.

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 ? 

The 28X1 can also be used as a slave.

 

HI2CSETUP I2CSLAVE, slaveaddress

 

Setting up the picaxe 28X1 or 40X1 as an I2C slave enables an I2C master to read and write the scratchpad.  

 

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

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 :)

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

http://www.kranenborg.org/ee/picaxe/twowirenetwork.htm

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

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