Searching \ for '[PIC] Capturing pulses in sleep mode' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Capturing pulses in sleep mode'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Capturing pulses in sleep mode'
2006\10\05@073059 by David

flavicon
face
I need to set up a micro to measure Pulses from a voltage-free contact.

The rate is not too fast (5 per second). Each 1 minute interval I want
to send the accumulated pulse
count our the serial port and clear the count to start measuring again.

I was thinking of using the PIC18LF1220 running with internal RC_OSC at
1 MHz. At 3.3V the micro should
draw around 330uA max. according to the datasheet. I need the average
continuous current to be around 1/2 this figure
(target is 140uA or less)

Can I put the micro in Sleep or idle mode and use say TOCK0 input to
accumulate pulses.
Then use the watchdog time to wake the micro up to determine if it is
time to send the accumulated
pulses else go back to sleep ?

Or, should I use an Interrupt pin and wake the micro up on each
transition and increment the accumulated count until
time to send ?

Or, is there a better way to do this ?


Thanks in advance.

Regards

David

2006\10\05@080619 by Alan B. Pearce

face picon face
>Can I put the micro in Sleep or idle mode and use say TOCK0
>input to accumulate pulses. Then use the watchdog time to
>wake the micro up to determine if it is time to send the
>accumulated pulses else go back to sleep ?

No the peripherals do not keep working while the CPU is asleep.

>Or, should I use an Interrupt pin and wake the micro up on
>each transition and increment the accumulated count until
>time to send ?

This is what would happen if you tried to use TOCK0 as the input, but if
just using the counter I suspect you would miss counts.

>Or, is there a better way to do this ?

I think you are on the right track, although I would have looked at one of
the nanowatt 16F devices myself. If you are already using the 18F series,
then stick with it.

2006\10\05@081910 by David

flavicon
face
Alan,

Thanks for the feedback.

I would prefer to stick with the PIC18F as I have the development tools
for them.

Most of my projects have used the PIC18F252 and PIC18F6720 but I don't
need as many pins and the current consumption
of the PIC18F1220 looks better.

I think the approach will be to use the interrupt as the pulse will be
there for at least 10ms and this gives me plenty of time
to wake up and increment a count.

Regards

David

2006\10\05@085441 by Jinx

face picon face
> No the peripherals do not keep working while the CPU
> is asleep

I'm not so sure about that. Timer0 rollover interrupt doesn't
work but I think T0CKI still increments (I've not tried it)

> I was thinking of using the PIC18LF1220 running with internal
> RC_OSC at 1 MHz

You might try measuring active current at different frequencies.
A slow clock will keep the PIC awake longer and although a
faster clock may use a little more power, the wake period will
be shorter

2006\10\05@093314 by Jinx

face picon face
> No the peripherals do not keep working while the
> CPU is asleep

In the block diagram of TMR0, the T0CKI signal goes
through a gate with T0SE, then into the first MUX with
Fosc and T0CS. As Fosc is turned off by SLEEP
(therefore no T0IF when TMR0 is free-running), I wasn't
sure if that stops the MUXes from incrementing T0reg.
I now suspect it may, because Fosc is needed in the synch
block also. So what actually stops TMR0 is not that it's
shut down, it's that there's no Fosc to clock the hardware


2006\10\05@162754 by Mike Harrison

flavicon
face
On Thu, 5 Oct 2006 13:06:13 +0100, you wrote:

>>Can I put the micro in Sleep or idle mode and use say TOCK0
>>input to accumulate pulses. Then use the watchdog time to
>>wake the micro up to determine if it is time to send the
>>accumulated pulses else go back to sleep ?

You can do this with timer 1 in async. mode
If you realy wanted to do it with tmr0, you could use the prescaler as a counter.
Clear  tmr0 (which clears the prescaler), go to sleep.
Wake up, reassign the clock source to fosc, and wait to see how long it takes for TMR0 to change,
which tells you how many counts the prescaler saw.
A bit contrived but should be do-able if you have no other option.

In practice if you have a timer1 (few pics don't), you probably don't need it for anything else in
sleep (except maybe an RTC).

Remember also that if using the INTRC osc, wake up from sleep is very fast, so you could use an INT
or pin-change interrupt to count the pulses by waking up on each one.

2006\10\05@185031 by David

flavicon
face
Mike,

Thanks for your input also.

Timer 1 looked ok but on the PIC18LF1220 the Input for Timer 1 is on RB6
and RB7. I have already used
these pins for debugging and bootloader coms.

RB0 is used for communications when sending the reading each minute.
This really leaves INT1 (RB1).

I need the count to continue during the transfer process (Sending the
data via serial port and waiting for response).

Regards

David

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...