This series of articles are the study notes of "AnIntroduction to Programming the Internet of Things", by Prof. Harris, Department of ComputerScience, University of California, Irvine. This article is week 2, Lessen 2: Componentsof Embedded Systems.
2. Lesson 2: Components of Embedded Systems
2.1 Components of Embedded Systems
This lecture we'll talk about components in embedded systems, the hardware components. Specifically we're going to talk about microcontrollers.
2.1.1 Microcontroller
(1) Integrated circuit that executes a program
The microcontroller’s job is to execute code and it's the center of the system. So, it reads inputs from other components and it controls other components.
(2) Microcontroller vs. microprocessor
Microcontroller versus microprocessor, it's a terminology difference. Microcontroller is basically smaller and weaker than the microprocessor.
- Slower, 16MHz- 500MHz
- Less memory, fewer features
microprocessor
So when you say microprocessor, you're thinking about what you'd find in a desktop, laptop, Intel whatever, AMD whatever. A big general purpose processor, general purpose digital signal processor. That's called a microprocessor. They're more heavy-duty. They're very fast, have a lot of memory, and all this.
Microcontroller
A microcontroller is more slimmed down. More like what you would find in an embedded system or in an IOT device.Because remember, these devices, they have to be designed efficiently. We don't want overkill. We don't want to over design the system. We don't want to buy the highest end processor. We don't want to buy that if we don't need it. For the task that we're performing, maybe we'reinteracting with users, and these users are only so fast. So maybe you don't need a fast processor. So you want the cheapest processor that will do the job.So you will go for amicrocontroller, which is slower and cheaper than whatever the high end microprocessor is. So you can generally think ofmicrocontroller as a lowerend microprocessor.
So it's slower, typical, a microcontroller mightbe 16 MHz, that's a slow one. All the way up to, well I have 500 MHz, 500 MHz is sort of a high end, actually though if you look at say, Raspberry Pi, that's going 1 GHz I think, so it's twice that. But generally microcontrollers are going to slower than microprocessors and goingto have less memory, less of everything roughly.
- Connectedto other hardware components
- Sendscommands and receives data
Needs to be programmed
Write a program in a language, such as C
Place the program in the mctrlr memory
2.1.2 Programming Microcontroller
(1) packaging of a microcontroller
So the microcontroller is at the heart of the system, it's connected to lots of different components that are in the embedded system in the IoT device. And it takes inputs from them, and it sends control data out of them.
(2) Programming Microcontroller
Needsto be programmed
Microcontroller needs to be programmed, it needs to run code. And that's what it does, it executes code. So you need to write the program in some language on a host machine-regular desktop or laptop.
Programminglanguage
There are many languages that you can write programs in:
- When it comes to Arduino we'll eventually be usingC/C++.
- When it comes to Raspberry Pi we'll be using Python.
So you have to write a program in alanguage. And then thatprogram has to be compiled or interpreted, and we'll talk about that in another lecture. And the result though,has to gettransmitted on to the memory of that microcontroller. So it has to be placed in the memory of the microcontroller. So inside that microcontroller, there is always some flash memory.Flash memory is just a non-volatilememory, a memory that stays after you power off. So there's some memory and that memory has to hold the program so that when it gets power, it starts executing the program from the start.
Programming the microcontroller-transferring the program from host to microcontroller
Usinga programmer
Programming hardware can be used to place program in microcontroller memory.
So first you'll write your program on some host platform, a laptop, or desktop. Which is not the program that you're going to execute, not the chip that you're going to execute it on, not that microcontroller. You typically write the program on a different host processor like your laptop, desktop. So you write the program there, then you process the program, compile or interpret the program, or compile it and interpretation will happen later. But you compile the program then that final version of the compiled program has to get transferred to the microcontroller. Usually it's done through a piece of hardware, an external piece of hardware. So, here we see in the middle, there's a little board. That board is connected by USB to the laptop, and the microcontroller chip on the side of the diagram, that is plugged into the board, to this slot that fits the microcontroller. You plug it into the board, then on the laptop you would type, hit program, there's a button that hits program. You program it and it'll write the data into the memory ofthat microcontroller. So that's one way to do it.
A programmer can be used to place program in microcontroller memory
Directly programming for Arduino or Raspberry Pi
Basically, the way an Arduino and Raspberry Pi work, is that a lot of this programming hardware that you see in there, is built into the Arduino board and to the Raspberry Piboard. So, we don't need a separate device to program the microcontroller. That logic is basically built right into the board. So we just take our Arduino or Raspberry Pi and plug it into USB into the laptop/ desktop. And we can program it directly.
2.2 More on Components of Embedded Systems
In this lecture we'll talk about basic components that you see in embedded systems commonly, different versions of what you will eventually use in the class.
2.2.1 Using a Development Board
You should do your programming on a host not always, like with a Raspberry pi, as you'll see. You can actually do the development on the rest of your Pi itself, if you want to. But it's most common if you do it on a host, because a host is generally in a more powerful platform, and easier to program all. So as far as processes go and microcontrollers as well, but right now just talking about general purpose processors.
(1) General Purpose Processors
- Usedfor any application
- Manyfeatures included
You can classify them in two broad categories, general purpose and digital signal processing. So general purpose processors, those are what you see in your standard desktop, laptop. They're used for any application and they include many features. But they are overkill for most features. They have many features that you probably don't even need. But they can handle anything, so any particular task they can do it. They can do it adequately. But they tend to be more expensive because they're over designed. They're over engineered, and they have many features that maybe you don't need a lot of them, but they have it just in case.
(2) Digital Signal Processors
- Made to support DSP functions
- Vector instructions
- Cheaper but more limited
There are also digital signal processors which Specific to doing digital signal processing applications. So digital signal processing is basically processing data streams. So audio streams, video streams. These are common, these are very common. Maybe you want to as audio is coming in you want to filter that audio or you want to compress that audio. You might want to filter it or do some special effect or compress it or something like that.
(3) Sensors
Sensors reciveing information from the environment.
Simplesensors: Provide simple information. I'll call them simple sensors because their inputs and outputs are just real numbers. Zero volts to five volts. So it's bright or not bright, something like that.
Thermistor: reports Temperature
Photoresistor: reports light intensity
Complexsensors: Provide more complicated data.
CMOS camera: capture images
Complex sensors can actually receive information and receive more complicated data. So for instance take a camera.CMOS camera, like in a digital camera. So it captures images. Now that's alight sensor, it's technically a light sensor. It's a special purpose light sensor. It doesn't just tell you the intensity of light like a photo resistor might. It also tells you what color the light is at every point in the image. So it's much more complicated visual data that this thing is reporting. So it's a much more complicated sensor, so there's a lot more data to receive and it's more complicated to work with generally.
Ethernet controller:enables network communication. Now, also an Ethernet controller, you can see that as a sensor. You know, whether that's a sensor or not is a question, is a sort of a judgmentcall, but an Ethernet controller will allow you to receive information on theether, from the Ethernet, from the network. So that information, you can call that sensing, not necessarily from the physical world, but sensing from the network.
(4) Actuators
Cause events to occur in the environment
Simpleactuators
- Light- Emittiong Diodes (LEDs) - small lights
- LCD Display – simple display
Complexactuators
- Servo motor: moves something
- Ethernet controller: enables network communication
2.3 Sensors and Actuators (in the Lab)
In class we've been talking about embedded systems. And I'd like to give you a small example of one in the flesh, so to speak. This one, it's got a sensor, an actuator and a microcontroller in between. It's got all the basics that we've spoken about.
This blue knob is a potentiometer. What it does is it senses rotation. So it's a knob, I can turn the knob, and it will report back to me the amount of rotation. It does that in terms of resistance, so it's really a changing resistor, or a variable resistor. You turn the knob and the resistance changes. So that is connected to a microcontroller, this microcontroller right here on the Arduino. This is the Arduino. The Arduino reads the information about the rotation, and based on that, it sends signals to the actuator. The actuator is over here. This actuator is a servo motor, it's a motor that you can control the angle to which it's rotating.