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.

A/D operation in Sleep Mode for PIC16F877A

Status
Not open for further replies.

michy2007ph

New Member
Hi,

I was wondering if someone can help me how to operate the A/D module for 16F877A in sleep mode.

I'm building a small project that tracks the sun and then when the Sun is out the MCU will go into SLEEP mode then when the Sun is up again the following morning, the MCU will initial a wake-up.

My first plan is to have an external circiut connected to the INT pin of the PIC, this will wake up the MCU once light is available (a simple comparator might be use using LDR as the sensor).

Please advise.

Thanks,
Mike
 
I assume that you are wanting to save power. If you have motors that drive mirrors, the motors will use thousands of times as much power as the PIC so shutting them off, which only needs code and doesn't need sleep mode will save you most of your power.

Using a PIC16LF877A, with a low supply voltage, will also save a good fraction of the power used. Running the processor at a slow clock speed cuts the power right down.

If you are going to use the A/D converter, it will run in sleep mode.

However, there is very little point in actually sending the processor to sleep while doing an A/D conversion. The conversion takes about 40 µs and you have a similar acquisition time before that.

A good way to save power is to set a timer, running on a 32.768 kHz watch crystal. Send the processor to sleep until the timer times out. Then turn on the A/D converter, do the conversion, and if it is still dark, go back to sleep. You can connect a watch crystal to timer1 on a PIC16LF877A, and use that to wake up the processor. The RC oscillator is best for the processor in an application like that, because it starts up quickly.

You are only looking for changes in daylight, so you could set the timer for several minutes. You would do that on a PIC16LF877A by only taking an A/D reading after being woken up a number of times.

If you are really keen to save processor power, other processors allow you to change the clock speed as well as going to sleep.

Alternatively, feed the PIC from solar cells. It will just stop at night, and restart in the morning. You loose any data in the registers but the program is safe, as is what is in EEPROM.
 
Hi Diver300,

That was really helpful, anyways the project will be used in a Solar Panels. Most of the Solar Panel Sun tracker right now are too expensive so, I decided to create one for me.

The Project uses Stepper motors (2 pcs for X & Y movements) and LDRs are the sensors of light. Another feature that I would like to include in the project is to position the solar panels in 180 deg position during night time to lessen wind loading to the panels. So, powering the PIC with the solar is not applicable (But that was a great idea).

The timer might be the great choice for now. I might just set the timer first and see what happens.


Thanks,
 
Last edited:
The 877a has a pair of comparators built in. Then can generate an interrupt not sure if it's a wake from sleep but probably is. If not just connect the comparator output to an INT pin.
 
Hi Bill,

Thanks, but is it possible if the PIC is used as A/D in normal operation & then comparator operation during Sleep Mode?

Mike
 
Last edited:
As Diver300 said, do you need to use sleep mode anyway?, the consumption of the PIC is tiny anyway, and running it at a low clock speed will make it even smaller - it's completely insignificant compared to the power required to move your motor.
 
Ok, Thanks. I'll keep that in mind.

Anyways I think I will use Solar Cell to power the PIC and then design the Solar Panels to go 180 deg (balance) once no power is connected to the Stepper Motors and the PIC.
 
hi ,
can anyone please tell me on what i need to do or to configure before using the pwm for PIC16F877A. I'm using ccs c compiler.
 
Hi, I am doing something like this as well. But, I am on an early phase. I need to use the A/D module in the PIC16F877A. As I am still new in doing this, can you show me the source code for using this module to convert the analog signal so that I can get a clearer picture on it.
Thanks.
 
Hi, I am doing something like this as well. But, I am on an early phase. I need to use the A/D module in the PIC16F877A. As I am still new in doing this, can you show me the source code for using this module to convert the analog signal so that I can get a clearer picture on it.
Thanks.

Read my tutorial which shows how to use it.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top