38
Embedded system and Development Rajani Bhandari Senior Project Manager HCL Technologies

Embedded system and development

Embed Size (px)

DESCRIPTION

Describes about embedded systems and breif on good coding practices.

Citation preview

Page 1: Embedded system and development

Embedded system and Development

Rajani Bhandari

Senior Project Manager

HCL Technologies

Page 2: Embedded system and development

2

Topics

Introduction to Embedded systemsHow embedded is different from PCDesign constraints in embedded softwareExamples of Embedded applicationsSoftware development cycle in embedded

applicationsArchitecture of embedded applications.Development Guidelines

Page 3: Embedded system and development

3

Introduction to Embedded systems

Page 4: Embedded system and development

4

Introduction of Embedded system

An embedded system is a combination of computer hardware and software accomplished with additional mechanical or other parts designed to perform a

Embedded software is used in real life like cell phone, pager, digital camera, portable video games, Calculators, oven, washing machine etc.

: :Embedded systems often must cost just a few dollars, must be sized to fit on a single chip, must perform fast enough to process data in real-time, and must consume minimum power to extend battery life. High user expectations in terms of performance

Specific Function

In every electronic device

Limited Resources

Page 5: Embedded system and development

5

Connect via peripherals

Embedded Systems talk with the outside world via peripherals, such as:

Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc.

Universal Serial Bus (USB) Multi Media Cards (SD Cards, Compact Flash etc.) Networks: Ethernet, Lon Works, etc. Analog to Digital/Digital to Analog (ADC/DAC)

Page 6: Embedded system and development

6

Examples In Your Daily Life

…wake up …

…have breakfast …

…set home safety system …

…get into your car …

…on your way to your office…

Page 7: Embedded system and development

7

Examples In Your Daily Life(cont’)

…in Your office…

Page 8: Embedded system and development

8

Examples In Your Daily Life(cont’)

…Back Home …

Page 9: Embedded system and development

99

A “short list” of embedded systems

And the list goes on and on

Anti-lock brakes

Auto-focus cameras

Automatic teller machines

Automatic toll systems

Automatic transmission

Avionic systems

Battery chargers

Camcorders

Cell phones

Cell-phone base stations

Cordless phones

Cruise control

Curbside check-in systems

Digital cameras

Disk drives

Electronic card readers

Electronic instruments

Electronic toys/games

Factory control

Fax machines

Fingerprint identifiers

Home security systems

Life-support systems

Medical testing systems

Modems

MPEG decoders

Network cards

Network switches/routers

On-board navigation

Pagers

Photocopiers

Point-of-sale systems

Portable video games

Printers

Satellite phones

Scanners

Smart ovens/dishwashers

Speech recognizers

Stereo systems

Teleconferencing systems

Televisions

Temperature controllers

Theft tracking systems

TV set-top boxes

VCR’s, DVD players

Video game consoles

Video phones

Washers and dryers

Page 10: Embedded system and development

10

Embedded Vs PC

Page 11: Embedded system and development

11

Difference - Embedded and PC

An embedded system have defined process and function whereas PC is generic

Computer system can be manufactured with general requirement and the manufacturer does not know what the customer will do, while embedded system is Application Specific .

Numerous embedded system make up the computer Tightly constrained: Embedded system design is tightly constraint.

Important factors to be considered are as cost, size, performance, and power.

Reactive and real-time: Continually reacts to changes in the system’s environment. Must compute certain results in real-time without delay

Page 12: Embedded system and development

12

Difference - Embedded and PC App- Coding

Embedded

Closer to the Hardware Use native data types

Fewer System ResourcesNo Operating SystemMore efficient algorithms

Higher frequency = higher power

PC Application

Abstracted Hardware

Plenty of ResourcesHas an Operating System

Page 13: Embedded system and development

Embedded vs PC App - Testing

EmbeddedDebugging is very difficultEmulators or simulators are

required at the time of development

Usually a simple interfaceOften involves extra hardware

PC ApplicationUsually simple to get a basic

debug outputCan be very sophisticated

testing

Page 14: Embedded system and development

14

Design challenges

Page 15: Embedded system and development

15

Design Challenges

Cost Unit Cost- Cost of manufacturing each unitNON recurring Engg Cost: Monetary cost of designing the system

The physical space required by the system and measured in bytes for software and gates for hardware.

Execution cost

The amount of power consumed which determines life time of battery. Maximum Source of power : Antennas – Bluetooth, Wi-Fi, RF . Digital displays

Time-to market constraint. Hardware and software development goes in parallelMissing this window – significant loss

Size

Performance

Power

Time Line

Flexiblity Change functionality without heavy NRE cost. Code should be maintainable

Page 16: Embedded system and development

Design Metrics

16

SizePerformance

Power

NRE cost

