Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge",...

21
Workshop on Embedded Design Challenge Competition Presented By Mohammed Abdul Kader Assistant Professor, Dept. of EEE, IIUC Email:[email protected] Website: kader05cuet.wordpress.com Organized By: IEEE IIUC Student Branch

Transcript of Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge",...

Page 1: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on Embedded Design

Challenge Competition

Presented By

Mohammed Abdul Kader

Assistant Professor, Dept. of EEE, IIUC

Email:[email protected] Website: kader05cuet.wordpress.com

Organized By:

IEEE IIUC Student Branch

Page 2: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2

Embedded Design Challenge

The competition is based on microcontroller based embedded system project design.

Microcontroller and some pre announced components will be arranged on a table.

Some projects based on the given components and specific topics will be given to

design.

Contestants have to collect necessary components from the table to design the project.

They have to design circuit, write program and load the program to microcontroller to

implement the project.

Page 3: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Topics

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 3

The problem (projects) will be based on following topic:

Input-Output (I/O) Pins/PORT

A/D Converter

PWM

Timer

ARDUINO UNO, LED, Push-Button, 7-segment display (Single and Multiple), Sensor (LDR,

Motion Sensor, Sound Sensor, MQ-4 Gas Sensor, IR Sensor, Sound Sensor, Ultrasonic Sensor,

Temperature Sensor), Relay, Motor (DC and Servo), LCD Display.

Components

Microcontroller and Programming Software:

ARDUINO UNO (ATmega328P), ARDUINO.

Page 4: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Components

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 4

Page 5: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 5

Contestant must bring their own laptop (one laptop per group) and an ARDUINO UNO

board with USB data cable (one ARDUINO UNO per group). Other components will be

provided by the organizer.

Laptop and ARDUINO UNO Board

Page 6: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 6

Project Allocated Time

Problem-1 25 min

Problem-2 35 min

Preliminary Round:

•All registered group can participate in Preliminary Round.

•Two problems will be given to solve.

•Contestant will get one hour to solve the problems (Programming and hardware implementation).

•8 groups will be qualified for final round.

Time allocation of projects (Problems)

Final Round:

• Four problems will be given to solve.

• Contestant will get two hours to solve the problems (Programming and hardware

implementation).

Time allocation of projects (problems)

Project Allocated Time

Problem-1 20 min

Problem-2 25 min

Break 10 min

Problem-3 30 min

Problem-4 45 min

Steps of Competition

Page 7: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 7

Judgment

N= [𝑨𝒍𝒍𝒐𝒄𝒂𝒕𝒆𝒅 𝒕𝒊𝒎𝒆 −𝒔𝒐𝒍𝒗𝒊𝒏𝒈 𝒕𝒊𝒎𝒆

𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 𝒇𝒂𝒄𝒕𝒐𝒓+ 𝟏. 𝟖 × 𝑨𝒍𝒍𝒐𝒄𝒂𝒕𝒆𝒅 𝒕𝒊𝒎𝒆 × 𝒔𝒐𝒍𝒖𝒕𝒊𝒐𝒏 𝒇𝒂𝒄𝒕𝒐𝒓 + 𝟑𝟏)

Where,

Allocated time means total time given to solve the problem.

Solving time represents time taken by contestant to solve the problem.

Solution factor represents how much percentage of problems is solved (i.e. fully solved or partially

solved). If contestant can solve all parts of a problem, the solution factor will be 1. In case of partial

solution, solution factor will be less than 1 based on the percentage of solution.

Page 8: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Timer/ Counter

I/O Port

What is Microcontroller?

Micro-computer in a single chip.

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 8

Page 9: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Arduino UNO Digital I/O Pins

Vcc and GND Pins

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 9

Page 10: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Digital I/O Pins

Most of the important pins of microcontroller are digital input-output pins.

These pins are used to connect INPUT Device (i.e. Push Button, keypad, digital sensors

etc) and OUTPUT Device (i.e. LED, Display, Relay, Motor etc.) with microcontroller.

These pins can act as INPUT or

OUTPUT.

Digital Output pin means microcontroller

can make this pin HIGH or LOW state

(Write Operation).

Digital Input pin means microcontroller

can read HIGH or LOW state from other

devices (Read Operation).

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 10

Page 11: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Configuring Digital I/O Pins

digitalWrite(pin number, HIGH/LOW)

digitalWrite(13,HIGH)

digitalWrite(13,LOW)

pinMode(pin Number, OUTPUT)

An LED is connected with pin 13.

The pin should be an OUTPUT pin.

We can configure a pin as OUTPUT by

“pinMode” function.

pinMode(13, OUTPUT)

Configuring as OUTPUT

Making a Pin HIGH or LOW

Microcontroller can make a digital pin HIGH or LOW by

digitalWrite function.

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 11

Page 12: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Program Structure in ARDUINO

Verify Program

Load Program

Processor run the instructions

written here only once after

loading program or reset .

Serial monitor

Processor run the instructions written here

repeatedly after loading program or reset .

i.e. void loop() function creates an infinite

loop.

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 12

Page 13: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

void setup()

{

pinMode(13,OUTPUT);

}

void loop()

{

digitalWrite(13,HIGH);

delay(300);

digitalWrite(13,LOW);

delay(300);

}

LED Blinking

Note: To insert a time delay in the program use following function-

delay(time_in_ms);

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 13

Page 14: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 14

Level-1 (Only input or output operation)

Level-2 (Both input and output operation)

Level-3 (Input and output operation with A/D conversion)

Level-4 (Input and output operation with A/D conversion, Timer and PWM)

Problem Setting

Problem Difficulty Level

