Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Lowest Power Consumption Strategy

Status
Not open for further replies.

PICMICRO

New Member
I am going to make a small device using PIC16f676. The device needs to produce little beeps every 15 minutes. The Beep Should Sound Like ~~~Beep~~~Beep~~~~.

I don't need any accurate 15 minutes, inaccuracy as large as +- 50% is O.K. So, this enables us to use sleep modes and watch-dog timer.

The purpose is to remind you for reality checking so as to induce lucid dreaming.
https://en.wikipedia.org/wiki/Lucid_dreaming

I am trying to find out best power saving Configuration (WDT prescale, which oscillator to use) and also the best (shortest?) code.

Until I come-up with something and ask you if its good, you may also like to suggest something.
 
I would suggest using a low power 32kHz xtal and keep it running.

This will still be very low power, and low enough since the device will still be turned on/off etc by the user (ie does not need to run 24 hours a day).

The benefit of the xtal is that you CAN use accurate timed intervals as once it is in use you may want to experiment with adjusting the time intervals or adding some type of carefully controlled random factor etc, so there are benefits to be explored with a running PIC and xtal accuracy.
 
Sorry for not mentioning earlier that I want it to run 24/7. I will keep it near my ear during sleep, so that its sound can probably enter into the dream and remind me for reality checking! And again please don't go for timing accuracy (I really don't need it, I think) but for Low Power Consumption.
 
Sorry for not mentioning earlier that I want it to run 24/7. I will keep it near my ear during sleep, so that its sound can probably enter into the dream and remind me for reality checking! And again please don't go for timing accuracy (I really don't need it, I think) but for Low Power Consumption.

Use sleep and the WDT then, plus a very low clock speed.
 
I'd just use the watchdog timer with the lowest power/frequency internal clock mode and maximum prescaler setting possible. The WDT interrupt routine can bump a counter and put the uC to sleep. On counter overflow the beep is sounded then the uC goes to sleep again.
 
From power consumption point of view, I think I have learned this
1. If you need to perform certain steps of works (like execute 15 instructions) then the Highest Clock Speed should be chosen
2. If you anyway need to spend certain amount of time, then of course lowest clock speed should be chosen.

I think I will have the case #1 of above so should go for max possible clock speed.

This is my plan for the code.

Code:
while(1){
Sleep (1.3 second (max possible))
increase counters;
    check if 15 minutes elapsed,
    if (yes){
      // Beep~~~Beep Sound Generation Code
      Start Beep sound (i.e set pin1 high)
      sleep (0.5 second) (Pin 1 still high, sound producing)
      stop the sound (i.e. set pin2 low)
      sleep (0.2) second
      Start Beep sound again (i.e set pin1 hight)
      sleep (0.5 second)
      stop the sound (i.e. set pin2 low)
      sleep (0.2) second
      // this completes the Beep~~~Beep
      Reset 15 minutes counter
     }
}

I think the variable sleep times is achievable by changing the prescale assigned to WDT.
I will attach a simple buzzer onto pin 1.
 
Sorry guys, the above post by Kumaradhikari is by mine. Not that I have multiple account, but that my Laptop has multiple users and that I wasn't careful when making the post to check who is actually loged in.
Really Sorry.
 
Last edited:
O.K. I have done the code. Simulated it, it works fine. Now its time to assemble the hardware. But before that, I need to find a nice sounding buzzer that can work on 2-volts. Perhaps, I will salvage it from old alarm clocks. Suggestions still welcome. :)

Code:
#include<htc.h>
__CONFIG(WDTEN & INTOSCIO & UNPROTECT);
#define buzzer RC4
#define buzzer_tris TRISC4
void main(){
	OPTION = 0b00001111;
	unsigned char counter = 0;
	buzzer_tris = 0; // output
	while(1){
		OPTION = 0b00001111; // prescale assigned to  watchdog timer 
							// prescale 1:128 2.3 seconds
		SLEEP();
		counter++;
		if(counter==255){ // happens to be around 9.5 minutes, fine
			buzzer = 1;  // sound on
			OPTION = 0b00001011; // adjust WDT prescale for 144 ms
			SLEEP(); // wait (sound still on)
			buzzer = 0; //sound off
			OPTION = 0b00001010; // WDT prescale for 72 ms
			SLEEP(); // wait (sound still off)
			buzzer = 1; // sound on again
			OPTION = 0b00001011; // WDT prescale for 144 ms
			SLEEP(); // wait
			buzzer = 0; // sound finally off Beep~~Beep complete
		} 
		
	}
}
 
