Ulster.ac.uk Embedded Systems Designing the high level structure of your embedded system Ian McCrum School of Engineering.

Slides:



Advertisements
Similar presentations
State Machines An approach to assembler coding. Intro State Machines are an integral part of software programming. State machines make code more efficient,
Advertisements

1 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices Switches LEDs.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Mark Schaumburg.  Dash Module for Formula Car  Sample pulse from engine for RPM  Display Information  Control gui  Can network interface  Request.
In this presentation you will:
EEE226 MICROPROCESSORBY DR. ZAINI ABDUL HALIM School of Electrical & Electronic Engineering USM.
MICRO PROCESSER The micro processer is a multipurpose programmable, clock driven, register based, electronic integrated device that has computing and decision.
Dr. HABEEB HATTAB HABEEB Dr. HABEEB HATTAB HABEEB Office: BN-Block, Level-3, Room Ext. No.: 7292 UNITEN.
CS-334: Computer Architecture
1 Computer System Overview OS-1 Course AA
Memory Management, File Systems, I/O How Multiprogramming Issues Mesh ECEN 5043 Software Engineering of Multiprogram Systems University of Colorado, Boulder.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
ASPPRATECH.
Computer System Laboratory
Microcontroller based system design
Module 2: Hardware and Terminology
Microcontroller: Introduction
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
PROGRAMMABLE LOGIC CONTROLLER (PLC) AND AUTOMATION
Hall C’s HMS PLC Controls by Steven Lassiter. What Constituents a PLC System PLC (processors) Programming. I/O modules. Field Device Signals (sometimes.
Advanced Embedded Systems Design Pre-emptive scheduler BAE 5030 Fall 2004 Roshani Jayasekara Biosystems and Agricultural Engineering Oklahoma State University.
Objectives How Microcontroller works
REAL-TIME SOFTWARE SYSTEMS DEVELOPMENT Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
PLC introduction1 Discrete Event Control Concept Representation DEC controller design DEC controller implementation.
PLC: Programmable Logical Controller
Protocol Architectures. Simple Protocol Architecture Not an actual architecture, but a model for how they work Similar to “pseudocode,” used for teaching.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Input/ Output By Mohit Sehgal. What is Input/Output of a Computer? Connection with Machine Every machine has I/O (Like a function) In computing, input/output,
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Typical Microcontroller Purposes
Module 1: Introduction to PLC
Programmable Logic Controller (PLC)
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview Part 2: History (continued)
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
REAL-TIME SOFTWARE SYSTEMS DEVELOPMENT Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Lab 13 Department of Computer Science and Information Engineering National Taiwan University Lab13 – Interrupt + Timer 2014/12/23 1 /16.
Lecture 2 Microprocessor Architecture Image from:
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Chapter 5 Input/Output 5.1 Principles of I/O hardware
Welcome to the world of ARM. COURSE CONTENT Module 1: Introduction  Introduction of ARM Processors  Evolution of ARM  32 - bit Programming Module 2:
CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
Digital Control CSE 421.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
IT3002 Computer Architecture
Embedded Programming B. Furman 09MAY2011. Learning Objectives Distinguish between procedural programming and embedded programming Explain the Events and.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
CSCI1600: Embedded and Real Time Software Lecture 15: Advanced Programming Concepts Steven Reiss, Fall 2015.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
An operating system (OS) is a collection of system programs that together control the operation of a computer system.
HOME AUTOMATION USING PC DONE BY RAJESHKUMAR S SRI HARSHA D.
Employment of scada system in water purification and transmission system.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
1 Chapter 1 Basic Structures Of Computers. Computer : Introduction A computer is an electronic machine,devised for performing calculations and controlling.
Big Picture Lab 4 Operating Systems C Andras Moritz
CEng3361/18 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2007 Recitation 01.
BITS Pilani Pilani Campus Pawan Sharma ES C263 Microprocessor Programming and Interfacing.
BATCH MEMBERS R.ABHISHEK-08N41A0401 K.DHEERAJ REDDY-08N41A0412 S.RAJENDRA REDDY-08N41A0458 JYOTHISHMATHI COLLEGE OF ENGINEERING AND TECHNOLOGY,TURKAPALLY.
Case Study #1 Microcontroller System. What is a microcontroller? A microcontroller can be considered a self-contained system with a processor, memory.
Information and Computer Sciences University of Hawaii, Manoa
Digital Control CSE 421.
ES C263 Microprocessor Programming and Interfacing
The Programmable Logic Controller
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Lecture 12 Input/Output (programmer view)
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Presentation transcript:

ulster.ac.uk Embedded Systems Designing the high level structure of your embedded system Ian McCrum School of Engineering

Assume you have to design an embedded system; your machine will read temperature, have a keypad, have a seven segment display or LCD as well as a number of switches, pushbuttons, LEDs, relays, solenoids and motors. It also has a serial communication capability Actually that system is typical – it doesn’t matter if it is a washing machine, a central heating controller or a complete automated house – nearly all systems have inputs from sensors, interfaces to and from humans, outputs to actuators and connections to other devices… (in general!) The rise of the “Internet of Things” IoT means we will see a lot more Wifi, Bluetooth, Zigbee or point to point linking of machines, Ethernet and even humble RS232 all matter. (RS232 can link GSM units to an embedded system) – so can SPI or I2C. But assume you have a number of C functions that provide robust input and output (“drivers”), and that functions exist to process and calculate the data. How do you connect together all this functionality ?

Method one: While(1){ do_task1(); do_task2(); do_task3(); do_task4(); }

Method Two: While(1){ do_a bit_of_task1(); do_a bit_of_task2(); do_a bit_of_task3(); do_a bit_of_task4(); }

main(){ … while(1){ do_task4(); do_other(); do_more(); } Method Three: ISR_task1() ISR_task2() ISR_task3() Events & Timers elapsing Interrupt happens

main(){ … while(1){ do_task4(); do_other(); do_more(); } Method Three: ISR_task1() ISR_task2() ISR_task3() Events & Timers elapsing Interrupt happens

Interrupts can be a powerful tool Dangerous! – hard to prove will work under all scenarios Hard to test, any mistake hangs the machine but this might only happen once every three months Last minute changes, upgrades to hardware all massively impact reliability of the system

Method Two: While(1){ do_a bit_of_task1(); do_a bit_of_task2(); do_a bit_of_task3(); do_a bit_of_task4(); } How can we implement this?

Implementing embedded systems using state machine methods In the infinite while loop we can have a switch statement that tests a variable to see where we are in the system. Switch/case statements test an int and have a multi-way branch structure – remember the role of break; though This state variable can be assigned meaningful names, rather than 1,2,3… This can be done using #define statements, or enum. Advanced state machines can use a table or array to hold the sequences of tasks, often a 2D array or an array of structs is used. Sometimes function pointers are used In our code we will avoid complex C and just #defines

State machines require a State Variable (SV). The SV is essentially a pointer that keeps track of the state that the microcontroller is in, and directs the program flow to the corresponding software module. The SV can be modified in the software modules (or states) themselves or by an outside function.

while(1){ // execute finite state machine switch(st){ INITIAL:start_timer(); st = WAIT_1_MSEC; break; WAIT_1_MSEC:if( time >= 1000 ){ st = GETTING_ADC } break; GETTING_ADC:If( adc_done() ){ update_average(); count++; if( count == 10 ) { st = DO_KEY_SCAN; // ev 10 ADC readings count = 0; }else{ st = CHECK_ALARM; }//-- end inner if --// }//-- end outer if --// break; DO_KEY_SCAN: scankeys(); if( keyhit() alarm_limit = getkey(); st = CHECK_ALARM; break; } CHECK_ALARM: If( alarm_limit <= average_temp ) buzz = 1; else buzz = 0; // better code would add hysteresis }//-- end switch – }//-- end while NEVER REACHED AS LOOPS FOREVER #define INITIAL 1 #define WAIT_1_MSEC 2 Etc., Or use enum states { INITIAL, WAIT_1_MSEC,…} st;

DO_KEY_SCAN: scankeys(); if( keyhit() & keynumber == 0) { // first time key hit dig1 = getkey(); keynumber=1; // remember state of entered keys st = CHECK_ALARM; // don’t block waiting for next key break; } if( keyhit() & keynumber == 1) { // 2nd key hit alarm_limit = dig1 * 10 + getkey() ; // xx keynumber=0; // reset state of entered keys st = CHECK_ALARM; // don’t block waiting for next key break; } If we need to wait for 2 keystrokes we could use the code below

What if we split our system into separate functions – called tasks or processes and had robust interprocess communications (IPC) This is what Operating systems do (they also can handle all i/o, manage memory, disks, cpu temperature and all respources of the computer)

How to design such systems? In the (very) old days we used “system analysts” who worked out what to do – they wrote the specifications for the programmers We evolved CASE tools (computer aided software tools) to try and help organise these systems We evolved various types of diagrams to pictorially represent systems. Current practice is to use UML - a set of diagrammatic methods; excellent way to model a system. But a complete course in their own right. We shall restrict ourselves to simple state diagrams, Algorithmic state diagrams and simple process diagrams using a subset of Mascot.

Mascot ( a subset) Activity - a task A channel - a queue, first in first out A pool – a global variable (could hide it a bit…) A device – Input/output A signal - a Semaphore (used as a flag)

A system reads a temperature, averages it and checks it against an alarm limit. It also receives RS232 messages that it either passes on or intercepts and sends temperature data back, and to the PC. We can use this technique to specify exactly what to do if using FreeRTOS. Temp Temp data RS232 in RS232 out RS232 to PC keypad in ALARM Alarm limit