0% found this document useful (0 votes)
7 views21 pages

ElectronicsComponent Lecture10 BK182

Uploaded by

tandepzai24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views21 pages

ElectronicsComponent Lecture10 BK182

Uploaded by

tandepzai24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Programming on Embedded

Circuits
Electronic Circuit Component – Programming on
Embedded Circuits

Micro-Controller Platform
▪ Micro-Controller Unit (MCU) contains
RAM, ROM and IO
▪ Micro-Processor Unit (MPU) only
contains the CPU
▪ System on Chip (SoC) refers to MCUs
with a greater number of onboard
peripherals and functionality

http://theairboard.cc http://www.ti.com http://www.microchip.com


2
Electronic Circuit Component – Programming on
Embedded Circuits

C Language: Header and C++ Files

#include “led.h”
#ifndef __LED_H_
#define __LED_H_
int T_on;
int T_off;
#include <system_lib.h>
int counter;
#include “user_lib.h”
#include “UserFolder/lib.h”
void setOn(long duration){
//TODO: set LED on here
extern int T_on;
}
extern int T_off;
void setoff(long duration){
//TODO: set LED off here
void setOn(long duration);
}
void setoff(long duration);
void delay(long duration){
//TODO: set delay here
#endif
}
3
Electronic Circuit Component – Programming on
Embedded Circuits

C Language: Main File


#include “led.h” ▪ Modules/ Libraries
#include “timer.h” are included
#include “gpio.h”
#include “button.h”

void main(){
initGPIO(); ▪ Modules/ Libraries
LED
initTimer(); are initiated
initButton();
initLED();
TIMER
….
….
while(1){};
GPIO }
void timer_isr(){
} ▪ System operations
are implemented in
BUTTON void ext_isr(){ interrupt functions
}
4
Electronic Circuit Component – Programming on
Embedded Circuits

Finite State Machine (FSM)


▪ Finite-State Machine (FSM) or Deterministic Finite
Automata (DFA), finite automaton, or simply a state
machine, is a mathematical model of computation
Current Input Next State
State
Locked Coin Unlocked
Push Locked
Unlocked Coin Unlocked
A turnstile
Push Locked

5
Electronic Circuit Component – Programming on
Embedded Circuits

Finite State Machine Programming


while(1){
switch(status){
case LOCKED:
lock_turnstile(); //operation in a state
if(Coin == true) //transition condition
status = UNLOCKED; //next state
break;
case UNLOCKED:
unlock_turnstile(); //operation in a state
if(Push == true) //transition condition
status = LOCKED; //next state
break;
default:
break;
}
}
6
Electronic Circuit Component – Programming on
Embedded Circuits

Example 1
▪ Given an LED turns on for T_on and then turns off
for T_off.
▫ Design an DFA for this LED
▫ Implement the DFA in Arduino

▪ digitalWrite(13, HIGH): turn on the LED


▪ digitalWrite(13, LOW): turn off the LED
▪ setTime(duration): set a clock (timer_flag =
0), when the clock is expired, timer_flag = 1;
duration is in mili-seconds.

7
Electronic Circuit Component – Programming on
Embedded Circuits

Answer
timer_flag == 1

INIT LED_ON LED_OFF


timer_flag == 1

▪ INIT: Set pin 13 to OUTPUT mode, set timer


▪ LED_ON: Turn on the LED
▪ LED_OFF: Turn off the LED

8
Electronic Circuit Component – Programming on
Embedded Circuits

Answer (Arduino Code)


void loop(){
switch(status){ void timer_run(){
case INIT: if(timer_counter > 0)
pinMode(13, OUTPUT);
timer_counter--;
setTimer(T_on);
status = LED_ON; if(counter_timer == 0)
digitalWrite(13, HIGH); timer_flag =1;
break; }
case LED_ON:
void setTimer(long duration){
if(timer_flag == 1){
status = LED_OFF; timer_counter = duration;
setTimer(T_off); timer_flag = 0;
digitalWrite(13, LOW); }
}
break;
case LED_OFF:
if(timer_flag == 1){
status = LED_ON;
setTimer(T_on);
digitalWrite(13, HIGH);
}
break;

default:
break;
}
delay(10);
} 9
Electronic Circuit Component – Programming on
Embedded Circuits

Example 2
▪ Design a smart lock which accepts 4 digits as a
secrete code. However, there is a time-out for each
digit (e.g. T_out = 5s). After this period, the system
is reset

1
Electronic Circuit Component – Programming on
Embedded Circuits

Embedded Platform based on Operating


System
▪ Embedded means something that is attached
to another thing.

▪ “Any sort of device which includes a


programmable computer but itself is not intended
to be a general-purpose computer” [Marilyn Wolf]

▪ Embedded system has three components:


▫ Hardware
▫ Real Time Operating System (RTOS)
▫ Software

1
Electronic Circuit Component – Programming on
Embedded Circuits

Classification of Embedded System

▪ Small Scale ▪ Medium ▪ Sophisticated Scale


Scale

1
Electronic Circuit Component – Programming on
Embedded Circuits

Processor
▪ Processor is the heart of the Embedded Syste

▪ General Purpose processor (GPP)


▫ Microprocessor
▫ Microcontroller
▫ Embedded Processor
▫ Digital Signal Processor
▪ Application Specific System Processor (ASSP)

▪ Multi Processor System using GPPs

1
Electronic Circuit Component – Programming on
Embedded Circuits

Operating System: Linux and Android


▪ Connectivity and UI
▫ Two powerful operating systems used in most of the
embedded systems
▫ Wireless connectivity and graphics interface: Android
OS
▫ Linux comes with a complex flow and it might be
difficult for a beginner to understand it

▪ Power management
▫ Android and Linux supports effective power
management compared to real time operating systems

▪ Responsiveness
▪ Cost
1
Electronic Circuit Component – Programming on
Embedded Circuits

Android Operating System Component

1
Electronic Circuit Component – Programming on
Embedded Circuits

Android Boot File


mkdir /system
mkdir /data 0771 system system
mkdir /cache 0770 system cache
mkdir /config 0500 root root
mkdir /metadata 0770 root root

service yunos_preinstall
/system/bin/yunos_preinstall.sh
user root
group root
class main
disabled
oneshot

1
Electronic Circuit Component – Programming on
Embedded Circuits

Android Resource File

IR Remote Data

1
Electronic Circuit Component – Programming on
Embedded Circuits

Android System File


▪ System
apps
▪ User apps
▪ Launcher
apps
▪ Preinstall
apps
▪ Libs
▪ KeyLayout
▪…

1
Electronic Circuit Component – Programming on
Embedded Circuits

How to Port Android Things?

1
Electronic Circuit Component – Programming on
Embedded Circuits

Create an Android Things Project


▪ http://developer.android.com/things/training/first-d
evice/create-studio-project

▪ Prerequisites
▫ Update your SDK tools to version 25.0.3 or higher
The updated SDK tools enable you to build and test
apps for Things.
▫ Update your SDK with Android 8.1 (Oreo), API 27 or h
igher
The updated platform version provides new APIs for
Things apps.

2
}
Electronic Circuit Component – Programming on
Embedded Circuits

Create an Android Things Project


▪ Added library

▪ Home Activity

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy