Embedded Systems/Interfacing Basics
Template:Embedded Systems/Page
Having our embedded system, with a fancy operating system is all well and good. However, embedded computers are worthless if they can't interface with the outside world. The chapters in this section will talk about some of the considerations involved with interfacing embedded systems.
Pins and Ports
Many embedded systems will provide a series of output pins for transmitting data to the outside world. These pins are arranged into groups called "ports". Ports will frequently (but not always) consist of a power-of-2 number of pins. For instance, common ports might be 4 pins, 8 pins, 16 pins, etc. It is rare to see ports with fewer then 4 pins (because in that case, they probably aren't called ports anymore).
Current and Power
When working with a particular microcontroller, it is very important to read the datasheet, to find out how much current different pins can handle. When talking about current, datasheets will (usually) mention 2 words: Sink and Source.
- Sink
- The sink value is the amount of current that can flow into the pin (and therefore into the microcontroller) safely.
- Source
- The source current is the amount of current that can be pulled out of the pin safely.
If you exceed the sink current or the source current on a given pin, you could fry the entire processor, which means added expense, and more time. It is very important that you try to limit the amount of current flowing into and out of your pin.
Ohms Law
Some people would like to never see Ohm's law again, and some people have never seen it before. Ohm's law relates the voltage and the current of a given circuit together, as such:
Where v is the voltage, i is the current, and r is the resistance of the circuit. Let's do an example. We have a microcontroller with output pins that can source 20mA (mA = milliamps), and goes from 0V(for a logical "0") to +5V (for a logical "1"). Using Ohm's law:
keep in mind that the resistance is the minimum value necessary to meet the requirements, we could easily pick a resistor with 300Ohms, or even 1KOhm if that was all we had. It is very important to note that diodes, transistors, and relay circuits (all of which are common in embedded systems) can be considered to have an effective resistance of 0. Therefore, it is very important to place resistors in a circuit to control the current flow.