130 likes | 150 Views
Fuel Cell Power Plant A Control Dominated Example. controller sense: Temperature H 2 Output Current Output Voltage Fan Speed control H2 valves Output MOSFET Fan Speed Stack MOSFETS. Air. H 2. Heat. H 2 0.
E N D
Fuel Cell Power Plant A Control Dominated Example • controller • sense: • Temperature • H2 • Output Current • Output Voltage • Fan Speed • control • H2 valves • Output MOSFET • Fan Speed • Stack MOSFETS Air H2 Heat H20 not showing power supply circuitry for the controller…runs off fuel cell w/ backup battery. CSE 466 – Fall 2000 - Introduction - 1
System level Modes (Logical Structure) warmup online startup Self Check Pass Failure Warm On Failure Off+ V<min + I>max shtdwn Self Check Fail offline I>0+V<min off Failure = H2+TooHot+TooCold CSE 466 – Fall 2000 - Introduction - 2
Mode Outputs Processes Events New Mode Off Load Disabled Power Supply Off Gas Valves Closed Power Button Enabled none Power Button Push Startup Startup Load Disabled Power Supply On Gas Valves Closed Initialize Temp Control H2 Detection Load Monitor UI Running Initialize Complete Warm Up Error Condition Detected* or shutdown request Shutdown Warmup Load Disabled Power Supply On Gas Valves Open Temp Control H2 Detection Load Monitor UI Running Operating Temp Reached Off Line Error Condition Detected* or shutdown request Shutdown Off Line Load Disabled Power Supply On Gas Valves Open Temp Control H2 Detection Load Monitor UI Running On-Line Command Received (UI) On Line Error Condition or Shutdown request Shutdown On Line Load Enabled Power Supply On Gas Valves Open Temp Control H2 Detection Load Monitor UI Running Off Line Command Off Line Overload Off Line Error Condition* or Shutdown Request Shutdown Shutdown Load Disabled Power Supply On Gas Valves Closed Fan On Temp Control Schedule transition to Off state Timeout Off State Table (activities/error conditions are mode dependent) CSE 466 – Fall 2000 - Introduction - 3
Examples of Mode Dependencies • Fan Speed Control: • In startup or shutdown mode always run minimum speed • otherwise attempt to maintain temperature set point • If fan doesn’t turn, issue shutdown event • Hydrogen Detection: always close hydrogen valves and issue shutdown event if hydrogen detected, except in startup mode. • Load Monitoring • If not online and output current > 0 or output voltage < min, then issue shutdown event. • If online and load current is > max allowed, or if output voltage is < min then turn on another stack. If all stacks are on, then issue overload event. • UI Process • If “line” button pushed and online issue offline event, If offline issue online event. • If “power” button pushed and not in off mode, then issue shutdown event. CSE 466 – Fall 2000 - Introduction - 4
Master Slave Architecture • Master/Slave Architecture • master process: determines what mode the system is in at any given time and synchronizes mode transitions. Process events and data. • Slave processes: Perform mode-dependent activities, pass data and events back to master. • Logical Decomposition Master (Mode) mode events Slave 4 (UI) Slave 1 (H2) Slave 2 (Load) Slave 3 (Temp) CSE 466 – Fall 2000 - Introduction - 5
Sockets are a “logical” constructs Socket could be implemented in shared memory, internet, or anything in between. High level architecture can be independent of implementation choices. Synthesis Problem: Map processes and sockets to processors and networks Warning: usually not done this way for embedded systems…usually designer performs the physical decompositions socket == 2-way fifo slave Master slave slave CSE 466 – Fall 2000 - Introduction - 6
Master/Slave Software Architecture Master void master() _task_ MAST{ m = doEvent(events); if (m != mode) enq(newModeCmd(mode = m)); checkDB(); // could be separate slave } void comTop() _task_ COM{ wait(K_TMO, 1); if (!deq(cmd)) { cmd = modeCmd(next++); slave = next; } else slave = toWho(cmd); write(slave, cmd); read(slave, response); signal(VERIFY); } // probably ISR/Timer void comBot() _task_ VERIFY{ // match up resp. and commds wait(K_SIG); verify(response); addEvent(events,response); updateDB(response); //data and/or events } commands and responses are packets not single bytes mode is NOT a global variable Slave void mainTask() _task_ SL{ manageLoad(mode); } // can queue up events void comTop() _task_ TOP{ read(master,mssg); if (!deq(resp)) event = mkEvent(db,i++); write (master,event); //prev signal(DO); }// could be ISR void comBot() _task_ DO { wait(K_SIG); do(mssg); } MODE COMMANDS EVENTS and DATA responses are for previous command CSE 466 – Fall 2000 - Introduction - 7
Master/Slave Software Architecture Master void master() _task_ MAST{ m = doEvent(events); if (m != mode) enq(newModeCmd(mode = m)); checkDB(); // could be separate slave } void comTop() _task_ COM{ wait(K_TMO, 1); if (!deq(cmd)) { cmd = modeCmd(next++); slave = next; } else slave = toWho(cmd); write(slave, cmd); read(slave, response); signal(VERIFY); } // probably ISR/Timer void comBot() _task_ VERIFY{ // match up resp. and commds wait(K_SIG); verify(response); addEvent(events,response); updateDB(response); //data and/or events } commands and responses are packets not single bytes mode is NOT a global variable Slave void mainTask() _task_ SL{ manageLoad(mode); } // can queue up events void comTop() _task_ TOP{ read(master,cmd); if (!deq(event)) event = mkEvent(db,i++); write (master,event); //prev signal(DO); }// could be ISR void comBot() _task_ DO { wait(K_SIG); do(cmd); } POLL, OFF, POLL, POLL I=10,V=15, M=ON, I=0 responses are for previous command CSE 466 – Fall 2000 - Introduction - 8
Distributed State Synchronization Is there a problem here? manageLoad(mode) { db[V] = readV(); db[I] = readI(); adjustStack(I,V); if (mode == OFFLINE && db[I]>0) enq(mkEvent(SHTDWN); … } do(m) { if (m != mode); if (m==OFFLINE) { out = 0; db[M] = offline; } if (m==ON) out = 1; db[M] = online; } mode = m; } Master doEvents() {… if (mode == ONLINE && event->type == BUTTON) { enq(mkCmd(OFFLINE)); mode = OFFLINE; } else … } checkDB() { … } POLL, OFF, POLL, POLL I=10,V=15, M=ON, I=0 CSE 466 – Fall 2000 - Introduction - 9
Distributed Data Is there a problem here? manageLoad(mode) { db[V] = readV(); db[I] = readI(); adjustStack(I,V); if (mode == OFFLINE && db[I]>0) enq(mkEvent(SHTDWN); … } do(m) { if (m != mode); if (m==OFFLINE) { out = 0; db[M] = offline; db[V] = INVLD; db[I] = INVLD; } … mode = m; } Master doEvents() {… if (mode == ONLINE && event->type == BUTTON) { enq(mkCmd(OFFLINE)); mode = OFFLINE; } else … } checkDB() { if (db[I] > maxI(db[T ]) shutdown(); } POLL, OFF, POLL, POLL I=10,V=15, M=ON, I=0 switching time is another factor not consider here db[I] and db[T] come from different slaves. CSE 466 – Fall 2000 - Introduction - 10
Synchronous Systems online offline offline warmup propagation time need to identify mode transition periods, and identify data that is out of synch as a result of transition. Need also to know when it is valid again. CSE 466 – Fall 2000 - Introduction - 11
Managing Distributed Transitions manageLoad() { db[V] = readV(); db[I] = readI(); adjustStack(I,V); … } do(m) { if (m != mode); if (m==OFFLINE) { out = 0; db[M] = offline; db[V] = INVLD; db[I] = INVLD; } … mode = m; } Master doEvents() {… if (mode == ONLINE && event->type == BUTTON) { enq(mkCmd(OFFLINE)); mode = OFFLINE; } else … } checkDB() { if (db[I] > maxI(db[T ]) shutdown(); } enq(cmd) { if (cmd=OFF) { db[I] = INVLD; db[V] = INVLD; db[M] = INVLD; q.data[q.head] = cmd; next(q); } updateDB(response) { ignore slave responses until correct mode is received from slave } db’s are not global either! POLL,POLL,POLL,POLL, OFF, POLL, POLL I=10,V=15, M=ON, I=5, V=20, M=OF, I=0 ignored, transition period CSE 466 – Fall 2000 - Introduction - 12
Multiprocessor Implementation Bus Two main types of serial buses: master-slave (SPI,USB) and multi-master (I2C, CAN) RS-232 is point to point…but can be used as a master-slave bus. CSE 466 – Fall 2000 - Introduction - 13