This document discusses implementing multi-state systems using EOS. It provides examples of multi-state systems like traffic lights and washing machines. It describes two types of multi-state systems - those where state transitions depend only on time, and those where they depend on both time and inputs. The document outlines how to represent states, time durations, and update states in a program. It provides exercises to write programs for traffic lights and washing machines as multi-state systems.
O documento apresenta uma palestra de Renato Abdo sobre estratégias de marketing em mídias sociais. A palestra discute a importância de ouvir os consumidores nas redes, interpretar o que dizem sobre a marca, e engajar-se em diálogos para criar relacionamentos. Exemplos de casos bem-sucedidos com Natura e Lenovo são apresentados.
Presentatie Erik Woning op Online Educa Berlin 2012.
IT Competency Framework for Teachers. Engelstalige animatie en het kader zijn hier te vinden: http://www.kennisnet.nl/themas/ict-bekwaamheid/it-competency/
Este documento proporciona una lista actualizada de variedades de frutales protegidas de acuerdo con la legislación europea y española. Incluye información como el número de expediente, fecha de concesión de la protección, denominación, referencia del obtentor, código identificador y boletín oficial en el que se publicó. La lista contiene detalles de numerosas variedades de kiwi, mandarina clementina y otras frutas, protegidas a nivel comunitario o español.
Este documento describe el concepto de procomún y cómo puede aplicarse a la producción audiovisual. Define el procomún como un modelo de gobernanza para el bien común basado en principios como la transparencia, equidad y acceso universal. Explica que la producción orientada al procomún puede involucrar recursos como contenidos audiovisuales y educativos de libre acceso, hardware de producción cinematográfica, e infraestructuras de comunidades que colaboran en la producción, financiación, distribución y educación sobre contenidos audiovisuales siguiendo normas como
Elphel ha desarrollado varias cámaras de código abierto a lo largo de los años, incluyendo una cámara de 1.3 megapíxeles en 2001, una de 2 megapíxeles en 2002, y una de 11 megapíxeles en 2003. Sus cámaras utilizan sensores CMOS y CCD y ofrecen funciones como tasas de cuadro variables, resoluciones variables, y la capacidad de grabar en formatos RAW de código abierto.
Este documento presenta una serie de ejercicios mentales breves como tests para evaluar la capacidad de cálculo mental y procesamiento rápido de información del cerebro. Los ejercicios incluyen sumas mentales, contar letras en un texto y responder preguntas mentales sobre herramientas y colores de forma rápida. Al final, se indica que la mayoría de las personas piensan en un martillo rojo, lo que sugiere que son normales, mientras que pensar en otra cosa indica ser parte del 2% más diferente.
Este documento es una carta de regalos simbólicos de amistad de una persona para otra. Los regalos incluyen amistad, sonrisas, sueños, apoyo, abrazos, luz, humildad, cariño, fe, lágrimas y ángeles para acompañarla en los momentos difíciles y asegurarle que no está sola.
O documento apresenta uma série de frases curtas sobre diferentes tópicos como amor, felicidade, erros e virtudes. A mensagem principal é que o amor é essencial para dar sentido à vida e às nossas ações.
O documento apresenta uma palestra de Renato Abdo sobre estratégias de marketing em mídias sociais. A palestra discute a importância de ouvir os consumidores nas redes, interpretar o que dizem sobre a marca, e engajar-se em diálogos para criar relacionamentos. Exemplos de casos bem-sucedidos com Natura e Lenovo são apresentados.
Presentatie Erik Woning op Online Educa Berlin 2012.
IT Competency Framework for Teachers. Engelstalige animatie en het kader zijn hier te vinden: http://www.kennisnet.nl/themas/ict-bekwaamheid/it-competency/
Este documento proporciona una lista actualizada de variedades de frutales protegidas de acuerdo con la legislación europea y española. Incluye información como el número de expediente, fecha de concesión de la protección, denominación, referencia del obtentor, código identificador y boletín oficial en el que se publicó. La lista contiene detalles de numerosas variedades de kiwi, mandarina clementina y otras frutas, protegidas a nivel comunitario o español.
Este documento describe el concepto de procomún y cómo puede aplicarse a la producción audiovisual. Define el procomún como un modelo de gobernanza para el bien común basado en principios como la transparencia, equidad y acceso universal. Explica que la producción orientada al procomún puede involucrar recursos como contenidos audiovisuales y educativos de libre acceso, hardware de producción cinematográfica, e infraestructuras de comunidades que colaboran en la producción, financiación, distribución y educación sobre contenidos audiovisuales siguiendo normas como
Elphel ha desarrollado varias cámaras de código abierto a lo largo de los años, incluyendo una cámara de 1.3 megapíxeles en 2001, una de 2 megapíxeles en 2002, y una de 11 megapíxeles en 2003. Sus cámaras utilizan sensores CMOS y CCD y ofrecen funciones como tasas de cuadro variables, resoluciones variables, y la capacidad de grabar en formatos RAW de código abierto.
Este documento presenta una serie de ejercicios mentales breves como tests para evaluar la capacidad de cálculo mental y procesamiento rápido de información del cerebro. Los ejercicios incluyen sumas mentales, contar letras en un texto y responder preguntas mentales sobre herramientas y colores de forma rápida. Al final, se indica que la mayoría de las personas piensan en un martillo rojo, lo que sugiere que son normales, mientras que pensar en otra cosa indica ser parte del 2% más diferente.
Este documento es una carta de regalos simbólicos de amistad de una persona para otra. Los regalos incluyen amistad, sonrisas, sueños, apoyo, abrazos, luz, humildad, cariño, fe, lágrimas y ángeles para acompañarla en los momentos difíciles y asegurarle que no está sola.
O documento apresenta uma série de frases curtas sobre diferentes tópicos como amor, felicidade, erros e virtudes. A mensagem principal é que o amor é essencial para dar sentido à vida e às nossas ações.
- Real-time operating systems provide tools for prioritized control and synchronization of tasks on embedded systems. They manage processes, memory, and communication between tasks.
- An OS acts as an intermediary between the user and hardware, making use of the computer convenient and efficient by hiding messy details and optimally allocating resources like the CPU.
- On embedded systems specifically, an OS provides software tools to conveniently control tasks according to programmer-assigned priorities and synchronize access to shared resources through mechanisms like semaphores.
The document discusses Linux runlevels, changing runlevels, and shutting down or rebooting a Linux system. It covers:
- Linux systems support runlevels 0-6, with levels 0, 1, 6 having specific purposes like halt, single-user mode, reboot. Levels 2-5 are for multi-user modes.
- The default runlevel is set in /etc/inittab and runlevel scripts are located in /etc/rc.d/rc?.d. The telinit command or changing the kernel command line can change runlevels.
- Clean shutdown is done with the shutdown command, which alerts users, signals processes, and changes runlevels gracefully. Halt, reboot,
This document discusses control flow in programming. It defines control flow as the order that a computer executes lines of code in a program. There are three main types of control flow: sequence, selection, and iteration. Sequence refers to statements executing sequentially in the order written. Selection (conditional) allows executing one of two possible paths depending on a condition. Iteration (repetitive/looping) repeats a block of code while a condition is true. Specific control structures like if/else, switch, for, while, and do-while are presented with examples to illustrate each type of control flow.
This document provides a cheatsheet comparing commands for managing services and system states between SysV init and systemd. It lists the equivalent systemd commands for common SysV init commands like service, chkconfig, and runlevels. It also covers commands for viewing and filtering journal logs, changing targets/runlevels, and rebooting/powering off the system.
Control structures in C and C++ alter program execution flow and include sequences, selections, and loops. Selection structures include if/else statements and switch statements to control program branches. Loop structures like for, while, and do-while loops repeat a set of statements until a condition is met. For example, a for loop initializes a counter, checks a condition on each iteration, and updates the counter to repeat statements like printing numbers from 1 to 10.
1) Arrays allow storing multiple values of the same type under one variable name using subscripts. One-dimensional arrays store elements in a single list, while multi-dimensional arrays can store elements in multiple lists.
2) Control statements like if/else, switch, while, do-while, for, break, continue and return allow altering the flow of execution in a program.
3) Classes are blueprints that define the structure and behavior of objects. Classes contain variables and methods, and objects are instances of classes that store their own set of variable values.
The Chandy-Lamport algorithm allows processes in a distributed system to consistently capture a global snapshot of the system state. Any process can initiate the snapshot by sending a marker message along outgoing communication channels. When a process receives a marker, it records its local state and the state of incoming channels before sending markers on other outgoing channels. This propagation of markers throughout the system allows each process to consistently record its state and the state of all communication channels, providing an accurate view of the global system state at a single point in time.
This document discusses key concepts related to operating system processes. It defines a process as stored code and data loaded into an assigned address space. It describes the different states a process can be in like running, ready, and blocked. It also discusses concepts like scheduling policies, address spaces, system calls, and context switching which are important mechanisms for an operating system to manage processes and share resources like the CPU.
This document discusses different types of process schedulers in an operating system:
1. Long term schedulers determine which programs are admitted to the system and load them into memory.
2. Short term (CPU) schedulers select ready processes and allocate the CPU to one of them.
3. Medium term schedulers handle swapped out processes and can reintroduce processes back into memory.
Context switching allows multiple processes to share the CPU by storing and restoring a process's state from its process control block when switching between processes. This switching is computationally expensive so some hardware uses multiple register sets.
This document provides instructions for maintaining a record book and following lab procedures for an advanced instrumentation lab at Vellore Institute of Technology. It outlines how to properly document experiments by including the date, experiment name and number, aim, circuit tables, diagrams, and getting staff certification. Safety instructions are provided, such as handling equipment carefully and not leaving the lab without permission. Finally, it lists 15 experiments to be completed, including implementing logic gates, timers, counters and process controls using a PLC.
2. Control structures with for while and do while.pptManojKhadilkar1
This document introduces various control flow statements in C programming including decision control statements like if, if-else, else-if ladder and switch statements. It also covers loop control statements like while, do-while and for loops. It provides the syntax and examples of using each statement. Key points covered include using break, continue and goto to alter normal program flow, and the exit() function to terminate a program.
Master-Trol is a electronic water management software system used to regulate water usage, provide complete control over the use of water fixtures in a facility and provide reports on water consumption.
For more information, please visit www.acorneng.com
The document discusses different types of iteration logic or loops in C programming. It describes the repeat-for loop, repeat-while loop, for loop, while loop, and do-while loop. The key aspects of each loop type are defined, including initialization, condition checking, updating, and flow of execution through the loop body. Examples are provided to illustrate the usage and flow of each loop type.
This document discusses process management in operating systems. It describes the attributes of a process, including process ID, program counter, state, priority, registers, and open files/devices. Process states include new, ready, running, waiting, and terminated. Processes move between these states during execution. The document also discusses process queues like job, ready, and waiting queues that the operating system uses to manage processes in different states. It covers process operations like creation, scheduling, execution, and deletion. Finally, it describes long term, short term, and medium term schedulers that help manage processes and resources.
This document discusses programming fundamentals and control structures in C++. It covers three main control structures: sequences which execute statements sequentially, repetition (looping) which repeats statements while a condition is met, and selection (branching) which executes instructions depending on conditions. Specific structures covered include if/else, switch, while, do-while, for, and nested loops. Control flow and how these structures direct a program's execution is also explained.
This document provides an introduction to Java programming concepts including what Java is, how to set up a Java development environment, basic Java code structure, variables, data types, arithmetic operations, conditional statements, loops, and getting user input. It covers elementary Java topics through examples and explanations. Key points include how to write, compile and run a simple Java program that prints "Hello World", how to declare and use variables of different data types, the different conditional statements (if, if-else, if-else-if-else), looping constructs (while, do-while, for), and taking user input using the Scanner class.
This document provides an overview of real-time operating systems (RTOS) fundamentals. It discusses when an RTOS is appropriate, key RTOS concepts like tasks and scheduling, terminology, and factors to consider when choosing an RTOS for a project. The objectives are to understand RTOS terminology, functions, and how it affects programming style and to learn what to consider when selecting an RTOS.
The document describes basic concepts related to machines, hosts, clients, servers, workstations, processes, daemons, distributed systems, and kernels. It then provides details about the boot PROM including its functions, components, configuration information storage, and commonly used commands. Finally, it outlines the boot PROM booting process and describes emergency sequences and diagnostic modes that can be accessed using stop key sequences.
This document discusses hardware and software solutions for critical section problems in multiprocessing systems. It introduces the TestAndSet instruction, which atomically sets a variable to true and returns its previous value. This can be used to implement mutual exclusion. Semaphores are also introduced as another synchronization primitive, with binary semaphores functioning similarly to mutex locks. Implementations of semaphores are discussed where processes block rather than busy wait, avoiding wasted CPU cycles. Deadlock and starvation scenarios are briefly described.
There are two types of booting a computer: a cold boot which starts the machine from an off state, and a warm boot which resets the system after it has been running. To cold boot, turn on the monitor, peripherals, system unit, and wait for startup. To warm boot or restart, exit all programs, click start and select restart. To shut down, exit all programs, click start and select turn off, then turn off peripherals, monitor, and power once the computer indicates it is safe to do so.
- Real-time operating systems provide tools for prioritized control and synchronization of tasks on embedded systems. They manage processes, memory, and communication between tasks.
- An OS acts as an intermediary between the user and hardware, making use of the computer convenient and efficient by hiding messy details and optimally allocating resources like the CPU.
- On embedded systems specifically, an OS provides software tools to conveniently control tasks according to programmer-assigned priorities and synchronize access to shared resources through mechanisms like semaphores.
The document discusses Linux runlevels, changing runlevels, and shutting down or rebooting a Linux system. It covers:
- Linux systems support runlevels 0-6, with levels 0, 1, 6 having specific purposes like halt, single-user mode, reboot. Levels 2-5 are for multi-user modes.
- The default runlevel is set in /etc/inittab and runlevel scripts are located in /etc/rc.d/rc?.d. The telinit command or changing the kernel command line can change runlevels.
- Clean shutdown is done with the shutdown command, which alerts users, signals processes, and changes runlevels gracefully. Halt, reboot,
This document discusses control flow in programming. It defines control flow as the order that a computer executes lines of code in a program. There are three main types of control flow: sequence, selection, and iteration. Sequence refers to statements executing sequentially in the order written. Selection (conditional) allows executing one of two possible paths depending on a condition. Iteration (repetitive/looping) repeats a block of code while a condition is true. Specific control structures like if/else, switch, for, while, and do-while are presented with examples to illustrate each type of control flow.
This document provides a cheatsheet comparing commands for managing services and system states between SysV init and systemd. It lists the equivalent systemd commands for common SysV init commands like service, chkconfig, and runlevels. It also covers commands for viewing and filtering journal logs, changing targets/runlevels, and rebooting/powering off the system.
Control structures in C and C++ alter program execution flow and include sequences, selections, and loops. Selection structures include if/else statements and switch statements to control program branches. Loop structures like for, while, and do-while loops repeat a set of statements until a condition is met. For example, a for loop initializes a counter, checks a condition on each iteration, and updates the counter to repeat statements like printing numbers from 1 to 10.
1) Arrays allow storing multiple values of the same type under one variable name using subscripts. One-dimensional arrays store elements in a single list, while multi-dimensional arrays can store elements in multiple lists.
2) Control statements like if/else, switch, while, do-while, for, break, continue and return allow altering the flow of execution in a program.
3) Classes are blueprints that define the structure and behavior of objects. Classes contain variables and methods, and objects are instances of classes that store their own set of variable values.
The Chandy-Lamport algorithm allows processes in a distributed system to consistently capture a global snapshot of the system state. Any process can initiate the snapshot by sending a marker message along outgoing communication channels. When a process receives a marker, it records its local state and the state of incoming channels before sending markers on other outgoing channels. This propagation of markers throughout the system allows each process to consistently record its state and the state of all communication channels, providing an accurate view of the global system state at a single point in time.
This document discusses key concepts related to operating system processes. It defines a process as stored code and data loaded into an assigned address space. It describes the different states a process can be in like running, ready, and blocked. It also discusses concepts like scheduling policies, address spaces, system calls, and context switching which are important mechanisms for an operating system to manage processes and share resources like the CPU.
This document discusses different types of process schedulers in an operating system:
1. Long term schedulers determine which programs are admitted to the system and load them into memory.
2. Short term (CPU) schedulers select ready processes and allocate the CPU to one of them.
3. Medium term schedulers handle swapped out processes and can reintroduce processes back into memory.
Context switching allows multiple processes to share the CPU by storing and restoring a process's state from its process control block when switching between processes. This switching is computationally expensive so some hardware uses multiple register sets.
This document provides instructions for maintaining a record book and following lab procedures for an advanced instrumentation lab at Vellore Institute of Technology. It outlines how to properly document experiments by including the date, experiment name and number, aim, circuit tables, diagrams, and getting staff certification. Safety instructions are provided, such as handling equipment carefully and not leaving the lab without permission. Finally, it lists 15 experiments to be completed, including implementing logic gates, timers, counters and process controls using a PLC.
2. Control structures with for while and do while.pptManojKhadilkar1
This document introduces various control flow statements in C programming including decision control statements like if, if-else, else-if ladder and switch statements. It also covers loop control statements like while, do-while and for loops. It provides the syntax and examples of using each statement. Key points covered include using break, continue and goto to alter normal program flow, and the exit() function to terminate a program.
Master-Trol is a electronic water management software system used to regulate water usage, provide complete control over the use of water fixtures in a facility and provide reports on water consumption.
For more information, please visit www.acorneng.com
The document discusses different types of iteration logic or loops in C programming. It describes the repeat-for loop, repeat-while loop, for loop, while loop, and do-while loop. The key aspects of each loop type are defined, including initialization, condition checking, updating, and flow of execution through the loop body. Examples are provided to illustrate the usage and flow of each loop type.
This document discusses process management in operating systems. It describes the attributes of a process, including process ID, program counter, state, priority, registers, and open files/devices. Process states include new, ready, running, waiting, and terminated. Processes move between these states during execution. The document also discusses process queues like job, ready, and waiting queues that the operating system uses to manage processes in different states. It covers process operations like creation, scheduling, execution, and deletion. Finally, it describes long term, short term, and medium term schedulers that help manage processes and resources.
This document discusses programming fundamentals and control structures in C++. It covers three main control structures: sequences which execute statements sequentially, repetition (looping) which repeats statements while a condition is met, and selection (branching) which executes instructions depending on conditions. Specific structures covered include if/else, switch, while, do-while, for, and nested loops. Control flow and how these structures direct a program's execution is also explained.
This document provides an introduction to Java programming concepts including what Java is, how to set up a Java development environment, basic Java code structure, variables, data types, arithmetic operations, conditional statements, loops, and getting user input. It covers elementary Java topics through examples and explanations. Key points include how to write, compile and run a simple Java program that prints "Hello World", how to declare and use variables of different data types, the different conditional statements (if, if-else, if-else-if-else), looping constructs (while, do-while, for), and taking user input using the Scanner class.
This document provides an overview of real-time operating systems (RTOS) fundamentals. It discusses when an RTOS is appropriate, key RTOS concepts like tasks and scheduling, terminology, and factors to consider when choosing an RTOS for a project. The objectives are to understand RTOS terminology, functions, and how it affects programming style and to learn what to consider when selecting an RTOS.
The document describes basic concepts related to machines, hosts, clients, servers, workstations, processes, daemons, distributed systems, and kernels. It then provides details about the boot PROM including its functions, components, configuration information storage, and commonly used commands. Finally, it outlines the boot PROM booting process and describes emergency sequences and diagnostic modes that can be accessed using stop key sequences.
This document discusses hardware and software solutions for critical section problems in multiprocessing systems. It introduces the TestAndSet instruction, which atomically sets a variable to true and returns its previous value. This can be used to implement mutual exclusion. Semaphores are also introduced as another synchronization primitive, with binary semaphores functioning similarly to mutex locks. Implementations of semaphores are discussed where processes block rather than busy wait, avoiding wasted CPU cycles. Deadlock and starvation scenarios are briefly described.
There are two types of booting a computer: a cold boot which starts the machine from an off state, and a warm boot which resets the system after it has been running. To cold boot, turn on the monitor, peripherals, system unit, and wait for startup. To warm boot or restart, exit all programs, click start and select restart. To shut down, exit all programs, click start and select turn off, then turn off peripherals, monitor, and power once the computer indicates it is safe to do so.
1. Programming embedded systems
Seminar 6
Multi-state systems
Dr. Tran Thanh Hung
Department of Automation Technology,
College of Engineering, Can Tho University
Email: tthung@ctu.edu.vn
2. Review hệ thống nhiều trạng thái
In the seminar 5, we have used EOS to implement periodic
functions for one state system.
In this seminar, we will use EOS to implement multi-state systems.
3. Outline
How to implement for multi-state systems?
• multi-state systems: hệ thống nhiều trang thái
• implement for multi-state systems: type 1
• implement for multi-state systems: type 2 viết được chương trình
thực thi hệ thống nhiều trạng thái
4. Seminar objectives
At the end of this seminar, by referring the lecture notes,
students will be able to:
• understand issue of multi-state systems
• implement multi-state systems, using EOS
5. What are multi-state systems?
Example of multi-state system: hệ thống có nhiều trạng
thái khác nhau
• Traffic light system
3 state system
4 state system
6. What are multi-state systems?
Example of multi-state system:
• Washing machine máy giặc
Bắt đầu Nước nóng
7. Types of multi-state systems
• Type 1: Multi-state (timed) system:
The transition between states will depend only on the passage of time.
- Example: Traffic light system
• Type 2: Multi-state (input/timed) system:
The transition between states will depend both on the passage of time and system
inputs. Ngoài thời gian còn phụ thuộc 1 số điều kiện ngõ vào- máy giặc
- Example: Washing machine
• Type 3: Multi-state (input) system:
The transition between states will depend only on system inputs.
- Chuyện trạng thái này sang trạng thái kia phụ thuộc đk ngõ vào
8. How to implement multi-state systems?
• You are going to write a program for a traffic light system,
operating on the following states:
− State 1 (RED): Turn Red light on for 10 seconds and go to State
2: bật đèn đỏ trong 10s
− State 2 (GREEN): Turn Green light on for 15 seconds and go to
State 3 bật đèn xanh trong 15s
− State 3 (YELLOW): Turn Yellow light on for 3 seconds and go to
State 1 bật đèn vàng trong 3s
9. EOS: Review
#include "Main.h"
#include "EOS.h"
void main (void)
{ EOS_init(50000); //Initialize EOS to interrupt every 50ms
while(1)
{ LPM1; // Enter low power mode to save power ngủ
}
}
#pragma vector = TIMERA0_VECTOR
interrupt void EOS_ISR(void)
{
// Put your code here hàm phục vụ ngắt, viết chương trình, hàm riêng, file riêng
Gọi 1 giây 1 lần , kt 20 lan
…
}
10. Implement multi-state systems
• Represent the states Tên kiểu
0 1 2
typedef enum {RED,GREEN,YELLOW} Light_State; khai báo kiểu liệt kê
static Light_State current_state = RED; //initial state = RED
• Define duration for the states
#define RED_DURATION 10 // time đen đỏ
̀
̀
#define GREEN_DURATION 15 // time đen xanh
̀ ̀
#define YELLOW _DURATION 3 // time đen vang
• Define global variables to measure time
static unsigned int time_in_state = 0; // time (s) in each state
Ghi chú: Đặt trong file TRAFFIC_LIGHTS_Update.c
11. Implement multi-state systems
• Update states hàm cập nhật trạng thái và công việc mỗi trạng thái
//This function must be called every 1s by EOS_ISR
void TRAFFIC_LIGHTS_Update(void)
{ switch (current_state)
{ case RED:
{ turn on Red light; turn off other lights;// bật đèn đỏ, tắt đèn vàng
if (++time_in_state == RED_DURATION) // đã đến time chuyển
trạng thái hay chưa, kiểm tra cho đến khi
{ current_state = GREEN; //change state
time_in_state = 0;
}
break;// thoát ra ngủ
}
Ghi chú: Đặt trong file TRAFFIC_LIGHTS_Update.c
12. Implement multi-state systems
case GREEN :
{ turn on Green light; ; turn off other lights;
…
break;
}
case YELLOW :
{ turn on Yellow light ; turn off other lights;
…
break;
}
}
}
13. Exercise 6.1
• Write a program to control a complete traffic light
system with states and hardware configuration as
following:
14. Type 2 multi-state systems
Ngõ vào
Bắt đầu
Chọn
Mức nước
Nhiệt độ
Led hiển thị
Chứa bột gặt
15. Type 2 multi-state systems
Operating description of the washing machine:
1. The user selects a wash program on the selector dial or keypad.// bắm
nút chọn chế đọ giặc 10 phím
2. The user presses the ‘Start’ switch. Ng sử dụng bấm star
3. The door lock is engaged.// nước chay ra
4. The water valve is opened to allow water into the wash drum.// if cần bột
giặc sẽ mở ra
5. If the wash program involves detergent, the detergent hatch is opened.//
When the detergent has been released, the detergent hatch is closed.
6. When the ‘full water level’ is sensed, the water valve is closed.// mức
nước đòng
16. Type 2 multi-state systems
7. If the wash program involves warm water, the water heater is switched
on. When the water reaches the correct temperature, the water heater is
switched off.// nếu cần nóng, thì mở và tắt đử lớn
8. The washer motor is turned on to rotate the drum. At the end of the wash
cycle, the motor is stopped.// quay lòng giặc
9. The pump is switched on to drain the drum. When the drum is empty, the
pump is switched off.// bơm nước sau khi giặc
10. The water valve is opened to allow water into the wash drum.// mở nước
11. The washer motor is turned on to rotate the drum (to rinse detergent).//
quay giặc
12. The pump is switched on to drain the drum… bơm nươć ra
17. Type 2 multi-state systems
10 trạng thái
Khởi động
Cấm điện
Quá time mà chưa được, báo lỗi
giặc
Xả
18. Type 2 multi-state systems
typedef enum {INIT, START, FILL1, HEAT,WASH,DRAIN1,FILL2, RINSE,
DRAIN2, ERROR} System_state;// khai báo kiểu dl liệt kê
#define MAX_FILL_DURATION 1000// xa nước tôi đa
́
#define MAX_HEAT_DURATION 1000// đun nươć tôi đa
́
#define MAX_DRAIN_DURATION 1000// chơ nươc đây ̀
static System_state current_state = INIT; //initial state khai báo gắn gt ban
đầu
static unsigned char Detergent [10] = {1,1,1,0,0,1,0,1,1,0};// man chưa số nhị
̃
phân, tương ưng 10 chế độ giăc
̣
static unsigned char Heat[10] = {1,1,1,0,0,1,0,1,1,0};// nươc nong
́
static unsigned char wash_program = 0;//chương trình giặc chọn
static unsigned char time_in_state = 0; // time (s) in each state// đếm time
trong trạng thái
19. Type 2 multi-state systems
void WASHER_Update(void) // Call once per second by EOS_ISR// diều khiển và
cập nhật trạng tahsi hệ thống// hệ thống loại 3
{
switch (current_state)
{
case INIT:
{ Display the state on LEDs;// hiển thị trang thái hiện tại lên led
p1out = current_state
turn all motor, valve off// tắt all motor và valve đi
//kif eyscan 0-9{
wash_program = read keypad (SWs); //0-9// đọc phím kt chọn chế độ giặc}
Display the wash_program user chosen on LEDs;// if
(Start SW pressed) current_state = START;// kt start có đc bấm ko, chuyển sang
trạng thái start, ko phụ thuộc time
break;
}
}
20. Type 2 multi-state systems
case START:
{ Display the state on LEDs;// hiển led có phải 1//Pour =C
lock the door;// khóa cửa mấy giậc -> khỏi làm
open the valve to fill water;// mở valve nước
if (Detergent[wash_program] ==1) // xét mãn với chế độ
giặc
open Detergent Hatch;// mở hộp bột giặc
current_state = FILL1;// đặt trạng thái fill1
Time_in_state = 0;//
break;
}
21. Type 2 multi-state systems
case FILL1 :
{ Display the state on LEDs;//
if (++Time_in_state >= MAX_FILL_DURATION)// kt time danh cho time đổ
nước vô
current_state = ERROR;
if (Drum is full water) // nước đầy hay chưa
{ close the valve;
if (Heat[wash_program] == 1) // Does program require hot water?// có cần
nướ nóng hay ko có =1 hay ko
{ Turn on Heater;/ bật bộ đun nước lên
current_state = HEAT;Time_in_state = 0
else
{ current_state = WASH;Time_in_state = 0;} ;}// vào thẳng chế độ
giặc
}
break;
}
22. ĐỒ ÁN
• Viết chương trình cho máy giặt, theo mô tả trên
Quy ước: Dùng
- phím SW15 làm nút Start
- SW12 cam bien bao het nuoc, chuyen qua trang thai khac
- phím SW10 làm cảm biến mức nước (bấm = nước đầy), bấm vào là báo hệ thống
đầy
- phím SW11 làm cảm biến nhiệt độ (bấm = nhiệt độ đạt yêu cầu), bấm thì nhiệt độ
đã đạt
- LED ở P1.7 làm van nước, mở van nước, đèn tắt van đóng
- LED ở P1.6 làm hộp đựng bột giặt, sáng, hộp đựng bột giạc đã có
- LED ở P1.5 làm bộ đun nước
- LED ở P1.4 làm motor lồng giặt
- LED ở P1.3 làm bơm nước
- Trang thai error p1.0 p1.1 p1.2
- Trang thai giat 20s