Serial with avr

I have an AVR butterfly which have one serial port. I am using this port to comunicate to a cell phone, but I would also like to comunicate with the picolu mini servo driver board. Is there any way to do this. I have spi and i2c free for the moment.

Cheers Kim

Hi, Kim.

Just to be clear, you are trying to communicate with our micro serial servo controller? You can only communicate with our serial controllers using serial (they are not designed to communicate via SPI or I2C), so if your only serial line is being used it seems like you only have one option: bitbang serial on another set of I/O lines. I’m not sure if you’re familiar with this, but bitbanging serial means that you use software to transmit and receive serial signals on an arbitrary I/O line rather than using the AVR’s hardware UART. Because it’s software, it’s processor intensive, but it allows you a great deal of flexibility when it comes to the number of serial connections you can simultaneously have and which pins you use for these serial connections.

I’m sure there are a number of software serial libraries out there for the AVR; I suggest you try searching for “bitbang serial” or “software serial” (or perhaps google “bitbang serial AVR”).

One last thought is that perhaps you could communicate with both your cell phone and servo controller using the same serial line. The communication protocol for our serial and motor controllers is such that you can have many of them on the same serial line. Can you perhaps program your cell phone communication protocol to be compatible with our Pololu serial controller protocol? Do you even have any control over the communication protocol you use to talk to your cell phone?

- Ben

It’s a tad complicated, but if you would like to use just hardware, you can use the ATMega169’s Timer0 and USI as a second UART (serial port). It will only provide half-duplex operation, which means it can send and receive, but not both at the same time. This shouldn’t be a problem, since you only need to send bytes to the servo controller.

For more information, check out AVR307: Half Duplex UART Using the USI Module.

So, what on earth are you planing to do with a cell-phone/butterfly/servo controller?


Thanks for the info, Adam. I’ve never used an AVR Butterfly/mega169, so I had no idea about the USI module. That’s definitely good to know!

- Ben

Thanks, will look into the usi interface, Might run out of ports on the butterfly if I use though. Will keep u posted.