Serial Communication
I know I was supposed to talk about the power supply schematic, and I promise I will get to that. Right now I plan to talk about serial communications between two microcontrollers and the outside world. Since I decided to go with 2 microcontrollers for my new mini sumo board, I realized they needed to communicate. There were several choices that could be used. You have the USART, SPI, and I2C/TWI ports on the AVR. Each serial comm port has its uses and issues.
USART
USART stands for universal synchronous/asynchronous receiver/transmitter. The USART (or UART) was a serial communications port that used to come with your computer, though that has mostly been replaced with USB. The USART is some times called RS-232. Really RS-232 is an electrical specification that also specifies a connector. The USART was either an external chip or hardware built into the microcontroller. I could go through the entire history of the USART and RS-232, but I won’t. That is information you can look up on your own if you want it. These days you will use a USB to Serial port converter or bridge IC. One end will plug into your computer, while the other will connect to your micro. This is the interface I’ll use for my board to talk to my PC. As I start working on the software development, I will revisit this interface.
SPI
SPI or the serial peripheral interface was designed to allow microcontrollers with limited numbers of pins to control external peripherals like I/O ports and serial EEPROM. Where the USART was normally used for computers to talk back and forth, the SPI bus was mainly used in a master and slave configuration. The microcontroller was the master and the peripheral was the slave. This allowed the designer a way to save pins on their microcontroller, which can be a limited resource. Since the microcontroller typically has all the required hardware, you can make the chip either a master or a slave depending on the needs of the design.
I2C/TWI
I2C/TWI is a serial communications interface originally designed by Philips (now NXP Semiconductor). I2C stands for Inter-Integrated Circuit bus. Where as the name I2C is copy written, TWI (two wire interface) is not, so many semiconductor companies use TWI to mean I2C because of licensing issues. None of that is really important here. Just remember that when I write I2C, I also mean TWI.
The I2C interface was designed from the beginning to be a multi-master bus. This meant several masters and slaves could share the simple two wire communications bus. This bus also has electrical specifications you need to be aware of. Most importantly is that the data and clock lines need pull up resistors. The value of these resistors is dependant on how strong of a pull up you need and capacitive loading on the signal lines.
OK, so…
Why am I going over all of this, so you can understand why I designed the circuits the way I did. I am planning to use the USART for communication back to a PC. Wireless communication could also be used. One of the most popular is the XBee radios. This would give you a way to send data back and forth between your computer and microcontroller without wires. The software overhead of communicating with the USART is minimal, around 100 bytes. Software is not the issue, just the fact I am using this interface to talk with a computer means I will have to use one of my other options. So how about using the SPI bus to talk between the micros? Again the amount of software over head is small. The issue is that the SPI port is also the in circuit programming interface. This complicates programming the devices individually, requiring some extra hardware. I will have to explore this a little more. That leaves the I2C port. The hardware requirements are not an issue, so this looks like a good idea. The only issue is the software, it requires a greater amount of code to handle the internal hardware. That could be an issue for flash limited devices.
So as I look at the problem in front of me, what I really need to do is write some code to test the 3 serial busses between a mega328 and a tiny24 micro. This way I can figure out which interface to use. This is also going to need some reading of the data sheet of the tiny24 as it has USI (universal serial interface) which is all 3 interfaces combined into one module in the micro. So much for things being easy.
So I am off to do some coding to test the serial busses. Then I can work on finishing the schematic and finally present the power supply and the rest of the electronics. Until then I hope this has been informative.