Embedded System

 

 

 

 

Communication Interface Selection

 

Personally to me, the simplest definition of Embedded System is a Microcontroller controlling/communicating with a bunch of peripheral devices (e.g, sensors and actuators, display, WiFi module, Cellular Module).

 

Then the next questions is how do we connect to those peripheral device ? The most common method of connections that almost every Microcontroller would be as follows.

  • i) GPIO
  • ii) UART
  • iii) I2C
  • iv) SPI
  • v) USB   // Not so common, but some Microcontroller support this
  • vi) CAN  // Not so common, but widely used for Microcontollers specialized in Automotive application

 

Then the next question would be 'which communication / connection method do I need to use for the specific module/device that I have now ?'.

Unfortunately there is no single / clear-cut answer to this question.

 

Then, why do bring up any question which does not have any answer ?

It is just to let myself to think something at system level (at high level).. and hopefully to give you the same chance.

Actually 'There is no answer for this question' might not be the correct statement. I should have said 'the answer IS an answer, but the answer varies depending on situation'.

 

My pesonal guideline to select the communication /connection method is pretty simple (this is purely my personal opinion and you may not agree..).

 

First Criteria : I will pick up whatever interface the target module (peripheral device) support. In most case, a microcontroller provide various different types of communication interface, but most of the peripheral device support only one or a few. When the device/module support only one communication interface, just use that one. For example, the device support only I2C, just use it.. if the device support UART, just use that. For some reason, if you really want to use the communication interface that the device does not support, you need to use another interface circuit/module for translating the communication/connection method and of course it will cause additional cost and your system more complicated.

 

Second Criteria : If your peripheral device/module support multiple communication method and you need to chose one of them, then you can think of various other criterial like data rate, complexity, current consumption and the distance from the microcontroller etc.  If a module support I2C and other connectivity (e.g, UART, SPI, USB), I personally chose I2C because it is very simple to use in both hardware and software, easily controll multiple device using single/common wiring (like bus) and current consumption is pretty low. However, relatively high data rate (e.g, in Mbps scale) I would chose SPI. If the peripheral device is Cellular module (e.g, GSM/GPRS, 3G, LTE etc), I would use UART since most of those module (cellular modem) is controlled by AT command over UART. However, if your application with the cellular module required wide bandwidth(very high data rate) which cannot be convered by UART. You may pick up different method like USB or in combination of UART (for control) and other method (for SPI or USB for data). Personally I would try to avoid using USB for connecting the peripheral device to microcontroller. It would be a little difficult to use USB without using a special device driver which would be a little too heavy for small / microcontoller based embedded system (In case of I2C / UART, programming those ports are relatively simple. just reading / writing a few I/O registers). Even though I haven't checked the specific numbers, the current consumption of USB would be much higher than I2C or SPI. I am not sure which one (UART or USB) is more efficient in terms of current consumption since I see so much different numbers on UART current consumption.

 

Again.. the conclusion is that it is all up to you to determine which one to use.  Whatever you choose, I would not complain :)

 

 

Reference :

 

[1]