Minimum start-up time

Hi:

I am planning to design a infrared controller. Each time that a button is pushed the Arduino will be powered on and an input will be send to it.

Therefore, I need to know how much time the microprocessor needs to be ready to process inputs (to execute a program).

I will use an Arduino nano or an Attiny85.

Thanks in advance.

The biggest delay is from a bootloader.

Assuming the processor does not have a bootloader ... The processor will be ready for business before your brain has time to send a signal to your hand to release the button.

The latest optiboot is very efficient at getting the application started. I suspect, even with it installed, the processor will be ready for business long before you are.

But, it is fairly easy to test. Essentially, you would be building a JEOPARDY! button. You versus the processor. :smiley:

IMO, Starting the MCU every time is a poor idea.
The amount of time required for startup depends on the startup fuses programmed.
The lowest setting is no delay so all there is - is 1-2ms of overhead. This setting is not recommended because it gives it very little time to stabilize.
The next setting is 4 ms + 1-2ms overhead. It takes about 5-6 ms to startup.
The longest setting is 64ms + 1-2ms overhead. Total startup 65-66ms. This is usually the default.

Fuse calculator is here: AVR® Fuse Calculator – The Engbedded Blog

OK, thanks both, so no problem with delay.

smeezekitty:
IMO, Starting the MCU every time is a poor idea.

I thought this is the way what a remote control works...

Normally you would run it in IDLE mode which reduces the power consumption to a very tiny amount but it is waken by an interrupt (which can be a pin change).

Even better is to use any key press to create an interrupt to wake the processor from power down sleep mode, it reads the keypad, sends the button, goes back to sleep.

Can use a 8MHz promini running off 3.7V Lipo battery, or wire up a bare minimum board to do the same.
Add your IR transmitter where I have the RF transmitter.

what its the purpose of the diods :smiley: ?

putyn:
what its the purpose of the diods :smiley: ?

I assume to use one interrupt line without short circuiting the buttons together :slight_smile:

Yes. Any button in a row pulls that cathode low to create the interrupt.

Tricky part was discovering that the keypad library left the columns pin High when sleep was entered, I had to drive them low when sleep was entered, then back high to read the keypress after the interrupt:

void loop()
{
  if (sleep_count>1000){                      // check if we should go to sleep because of "time" --> Try shorter versions of this
    sleep_count=0;                           // turn it off for when we wake up
//    Serial.println("Sleep");               // for debug only
                                             // set the columns low before sleeping, otherwise Keypad leaves them high and Rows have nothing to pull low.
    digitalWrite(7, LOW);
    digitalWrite(8, LOW); 
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);   
    delay(100);                               // need this?
    enterSleep();                             // call Sleep function to put us out
    
                                              //  THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep()
  }                                           // end of checking to go to sleep
//***************************************************
// *  Name:        enterSleep
void enterSleep()
{
  /* Setup pin2 as an interrupt and attach handler. */
  attachInterrupt(0, pin2Interrupt, LOW);
  delay(50); // need this?
  /* the sleep modes
   SLEEP_MODE_IDLE - the least power savings
   SLEEP_MODE_ADC
   SLEEP_MODE_PWR_SAVE
   SLEEP_MODE_STANDBY
   SLEEP_MODE_PWR_DOWN - the most power savings
   */
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);  // setting up for sleep ...
  sleep_enable();                       // setting up for sleep ...

    // Disable ADC
  ADCSRA &= ~(1 << ADEN);

  // Power down functions
  PRR = 0xFF;

  sleep_mode();                         // now goes to Sleep and waits for the interrupt

  /* The program will continue from here after the interrupt. */
  detachInterrupt(0);                 //disable interrupts while we get ready to read the keypad 
  
    // Power up functions
  PRR = 0x00;

/* First thing to do is disable sleep. */
  sleep_disable(); 

  // set all the keypad columns back high so can read keypad presses again
  digitalWrite(7, HIGH);
  digitalWrite(8, HIGH); 
  digitalWrite(9, HIGH);
  digitalWrite(10, HIGH); 
  // then go to the void Loop()
}