Page 15: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 15

Design a 3-bit binary up counter which changes state automatically at every 2 second.

Example-1 (Level-1)

void setup() {

pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11,OUTPUT);

}

void loop() {

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

delay(2000);

digitalWrite(13,LOW);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

Delay(2000);

}

digitalWrite(13,LOW);

digitalWrite(12,HIGH);

digitalWrite(11,LOW);

delay(2000);

digitalWrite(13,LOW);

digitalWrite(12,HIGH);

digitalWrite(11,HIGH);

Delay(2000);

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,LOW);

delay(2000);

digitalWrite(13,HIGH);

digitalWrite(12,LOW);

digitalWrite(11,HIGH);

Delay(2000);

digitalWrite(13,HIGH);

digitalWrite(12,HIGH);

digitalWrite(11,LOW);

delay(2000);

digitalWrite(13,HIGH);

digitalWrite(12,HIGH);

digitalWrite(11,HIGH);

Delay(2000);

}

Page 16: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 16

Design a 3-bit binary up counter which changes state at every 2 second.

Example-1 (Level-1) Alternative way

unsigned char j=0;

void setup() {

pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11,OUTPUT);

}

void loop() {

digitalWrite(13,(j & 1));

digitalWrite(12,(j & 2));

digitalWrite(11,(j & 4));

delay(1000);

j=j+1;

if(j>15) j=0;

}

Page 17: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 17

Show the even numbers from 0 to 9 at seven segment display at every 1 sec later. Repeat the sequence.

Example-2 (Level-1)

const int a=13, b=12, c=11,d=10;

const int e=9,f=8,g=7;

unsigned char i=0;

unsigned seven_seg[10]={64,121,36,48,25,18,2,120,0,16};

unsigned char number;

void setup() {

pinMode(a,OUTPUT);

pinMode(b,OUTPUT);

pinMode(c,OUTPUT);

pinMode(d,OUTPUT);

pinMode(e,OUTPUT);

pinMode(f,OUTPUT);

pinMode(g,OUTPUT);

}

void loop() {

number=seven_seg[i];

digitalWrite(a,(number & 1));

digitalWrite(b,(number & 2));

digitalWrite(c,(number & 4));

digitalWrite(d,(number & 8));

digitalWrite(e,(number & 16));

digitalWrite(f,(number & 32));

digitalWrite(g,(number & 64));

delay(1000);

i=i+2;

if(i>9) i=0;

}

Page 18: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Line Follower Robocar", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 18

Eight LEDs are connected with microcontroller. The initial value of the LEDs are 00110001 (1 means

ON, 0 means OFF). Write program to rotate these value at every 1s. Collect components, connect

different components and load the program to make the project .

Example-3 (Level-2)

byte number=0b00110001;

boolean a,b,c,d,e,f,g,h;

boolean shift_bit;

void setup() {

pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(11,OUTPUT);

pinMode(10,OUTPUT);

pinMode(9,OUTPUT);

pinMode(8,OUTPUT);

pinMode(7,OUTPUT);

pinMode(6,OUTPUT);

}

void loop() {

a= number & 1;

b=number & 2;

c= number & 4;

d=number & 8;

e=number & 16;

f= number & 32;

g=number & 64;

h=number & 128;;

digitalWrite(13,a);

digitalWrite(12,b);

digitalWrite(11,c);

digitalWrite(10,d);

digitalWrite(9,e);

digitalWrite(8,f);

digitalWrite(7,g);

digitalWrite(6,h);

delay(1000);

shift_bit= number & 1;

number >>= 1;

number=number+(shift_bit*128);

}

Page 19: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 19

A seven segment display and a sound sensor are connected with a microcontroller. Write program for

this circuit to count the hand clap and to show data in seven segment display.

Example-4 (Level-2)

#include <Bounce.h>

const int sensorPin = 6;

Bounce sensor = Bounce(sensorPin, 10);

const int a=13, b=12, c=11,d=10,e=9,f=8,g=7;

unsigned seven_seg[10]={64,121,36,48,25,18,2,120,0,16};

unsigned short clap=0,number;

void setup() {

pinMode(sensorPin, INPUT);

digitalWrite(sensorPin, HIGH);

pinMode(a,OUTPUT);

pinMode(b,OUTPUT);

pinMode(c,OUTPUT);

pinMode(d,OUTPUT);

pinMode(e,OUTPUT);

pinMode(f,OUTPUT);

pinMode(g,OUTPUT);

}

void loop() {

if (sensor.update()) {

if (sensor.risingEdge()) {

clap=clap+1;

if(clap>9) clap=0;

number=seven_seg[clap];

digitalWrite(a,(number & 1));

digitalWrite(b,(number & 2));

digitalWrite(c,(number & 4));

digitalWrite(d,(number & 8));

digitalWrite(e,(number & 16));

digitalWrite(f,(number & 32));

digitalWrite(g,(number & 64));

}

}

}

Page 20: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 20

Design a circuit which measure light intensity and control a bulb based on light intensity (bulb is

operated at 220V, 50Hz power supply). When light intensity falls from a certain level the light should

be ON and other case it should be OFF.

Example-5 (Level-3)

Page 21: Workshop on Microcontroller · 2017. 10. 23. · Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 2 Embedded Design Challenge The competition

Workshop on "Embedded Design Challenge", By-Mohammaed Abdul Kader,Assistant Prof, EEE, IIUC 21

Develop a project to measure the distance (from 2 cm to 100 cm) of an object and to show the value in

a LCD display. The device should also control the speed of a motor based on distance. The speed of the

motor should increase with the increment of distance.

Example-6 (Level-4)