techbus.org

how IOT related to embedded systems

Internet of things devices are implemented using both hardware and software components.  Micro controllers are used to execute software that interprets and that is how IOT related to embedded systems.

so in this this article we will discuss:

1- An introduction to the embedded systems and how they are related to IoT devices.

2- Exploring the Embedded Systems world.

3- The hardware structure by looking at the different components.

4- Some of the prototyping boards used in Internet of Things systems such as arduino and raspberry pi.

5- Explaining the Arduino board and how to use it.

6- Implementing a project using Arduino.

1- Introduction to Embedded Systems: Embedded systems is a term refers not only to how the device is used, but also how it’s implemented and how it’s built, so there is a lot of overlap between the two terms IoT devices and Embedded System devices. So IoT devices are typically embedded systems also, so we’ll just define that and give you an idea of what embedded systems are. It’s good to know the term embedded system because it is still commonly used, and what we are building in the world of IoT are typically embedded systems.

2- Exploring Embedded systems world : Embedded systems are computer based systems that don’t look like computers. The complexity of a computer is hidden from the user. So unlike typical computers or laptops which you as a typical user find complexities in using it such as installing new softwares, searching for a solution to one of your conflicts, etc. like for instance video games. I used to play video games on computers, now I use only game machines, but say I play a video game on a computer. What i need to start playing is to put the video game in it’s place, install it’s software and if you are lucky, you would not face problems or conflicts installing it, but in many cases, there are some conflicts with the video card. So you need a new video card to play this new video game. Now, you need to get new drivers for your video card. Finally, you will be able to play your games. So in computers, the functions are not separated unlike a machine ready and equipped with the hardware and the software tools needed for games like game machines. This is different than an IoT device. An IoT device is basically has one function. We mentioned this in previous articles. It has one function it’s trying to do like the car which does the car things or the camera which does the camera things, taking photos, recording videos, saving, etc. But, a general purpose computer, It can do a lot of things so there can be conflicts because there are many relationships between it’s components and it’s functions and those relationships add to complexity.

So embedded systems and IoT devices are generally embedded. They hide the complexity from the user so the user doesn’t have to see the complexity of what’s going on inside. The user just need to know how to use it. It has a very simple interface and this is where the term embedded came from. The complexity is embedded inside the device and the user doesn’t have to deal with the complexity. One thing to notice about the relationship between embedded systems and IoT systems is that IoT systems are almost always connected to the internet, thus the term Internet of Things, but embedded systems may or may not be. Embedded systems may have computational complexity in there, but no network connection at all. And so there are a lot of uses for devices like that. Things are moving from embedded to IoT because of the trends we talked about in the previous articles. The fact that internet connectivity is so ubiquitous and it’s pretty cheap to obtain. So a lot of these devices that used to be just embedded, are now becoming networked and so you’d call them IoT.

So embedded systems are basically everything that interacts, all the internet of things devices that we’ve mentioned but plus or minus the internet part. So a digital camera might not be networked. It might just be an embedded system where you click, press a button, take a picture and the picture is stored locally, but it might not be immediately networked. So you would call that type of thing an embedded system because the complexity is embedded within the device and has a simple interface to the user.

3. embedded system devices: It will be designed to take data from the outside world through “sensors” and then it has an output data to the outside world using “actuators” after making some logic to the sensed data using other components.

– “Sensors”: Sensors are used for receiving data from the outside world. An embedded device has a set of sensors. So these sensors receive information from the outside world in many different ways because there are many different types of sensors. The most basic type of sensor would be a push button that is receiving data that somebody types in through push which implies 1 in the embedded system world. You could receive sound information like the microphone which receives audio information. There’s also video, like the camera or just a regular light sensor that receives video information. You could also receive touch information through touch screens. So, there’s a lot of different sensors that an embedded system can receive input from. That input comes in through a set of sensors on it’s way to the core of the system. Once the system has decided to process that information, it needs to cause some results which is an effect to happen in the outside world. So that’s done through the actuators at the other side.

-“Actuators”: Actuators are the part which cause events to happen in the world. So those might be something like a motor. It goes off and on to perform some actions. It may control the lens to control the focus on cameras. So those motors, those are actuators that perform the outputs of the system. Speakers are actuators, they output sound. Lights are actuators, they output light. The screen is an actuator, it also outputs light but in a more complex format. So if you look at an embedded system, It receives data from the sensors, it does something with the data, and then it outputs to the actuators to make something happen in the real world as a result of the data that it received.

microcontroller or microprocessor: The differences between microcontrollers and microprocessors is that the microcontroller is basically smaller and weaker than the microprocessor. So when you say microprocessor, you almost mean a computer, desktop or laptop which has a big general purpose processor, and a general purpose digital signal processor, ect. Microprocessors are heavy-duty which mean they can run much complex programs, they’re very fast, have a lot of memory, etc.

Microcontrollers are cheaper and weaker which you may need to perform less complex systems that do not need much power, processing, memory, ect. You can think of Microcontroller as a lower end microprocessor. The speed numbers change over time but a common ratio might be 16 MHz, 8 MHz or just 4 MHz. Unlike microprocessors which could reach a speed up to 1 GHz.

3. Arduinos and Raspberry PIs are very common devices which represent microcontrollers and microprocessors. The Arduino is a microcontroller and The Raspberry pi is a microprocessor.

We will focus on the arduino in this article and dive deeper into microprocessors in later articles. So the Arduino is not just a microcontroller, it has a main big black chip on the center of it which is the microcontroller that executes our programs, but also many other components on the board.