Improving one often leads to a degradation in another

Page 17: Embedded system and development

Examples of embedded system

17

Car cruise controllers reacts to brake sensor and speed

It Compute acceleration and deceleration System

Failure

Delayed computation

Page 18: Embedded system and development

Mobile evolution – impact on design matrices

18

1980 analog cellular technologyDigital Mobile Communication 1990

Wide Band Mobile Communication 2000

Broadband Mobile Communication 2010

Factors Affected Cost Design Complexity Size Performance Power Consumption

Page 19: Embedded system and development

Digital camera- An embedded system example

19

Microcontroller

CCD preprocessor Pixel coprocessorA2D

D2A

JPEG codec

DMA controller

Memory controller ISA bus interface UART LCD ctrl

Display ctrl

Multiplier/Accum

Digital camera chip

lens

CCD

Page 20: Embedded system and development

Time to Market- Design challenge

20

Re

ven

ue

s ($

)

Time (months)

Market window:Period during which the product would have highest salesAverage time-to-market constraint is about 8 months. Delays can be costly.

Page 21: Embedded system and development

Design Challenge

21

After decision of mass production of embedded system and a small bug found at that time may be very expensive. Even a 1 day delay can cost equivalent ……… Any Guesses??

Page 22: Embedded system and development

22

Software Development Life cycle

Page 23: Embedded system and development

Embedded system Life Cycle

23

Development of Hardware and software goes in parallel which is a major challenge.

Page 24: Embedded system and development

24

Architecture of embedded application

Page 25: Embedded system and development

25

Architecture of embedded system

Application Software

Operating System

Hardware

Page 26: Embedded system and development

Hardware architecture

26

Page 27: Embedded system and development

27

Development Guidelines

Page 28: Embedded system and development

Guidelines for embedded application development

Power: Optimal Power usage Transferring data on Air

Reset Device Design for the restoration of configuration

28

Memory Guidelines Data Type Life time of variable Memory allocation on heap or stack. Memory should be freed if

not required Stateless components Logging and Instrumentation

User Interface Simple UI Hour glass as visual indicator for blocking operation Resolution and LCD size Design for usability by supporting for touch, stylus driven, 5-way Do not update ui frequently

Page 29: Embedded system and development

29

Key rules for best coding

Maintainability Reliability Efficiency

Page 30: Embedded system and development

30

Maintenance problems

Unstructured code

Insufficient domain knowledge

Insufficient documentation

Page 31: Embedded system and development

31

Efficiency

Optimal Utilization of ResourcesDesign and architecture of softwareMemory management

Page 32: Embedded system and development

32

Coding standards

Readability of code Size of Function Variable naming Code Commenting Long methods Private, public or local variable naming rule Formatting and indentation

Complexity of code Multiple return statement Nested loop or conditions

Uninitialized variables

Duplicate code prone to errors

Avoid Hard Coding

Use of enum to indicate discrete values

Multilingual support

Reusable code or shared libraries

Page 33: Embedded system and development

33

Sample code

// This class provides the functionality // of adding numbers#include <iostream>using namespace std;

class Adder{ public: // constructor Adder(int i = 0) { total = i; } // interface to outside world // Adds a number and calculates

total void addNum(int number) { total += number; } // interface to outside world //get sum total result int getTotal() { return total; }; private: // hidden data from outside world int total;};

int main( ){ Adder a; a.addNum(10); a.addNum(20); a.addNum(30);

cout << "Total " << a.getTotal() <<endl; return 0;}

Page 34: Embedded system and development

34

Which one is better

bool MyApplication::ReportGenerator::GenerateReport() { bool returnValue = false; if (isAdmin() && isConditionOne() && isConditionTwo() && isConditionThree()) { returnValue = generateReport(); } return returnValue; }

bool MyApplication::ReportGenerator::GenerateReport()

{ if ( ! isAdmin () ) return false ;

if ( ! isConditionOne () ) return false ;

if ( ! isConditionTwo () ) return false ;

if ( ! isConditionThree() ) return false ;

return generateReport() ;

}

Page 35: Embedded system and development

35

Sample Code

function do_stuff() {// …

if (is_writable($folder)) { if ($fp = fopen($file_path,'w')) {

if ($stuff = get_some_stuff()) {

if (fwrite($fp,$stuff)) {

// ... } else {

return false;

}

} else {return false;

}} else { return false;}

} else {return false;

}}

function do_stuff() {

// ...

if (!is_writable($folder)) {return false;}

if (!$fp = fopen($file_path,'w')) {return false;}

if (!$stuff = get_some_stuff()) {return false;}

if (fwrite($fp,$stuff)) {// ...

} else {return false;}

}

Page 37: Embedded system and development

37

Questions ??

Page 38: Embedded system and development

38

Thanks!!