[Home]Timeline Automata

HomePage | RecentChanges | Preferences

Timeline Automata

Microcontrollers have timers, and a timeslice routing can be called each tick.

A way of doing an Automata is to use a countdown timer.

Musical boxes often use a rotating disk and pins pluck a note.

A clock that strikes the hour have a mechanism that is triggered and counts out the dongs.

Countdown Timer

Each value of Timer

 timer1 is a variable.

 each timer tick decrement it down to zero

 onTimerTick(){

   if ( timer1 > 0 ){
     timer1 += -1

   }
   if ( timer1 == 10 ){ routine0() }   
   if ( timer1 == 5 ){  routine2() }   
   if ( timer1 == 1 ){  routine2)_ }   
 }

Each timertick execute a line of code.

Constant Tick Numerical Controlled Oscillator Timer

For each tick decrement by K, and increment by decimal value

List of routines

Execute the next routing in the list.

Pointer to next routine

Each timertick, jump through a pointer to the handler . The Handler leaves the pointer at the next routine.

  onTimerTick()
    switch ( timer0 ){
      10: routine();
          break; 
      30: routine();
          break;
      35: routine();
          break;
    }     

  }

Linked List Timer

Each timer tick a routine is run and a pointer is set to the routine called next tick.

State and substate

The state is coded 1 << state | count

Shift register button Press edge detector

Use a shift register in a slow timer tick to detect edges.

    // shift register edge detector for HALT button.
    lastHALT = ( lastHALT + lastHALT + digitalRead( HALT ) ) & 3 ;

      // edge ---___ reset waitingPauseSet
      // edge ___--- store waitingPauseSet
      // ____ increment.  
    switch (  lastHALT ) {
      case 0: {  waitingPauseSet ++ ; break; };
      case 1: {
        Serial1.print( " waitingPauseSet: " );  
        Serial1.print( waitingPauseSet ); break; 
      };
      case 2: {  waitingPauseSet = 0; break; };

      default:{  }
    }  


HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 26, 2023 9:47 pm by dougrice.plus.com
Search:
home page