Page 1 of 1

PICF1938 - Sleep

Posted: Mon Apr 01, 2019 5:24 pm
by JLeith
Hello All

My Baseball Pitch count program is work wonderful. I would like to try to put the processor to sleep to conserve battery power

PIC16F138 - 28 pin

There is about 5 to 8 min between innings and if I can put the PIC and LCD to sleep I think I could save battery power.

My thoughts;
Press Digit 2 on the key pad ---- PIC goes to sleep and the LCD turns off --- Save battery
Press Digit 5 on the key pad ---- PIC wakes up and the LCD displays the values on the screen before it wen to sleep

Is this possible

Here a drawing


Re: PICF1938 - Sleep

Posted: Mon Apr 01, 2019 5:31 pm
by Benj
Hi John,

Pressing 2 to put the micro to sleep should be fine.

The problem may come when you try and wake up again. The keypad is actively scanned so you could do one of the following.

Use a timer interrupt to wake up periodically to scan the keypad for wake presses. Waking up periodically will lower your power saving but hopefully not by much.

Use a different wake mechanism, e.g. a switch connected to an interrupt pin or the MCLR reset pin.

Re: PICF1938 - Sleep

Posted: Mon Apr 01, 2019 6:12 pm
by JLeith
Thank you Benj

Do you expect I can save battery power ?

I think the Press 2 to sleep and then use a timer to check if digit 5 was pressed.

I have attached my Design Flowcode.

oops I have a design flaw when I press 2 My program resets the LCD.
No trouble with (5) Maybe I can use (5) to sleep and (5) to wake up

Benj if you can help me with the steps to Sleep on Digit (5) and how I can use (5) to wake up.

Would I use a Macro to have a wake up routing so I don't have to run the LCD. I could do a check in a Macro maybe ( Sleep )
I have attached a sketch


Re: PICF1938 - Sleep

Posted: Mon Apr 01, 2019 6:27 pm
by JLeith
Did some measurements

On startup
"Press 5 to start game" ( 63.7 ma )
Enter values ( Division) ( 2 or 8 )
Reset the Remote displays
Down to 42.3 ma
Press Digit 1 to advance pitch count --- (
About every 2 min a pitch is taken. --- (45ma)

Sitting for 8 min with no input ( Would that be 43ma for 8 min = 344 ma battery drain )


Re: PICF1938 - Sleep

Posted: Mon Apr 01, 2019 6:56 pm
by JLeith
More info

On my working Pitch count battery
9v rechargeable ( EBL Battery Model 6F22 )

I get 28.43 ma on startup and waiting for a pitch

On the transmission to the receiver for 300ms takes 35ma and the back to 28ma

By the math I can find 280ma at say 29ma = 280 / 29 = 9.6 hrs.

Odd I get about 2 to 3 hrs. Odd

Is there a way to test if the battery is able to have 280ma/HR


Re: PICF1938 - Sleep

Posted: Tue Apr 02, 2019 1:15 pm
by Benj
Hi John,

Can you turn off the display at the moment? Do you have a FET or transistor etc connected to allow you to control the display VCC? This would be required to drop the power draw of the display during sleep.

The C code to sleep the device looks like this.

Code: Select all

If you start a timer interrupt going just before you sleep then the device will auto wake when the interrupt fires. Maybe disable the interrupt again after you have woke up and want to continue. If you dopn't want to continue then go back to sleep from within the interrupt macro.

Your power usage does maybe seem a bit high. How efficient is your regulator? Could you use a DC2DC switch mode regulator rather than a standard low drop out linear regulator. This will certainly save you a bit of power usage.

Re: PICF1938 - Sleep

Posted: Tue Apr 02, 2019 3:22 pm
by JLeith
Hello Benj

Thank you;
Yes I don't know why I can't get more time. I did order a 500mahr 9v battery to maybe help.

For my design I have 2 ( LM2596 ) DC-DC. ( From Sparkfun )
1. For 9V to 5V for VCC
2, 5V to 3V for the TX (NFR905)
Could you use a DC2DC switch mode regulator
Not sure what the DC2DC Switch is ?
If I drop the VCC then I would lose the Values for the Variables would I not.

I will look at the VCC for the LCD and see how I could disconnect and bring back.

I will update when I have a plan