You can find more information about the Arduino here (https://www.arduino.cc/)

4. Arduino uses the C programming language to run it’s programs. Arduino developers built a c language for the Arduino called Arduino c which is similar to the original c language with a little modification. You can use the Arduino to be the brain of your system after wiring your components to the Arduino pins.The basic Arduino program functions are setup() which you use to define the behavior of your pins after defining it using the define keyword. The second main function of any Arduino program is the loop() function which will loop forever to execute it’s contents.

5. Let’s make a simple Arduino project, a car model. In our project, we need a car body, arduino uno, 4 motors, h bridge, breadboard, wires and two batteries.

1- The car body: It’s a simple body to carry your system components and it is available in almost any electronics shop.

2- Arduino: It’s the brain of our system to hold the logic of our system and run the c program.

3- 4 motors: Actuators to move the car forward, backward, right and left.

 

techbus.org

4- H-Bridge: those are very useful for controlling the speed and direction of our car model and also available in any electronics shop.

techbus.org

3- breadboard: A simple board that help in wiring the system.

techbus.org

4- wires: to connect our systems.

 

techbus.org

5- 2 batteries: To power up the h-bridge, the arduino, and the 4 motors.

techbus.org

To start moving our car, we need to wire the h-bridge with the motors as the h-bridge control the speed and the direction. The typical h-bridge function is two control two motors. The h-bridge has two enables “enA, enB” which will control the speed of the two motors enA for motor 1 which represent the right wheels of the car and enB is the left wheels. As we need to wire up 4 motors, we will use 4 motors and will wire the right two motors to the enA as a single motor and the two left motors to enB as a single motor. To control the direction for the 4 motors, there are 4 pins in the middle of the h-bridge two of them will be for the enA “right morots”, and the other two are for the left motors. here is the code for our car.

// part 1

#define enA 10

#define enB 5

#define i1 8

#define i2 9

#define i3 6

#define i4 7

//part 2

void setup(){

pinMode(enA, OUTPUT);

pinMode(enB, OUTPUT);

pinMode(i1, OUTPUT);

pinMode(i2, OUTPUT);

pinMode(i3, OUTPUT);

pinMode(i4, OUTPUT);

}

//part 3

void motor1Stop(){

digitalWrite(i1, LOW);

digitalWrite(i2, LOW);

}

void motor2Stop(){

digitalWrite(i3, LOW);

digitalWrite(i4, LOW);

}

//part 4

void motorsEnabled(bool en){

digitalWrite(enA, en);

digitalWrite(enB, en);

}

void enableMotors(){

motorsEnabled(HIGH);

}

//part 5

void motor1Forward(){

digitalWrite(i1, HIGH);

digitalWrite(i2, LOW);

}

void motor2Forward(){

digitalWrite(i3, HIGH);

digitalWrite(i4, LOW);

}

//part 6

void motor1Backward(){

digitalWrite(i1, LOW);

digitalWrite(i2, HIGH);

}

void motor2Backward(){

digitalWrite(i3, LOW);

digitalWrite(i4, HIGH);

}

//part 7

void loop(){

delay(1000);

enableMotors();

motor1Forward();

motor2Forward();

delay(1000);

motor1Stop();

motor2Stop();

delay(1000);

motor1Backward();

motor2Backward();

delay(1000);

motor1Stop();

motor2Stop();

delay(1000);

//right and left

enableMotors();

motor2Stop();

motor1Forward();

delay(1000);

motor1Stop();

motor2Stop();

delay(1000);

enableMotors();

motor1Stop();

motor2Forward();

}

let’s break down our car model code:

part 1: This part is used to define the Arduino’s pins which the arduino will use to read or send signals from or to the system.

part 2: Is used to define the pins to tell the Arduino the behaviour of those pins wether input or output pins so the Arduino should read or write from or to them.

part 3: motor1Stop() Remember the two pins which control the direction of the right “motors 1”. i1 and i2 are those pins and by setting them to 0 or LOW, it means do not use them in the embedded world. So by calling this function, right motors or “motors 1” would stop. motor2Stop works the same as motor1Stop, but it controls the left motors and by calling this function, motors 2 would stop.

part 4: enableMotors() and motorsEnabled() for controlling the speed of the left and right motors. enableMotors will call motorsEnabled and send it HIGH which mean both left and right side motors should go in their full speed “speed 255”.

part 5: motor1Forward() and motor2Forward() are functions for controlling the direction of the left and the right side motors which will control the car direction. motor1Forward() sends HIGH to i1 and LOW to i2 which will make the two right motors go forward, and you can make them go backward by sending LOW to i1 and HIGH to i2. motor2Forward() send HIGH to i3 and LOW to i4 which will make the left motors to also go forward. So by calling both functions, our car should go forward.

part 6: Similar to part #5, but the car should go in the opposite direction by calling those functions.

part 7: loop() is the function which will run forever if the system is powered. So Arduino will excute the setup() function first, then the loop() function will loop forever and execute the statements inside it. So the behavior of our car should be:

1- delay(1000): pause the system for some time to be able to place the car on the ground.

2- enablemotors(): to make both motors go in their full speed.

3- motor1Forward(), motor2Forward(), and delay(1000): The car should move forward for some time.

4- motor1Stop(), motor2Stop(), and delay(1000): The car should stop moving for some time.

5- motor1Backward(), motor2Backward(), and delay(1000): The car should move in the reverse direction for some time, then stop for some times as #4.

6- enable Motors(), motor2Stop(), motor1Forward(), delay(1000): after executing those functions the left motors should stop and the right motors would go forward which should make our car to go in the left direction for some time.

7- Stopping the car for some time as #4.

8- Moving the car in the right direction as #6.

 

 [contact-form-7 id=”1013″ title=”Contact Form 1″]

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s