Shop OBEX P1 Docs P2 Docs Learn Events
How to use the napping-function — Parallax Forums

How to use the napping-function

ChristianGChristianG Posts: 29
edited 2004-10-21 08:03 in General Discussion
My board is using batteries, and I need to save power during period of inactivity.
The specifications says that the javelin is using up to 180 mA, but in nap mode its reduced to 13 mA, it says nap mode should be used to save power.
·
What is the correct code for using CPU.nap for example 1 minute?
for (int n =0; n < 30; n++) {
· CPU.nap(7); // nap 2 secs
}
Is it the correct way to do it?
·
My second question is about nap and virtual peripherals. The javelin manual (version 1.0) says that we must remove all VPs before using the nap function. I’ have tried not to removed them, and it seems to work fine.· VP’s seems to stop and start again, for example it seems that a Timer will stop during CPU.nap(7), and start again after nap (of course·it's not possible to measure the elapsed time with Timer during napping).·
Should I remove VP’s before using the nap-function or not? If not, should take some precautions with my VP’s before napping? I’m using Timer, Uart, and ADC.

Regards

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-10-18 08:26
    That is the correct way.

    VP's must be stopped before, and restarted

    after the nap, because otherwise some variables

    used by the VP's will be in an invalid state, because

    these are not updated during nap.

    This may, or may not, give problems.

    For receive uarts, read all bytes from the buffer

    before nap, for transmit uarts make sure the buffer

    is empty before nap.

    regards peter.
  • ChristianGChristianG Posts: 29
    edited 2004-10-21 06:49
    It seems that my javelin is still using much power, even if using the nap function. It's still far from 13mA as mentionned in the manual.
    Are there any other options for saving power? Will it help writing all the pins down (CPU.writePin(pin, false)?

    Regards, Christian
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-10-21 06:59
    Christian,

    Are you powering external circuitry from the

    Javelin VDD pin?

    regards peter
  • ChristianGChristianG Posts: 29
    edited 2004-10-21 07:15
    Yes I am. I have a vindsensor connected to vdd.
    And a modem connected through rs232.

    Christian
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2004-10-21 08:03
    The nap function does not shutdown the VDD pin.

    So if your external circuitry draws say 80 mA,

    and the Javelin draws 13 mA during nap, you always

    draw a minimum of 93 mA. To really save power

    you should turn off this external circuitry. Perhaps

    power this circuitry through a transistor that you

    can switch with a javelin I/O pin.

    (PNP transistor, collector to VDD pin, emitter to

    power external circuitry, base (via 1k resistor)

    to Javelin I/O pin. Making this pin low output

    then turns on the external circuitry.



    regards peter
Sign In or Register to comment.