Bypass timer on reset?

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Jan 9, 2011.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    I developed a solar light controller / timer. What happens is the PIC monitors the voltage from the solar panel. When the panel voltage drops below a certain amount a timer is started. The light comes on when the timer expires.

    The reason for this is on our previous purchased controller, it turned the light on when the voltage dropped to zero. The problem was there was still plenty plenty of ambient light, just not enough for the panel. Hence the reason for the timer.

    I just realized that I have a small bug in my software. Should the power fail at night (disconnected battery), the timer will start again from zero. Not a big problem really but it would be nice to avoid it.

    One thought I had would be to store the fact that the light is already on in eprom. If the PIC comes up again and it is dark and the eprom value is true then the timer does not start and the light comes on right away.

    Any other ideas on how to solve this?
  2. Markd77

    Senior Member

    Sep 7, 2009
    For the simple case you could just put in some code at the start that checks your voltage and if it's below the level, turn on. It would only get to this code when first turned on or reset.
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009

    That is a good idea. I think it would work. I already turn it off first thing. I could turn it off or on based on the input voltage.
  4. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    There are bits to determine what caused the reset in all PICs