Embedded software Assessment 2

Dependencies:   MCP23017 SDFileSystem USBDevice WattBob_TextLCD mbed

Revision:
21:0e681d5fa3ba
Parent:
20:00a9a95ef083
Child:
22:644d53f1f291
diff -r 00a9a95ef083 -r 0e681d5fa3ba main.cpp
--- a/main.cpp	Tue Mar 04 18:42:38 2014 +0000
+++ b/main.cpp	Tue Mar 04 21:49:29 2014 +0000
@@ -1,12 +1,21 @@
 /*                                        Cyclic Executive
-This software is built to test (Cyclic Executive). Five main functions are used in and every one of them
-has its own time of repetition. To execute this, a Ticker was used to call a function every 12.5 mSec.
-In this software a benefit is a token from two counter, one is counting a pulses and it reset every 8 cycles.
-That mean it reset every 100 mSec. Then other counter (AllTimeCounter) increased by one. Every slot in the 8 slots
-has a defined function, for example the slot number 1 is to reading the two digital input. however this slote is
-for this function it is not excuted every slot 1. It excute just when the timer calculat 400 mSec. That is 4X8 
-cycles. Also, after 8X8 cycles (800 mSec) the condition is true for two factions, but the processor will 
-implement one in slot 1 and next cycle implement the other. 
+This software is built to test (Cyclic Executive). 6 main tasks are used in and every one of them
+has its own time of repetition. To execute this, a Ticker was used to call a function every 4 mSec.
+In this software a benefit is a token from two counter, one is counting a pulses and it reset every 25 cycles.
+That mean it reset every 100 mSec. Then other counter (AllTimeCounter that count a 100 mSec) increased by one.
+A slot is defined for each function, for example the slot number 1 is to reading the two digital input. however
+this slote is for this function it is not excuted every slot 1. It is excuted just when the timer calculat 400 mSec. 
+That is 100 cycles. Also, after 200 cycles (800 mSec) the condition is true for two factions, but the processor will 
+implement one in slot 1 and next cycle implement the other. Excuting the LCD and writing file got more slote space.
+The LCD show slot is 72 mSec and the writing is 8 mSec. At A Sec 180 all functions are called and the 1800 (100 mSec)
+will be like this:
+   __    __    __    __    __    __    __    __    __                      __  
+  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |                 |  |  
+  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |-----------------|  | 
+__|  |__|  |__|  |__|  |__|  |__|  |__|  |__|  |__|  |                 |__| 
+  < S1 > < S2> < S3> < S4> < S5> <    S6   > <            S7             > 
+     4     4     4      4     4        8                  72    mSec 
+   
         The full program ducimentation is on
         http://mbed.org/users/muaiyd/code/ass2/
 */
@@ -24,7 +33,7 @@
     Init_LCD();
     InitFile();
     LogTimer.start();
-    Cycle.attach(&CycleFunction,0.0125);      
+    Cycle.attach_us(&CycleFunction,4000);      
 }
 
 void CycleFunction(){
@@ -32,7 +41,7 @@
 /*
     We can see the period of execute time for  every function below on the pin that
     assigned for each and writen infront of it.    The least common multiple for all the above
-     repeat time function is 180 Sec so every 180 Sec all the cycle is repeated. That mean 14400
+     repeat time function is 180 Sec so every 180 Sec all the cycle is repeated. That mean 45000
      cycles.
 */
    
@@ -54,16 +63,16 @@
             if( AllTimeCounter % 18 == 0) InputCheck();   //Pin 25
         break;
         case 6:
-            if( AllTimeCounter % 20 == 0 ) Display();      //Pin 26
-        break;
-        case 7:
             if( AllTimeCounter % 50 == 0 ) LogFile();      //Pin 27
         break;
         case 8:
+            if( AllTimeCounter % 20 == 0 ) Display();      //Pin 26
+        break;
+        case 25:
             Counter = 0;
             AllTimeCounter ++ ;
             TickerPin = !(TickerPin);
         break;
     }
-    if ( AllTimeCounter == 14400 ) AllTimeCounter = 0; 
+    if ( AllTimeCounter == 1800 ) AllTimeCounter = 0; 
 }
\ No newline at end of file