Last edited:
While hunting for Small Buzzer, I came across this
**broken link removed**

Its vibration motor of cellphone. Even better. I tried increasing voltage from 0 up and it started to rotate at round 1.1 Volts.
 
:eek: You were talking about power consumption?
I am still concerned with power consumption. What made you think, I am out of it? I think Vibrator motor is better option (from power consumption point of view) than buzzer, because it will eliminate the necessity of using very large buzzer in noisy environment.
I also tried to optimize the code for power consumption.
And, I am posting all these, just for sharing, and for listening to any suggestion you may feel like making.
Cheers.
 
Last edited:
That vibration motor won't give the 'beep beep' sound.you were after. And it will gobble a lot of power!
 
That vibration motor won't give the 'beep beep' sound.you were after. And it will gobble a lot of power!

Of course I know it won't give that sound. And my aim wasn't to get that sound, but instead, the aim was to get notified. Can you make an estimate of how large the buzzer should be for me to hear it in busy traffic?
So, I thought, vibrator would be better.
I checked and found that the The vibrator consumes 31.5 mA of current.
It runs for about 1 second every 10 minutes; which equates to 52.5 uA continiously. The PIC in Sleep Mode Consumes 7 uA.
So, in total its about 60 uA, continious.
How bad is that? seriously, I don't know.
I am using 3V.
 
Last edited:
I think (I could well be wrong) even a powerful piezo buzzer would have a lower power consumption than the vibrator, but with an average 52uA draw the vibrator should give a decent battery life so I agree, it wouldn't be worth buying and using a buzzer.
 
I found that the vibrator motor (in fact any motor I think) have this property
1. It needs higher Current (and hence higher voltage across it) to start
2. It can continue to rotate once started with like, half the current.
So, I designed two step motor control. Like this
**broken link removed**
And I am using this code,
Code:
#include<htc.h>
__CONFIG(WDTEN & INTOSCIO & UNPROTECT & BORDIS);
#define motor RC4  // running Transistor Base
#define motor_tris TRISC4
#define motorH RC3 // Kick-Start Transistor Base
#define motorH_tris TRISC3
void main(){
	OPTION = 0b00001111;
	
	CMCON = 0xFF;
	ANSEL = 0x00;
	TRISA = 0x00;
	TRISC = 0x00;
	PORTA = 0x00;
	PORTC = 0x00;
	unsigned char counter = 0;
	motor_tris = 0; // output
	motorH_tris = 0;
	
	while(1){
		OPTION = 0b00001111; // maximum watchdog timer 
                             // prescale 1:128 2.3 seconds
		SLEEP();
		counter++;
		if(counter==5){ // happens to be around 11.5 seconds (for test purpose)
						// finally counter==255 which would occur ever 9.8min
			counter = 0;

			OPTION = 0b00001000; // adjust WDT prescale for 18 ms
			motorH = 1; // kick start
			SLEEP();
		    motor = 1;  // Sart Running
			motorH = 0; // stop Kick
			OPTION = 0b00001101; // adjust WDT prescale for 575 ms
			SLEEP(); // wait (sound still on)

			motor = 0; //Stop Running
			OPTION = 0b00001100; // adjust WDT prescale for 72 ms
			SLEEP(); // wait (sound still off)


			OPTION = 0b00001000; // adjust WDT prescale for 18 ms
			motorH = 1; // kick start again
			SLEEP(); //
			motor = 1; // start running
			motorH = 0; // stop kick
			OPTION = 0b00001101; // adjust WDT prescale for 575 ms
			SLEEP(); // wait
			motor = 0; // Bruuum~~Bruuum complete :)
		} 
		
	}
}
I checked the power consumption of the PIC in sleep mode again, disconnecting all peripherals. (And, connecting MCLR to VDD through 400K). It was 4.5 uA.
From the datasheet, the maximum current that WDT can consume at 3V is only 3.5uA.
Is this normal or am I missing something.
Not, that its critical (I am going to use up most of the battery on Vibrator anyway), but just for the sake of knowledge.

Last of all, Is it fine for me to keep posting like this here (with no specific question), but I like to do this for the sake of sharing and documentation. If you don't like, just mention, and I will stop.

Thanks.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top