1 / 45

IT-606 Embedded Systems (Software )

IT-606 Embedded Systems (Software ). S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay. Esterel Tools & Illustrative Examples S. Ramesh. Esterel Tools. Compiler C-code for simulation C-code for target implementation in SW bliff code for implementation in HW and verification

mingan
Télécharger la présentation

IT-606 Embedded Systems (Software )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IT-606Embedded Systems(Software) S. Ramesh Kavi Arya Krithi Ramamritham KReSIT/ IIT Bombay

  2. Esterel Tools & Illustrative ExamplesS. Ramesh

  3. Esterel Tools • Compiler • C-code for simulation • C-code for target implementation in SW • bliff code for implementation in HW and verification • Simulator - Xes • Verifer • Xeve • fctools • atg

  4. Make file - An example all: blif genc obj es blif: esterel –Lblif :-soft -causal -main simple auto.strl genc: esterel -simul -main simple auto.strl obj: gcc -w -c auto.c es: xes auto.o

  5. The simulation tool - Xes

  6. Verification Tools • Xeve • converts bliff code into fc2 format • hiding of signals • FcTools • Automata minimization • Automata abstractions • Atg • display of automaton • Manual inspection

  7. Code generator • Compiler (without special options) produces • reactive engine that implements the automaton • one function for each input signal • the reactive engine is just a procedure • user has to write a main program that calls the engine • user has to write a function for each output signal and sensor • when to call the engine, which input signals are simultaneous decided by the user • the engine calls the output functions

  8. Example Main:: every milli second for every input that has occurred call f_input(par); call f_kernel; end • Assume interface functions run concurrently with the main program • Input parameter gets the value from specific registers or memory • f_kernel calls output functions corresponding to emitted outputs

  9. A Simple Example An Auto Controller: • initially waits for the engine to be on • when car is running, acceleration/deceleration controls the throttle valve • car stops when the ignition is off

  10. The code module simple: input ignition_on,ignition_off,accel; output control_throttle; loop abort await ignition_on; every accel do emit control_throttle end every when ignition_off end end module

  11. Use of Esterel Tools • compile the program to simulate (-simul option) • compile the program to generate bliff code • use xeve to generate automaton • use atg for visual display

  12. Automaton for Simple controller

  13. A Complex Controller Additional safety feature: • monitors status of the door (closed or open) while in motion • sends out alarm when door opens • ensures that doors are closed while starting

  14. The code module complex: input ignition_on,ignition_off,accel; input door_opened, door_locked; output alarm,control_throttle,door_lock; loop abort await ignition_on; emit door_lock; loop await door_locked; abort every accel do emit control_throttle end every when door_opened; emit alarm; emit door_lock; end; when ignition_off end end module

  15. Automaton for Complex controller

  16. Lego Mindstorm Robot

  17. Mindstorms robots • Smart toys assembled using certain Lego bricks called, Robotics Invention System • RCX brick (microcomputer), inspired by MIT media lab. Programmable Brick • touch sensors • light sensor • Motors • IR Transceiver • Serial cable

  18. RCX • Lego Micro computer • 8 bit 16 MHz Hitachi controller • 8K ROM, 19K RAM • Supports three touch sensors, three motors and one light sensor • Programmed using PC • Loaded using IR transmitter connected through serial cable • Programmed using RCS programming language • Program receives sensor inputs and controls motor movements

  19. Synchronous Programming • Mindstorms can be programmed using synchronous languages, like Esterel. • Thanks to an effort by some french groups • http://www.emn.fr/x-info/lego// • Makes use of LegOS, its tools and APIs

  20. LegOS • An open source OS for lego Mindstorms initiated by Markus L. Noga • Web page: http://www.noga.de/legOS/ • Supports (version 0.2.0) • Dynamic loading of programs and modules • Full IR packet networking • Preemptive multitasking • Dynamic memory management • Drivers for all RCX subsystems

  21. Cross Compilation • The OS cross - compiled on a PC and downloaded onto the RCX via IR transceiver • Runs in both Linux and windows • Provides many APIs for application programs • Inputting from Sensors • Actuating motors • Application programs (in C) use these APIs to control • cross-compiled and loaded onto the RCX

  22. Esterel Programming • Applications can be written in Esterel • An extension of Esterel compiler is available • Need to use specific names for inputs and outputs • touch_1, touch_3, motor_a_speed, motor_b_speed, cputs etc. • Here is an example

  23. A simple program module lego1 : input TOUCH_1, TOUCH_3; output MOTOR_A_SPEED(integer), MOTOR_C_SPEED(integer),    MOTOR_A_DIR(integer), MOTOR_C_DIR(integer),    CPUTS(string); relation TOUCH_1 # TOUCH_3; constant MOTOR_FWD, MOTOR_REV, MAX_SPEED : integer;

  24. var t : integer inemit MOTOR_A_SPEED(MAX_SPEED/2); emit MOTOR_C_SPEED(MAX_SPEED/2); loop   emit MOTOR_A_DIR(MOTOR_FWD); emit MOTOR_C_DIR(MOTOR_FWD); emit CPUTS("fwd"); await [TOUCH_1 or TOUCH_3]; present TOUCH_1 then         t:=1; else          t:=3;   end present;

  25. emit MOTOR_A_DIR(MOTOR_REV); emit MOTOR_C_DIR(MOTOR_REV); emit CPUTS("rev"); await 100 tick;        % 1 tick = 1 ms if t=1 then emit MOTOR_A_DIR(MOTOR_FWD); emit CPUTS("right"); else          emit MOTOR_C_DIR(MOTOR_FWD); emit CPUTS("left"); end if; await 100 tick;  % 1 tick = 1 ms end loop end var.

  26. Compiling • This program can be simulated • Compiled using the extended compiler to generate C code • Use legOS cross compiler to generate code and download onto the RCX • Look at the web-site for more examples

  27. A Simple Case-study Plastic Injection Controller • a simple controller • controls a plastic injection unit. • The unit injects plastic material from a tank into a molding chamber • When chamber is empty, a motor started in the forward direction • motor moves a piston until it reaches position B

  28. Illustration (contd.) • motion is reversed until position A reached in the opposite direction • plastic material in the tank heated by a coil • temperature of the tank controlled between Tmin and Tmax

  29. Time Constraints • motor must stop within tin time units after signals A and B are emitted as otherwise, the piston might get stuck • contact switch made on/off within ttemp after temperature limits Tmin and Tmax reached to avoid boiling and keep it flowing

  30. The code: module simple:constant T_min=30:integer, T_max=100:integer;input A,B,form_empty;sensor Temp: integer;output motor_on(boolean), motor_off;output contact_on,contact_off;relation A#B;

  31. [ loop if ?Temp<T_min then emit contact_on end; if ?Temp>T_max then emit contact_off end; await tick;end||loopawait form_empty; emit motor_on(true);await B;emit motor_on(false);await A;emit motor_off;end]end module

  32. Use of Esterel Tools

  33. A Cruise Controller A more complex auto controller: • includes the feature of cruise mode of driving • illustrates the features like modules, valued signals and procedure calls

  34. module cruise: input cruise; input accel,brake_pressed; input engine_off; input accel_released,ignition_on; input belt_fastened,belt_unfastened; output chk_belts,start_engine; output control_throttle:double; output alarm; input current_speed:integer; output cruising; procedure increase_speed(double)(integer); procedure compute_throttle(double) (integer,integer);

  35. loop await ignition_on; emit chk_belts; await belt_fastened; emit start_engine;

  36. || every belt_unfastened do emit alarm end ] abort [ loop abort run manual_mode; when cruise; abort run cruise_mode; when brake_pressed; end loop when engine_off end loop end module

  37. module manual_mode: input accel_released,accel; output control_throttle:double; var th$_value:=5.0:double,val:=0:integer in loop abort every accel do emit control_throttle(th_value + 2.0); end every when accel_released; end end var  end module

  38. module cruise_mode: input current_speed:integer; output control_throttle:double, cruising; procedure compute_throttle(double) (integer,integer); var cruise_speed:=?current_speed:integer, th_value:double in cruise_speed:=?current_speed; every tick do call compute_throttle(th_value) (?current_speed,cruise_speed); emit control_throttle(th_value); emit cruising end end var end module

  39. A Train Controller • controls the movement of an automatic train • train moves back and forth between a set of stations • no request means the train is idle at one of the stations • request are serviced eventually • door is closed when the train is in motion • buttons are provided inside the train and in the stations

  40. module Train: input d_closed, d_opened, stn_arrived(integer); input request(integer); output d_close,d_open, t_run, t_stop; loop var X: integer in emit d_open; await d_opened; await request; X:=?request; emit d_close; await d_closed; trap Stop in

  41. loop abort sustain t_run when stn_arrived; if X=?stn_arrived then emit t_stop; exit Stop; end end %loop end %trap end %var end %outer loop end module

  42. A mine pump controller • controls a pump that drains excess water in the mines • pump should start draining when water level is high • pump has to stop when water is too low • mine has methane which is combustible when the pump is on • high dose of CO is lethal • warnings are to be issued • auto and manual mode for pump • pump is started and stopped under operator control • default is auto

  43. module pump_controller: input start,stop,methane,co,hw_level; input lw_level,manual; input auto; output p_run,p_stop,m_alarm,c_alarm; [ loop abort loop await hw_level; await immediate [ not methane ]; abort sustain p_run

  44. when [ methane or lw_level ]; emit p_stop end when manual; abort loop await start; await immediate [ not methane ]; abort sustain p_run when [methane or stop]; emit p_stop; end

  45. when auto; end loop || every methane do emit m_alarm; end every || every co do emit c_alarm end every ] end module

More Related