Embedded Systems/Interfacing Basics

From Wikibooks, open books for an open world
Jump to navigation Jump to search

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[edit | edit source]

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[edit | edit source]

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.

The sink value is the amount of current that can flow into the pin (and therefore into the microcontroller) safely.
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[edit | edit source]

Ohm's law, one of the fundamentals of electronics 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. This holds true for DC, for AC, it is a bit more involved. Let's do a DC 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, depending on what you are trying to accomplish it is important evaluate both the sink and source currents limits, and what your circuit is expecting to sink or source. A common example is the use of a resistor in series with a LED, the resistor limits the amount of current sourced from a microcontroller. Here the choice of a resistor will depend on the chosen LED and desired brightness, where larger resistance (less current flow) will dim the output of the LED.

Further reading[edit | edit source]