A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
Hi all, What is the preferred method of saving batteries ? I was thinking of sleep for 30 seconds, wake to check to see if the power is on a pin, re-sleep if no power, run if the switch is closed and there is 5v on that pin. Or, is there a better way to wake up the PIC when in sleep mode ? Dave |
|
|
|
Why don´t sleep at an interrupt? I say, every time occur an interrupt, automatically MCU wake from sleep mode. Regards, Wilson Antonieti Engenharia de Desenvolvimento Tel.: (11) 4223-5117 Fax.: (11) 4223-5103 Visite nosso site: www.contemp.com.br PRECISÃO AO SEU ALCANCE!!! ----- Original Message ----- From: "Dave Mucha" <> To: <> Sent: Tuesday, March 16, 2004 1:54 PM Subject: [piclist] wakeup ? > Hi all, > > What is the preferred method of saving batteries ? > > I was thinking of sleep for 30 seconds, wake to check to see if the > power is on a pin, re-sleep if no power, run if the switch is closed > and there is 5v on that pin. > > Or, is there a better way to wake up the PIC when in sleep mode ? > > Dave > > > to unsubscribe, go to http://www.yahoogroups.com and follow the instructions > Yahoo! Groups Links |
|
Like Wilson said you can use interrupts. I'm not sure if all PIC have it, but my experience with interrupts on the AVR is that the power-on interrupt can signal if it was a power-on or a reset. Refresh my memory...What are you trying to do? And how can you even do anything if there is no power at Vdd? Mike --- In , "Dave Mucha" <davemucha@j...> wrote: > Hi all, > > What is the preferred method of saving batteries ? > > I was thinking of sleep for 30 seconds, wake to check to see if the > power is on a pin, re-sleep if no power, run if the switch is closed > and there is 5v on that pin. > > Or, is there a better way to wake up the PIC when in sleep mode ? > > Dave |
|
|
|
--- In , "upand_at_them" <upand_at_them@y...> wrote: > Like Wilson said you can use interrupts. I'm not sure if all PIC > have it, but my experience with interrupts on the AVR is that the > power-on interrupt can signal if it was a power-on or a reset. > > Refresh my memory...What are you trying to do? And how can you even > do anything if there is no power at Vdd? > > Mike I guess I'm thinking ahead of myself…. Sorry for not being as clear as I could be. My brother runs a greenhouse and wanted me to make him a portable controller(s) that can be used for different plants, different types of plants and different watering routines. The variables are frequency of watering, duration of watering and monitor soil moisture and temperature. The idea is to make a half dozen units that would all have the same basic type of program, and then offer field settings of watering times and such. The board would have a real time clock and serial mammary chip and probably the 16F876 or similar. The sprinkler connection has 24VAC so it would be no problem adding a power supply on the board. I am hoping to be able to program the PIC and then store user setting in serial memory. The options are the 31k of scratchpad ram on the clock or a section of memory in the serial memory chip. The clock will have a button battery so there will be some battery on- board, but not enough to do much of anything but back up the clock. When one plugs the unit in to the power at the sprinkler, the PIC would wake up, look at the parameters stored in the memory and then use those as settings for how to operate in that location. Periodically, someone would go to the unit, connect a PALM, download the data of soil moisture and temperature, then take that back to the office and someone there would figure out what changes to make. Then someone would go back to the unit, again with a PALM, connect to the board and upload new operation settings of water frequency and duration. The original concept was using a 9v or some AA batteries, but that seemed like I would have to make the unit twice as large as 4 AA batteries are as large as the board I've started to lay out. I'm on the fence about batteries and not using batteries. I figure that if one of these would sit on the shelf for a season, 3 months or more, the batteries would be dead. That was the reason I want to understand more about sleep and wake-up conditions. If using batteries, sleep could be ended with the application of the external power, or I could routinely wake-up, check for an external setting then either go back to sleep, or run. I'm not familiar with interrupts that would wake up the PIC. Another question that I have not resolved (please change the subject line if you respond to this question) is one of writing to memory. 512k serial memory chips can be page written, but I do not have a page of memory to write unless I store data on a secondary chip and then write the whole lot. But, that means bunches of smaller writes to that secondary memory chip which means a shorter life for that. Please offer alternatives if I missed something. Also, I have not thought about storing data after a power failure, resuming from the last write. I don't mind losing a page of data or whatever, but if I'm storing 2 weeks data and lose power after a week for one hour, I want to retain the first week and just have a gap where there was no data stored. Hope the bigger picture makes more sense. Dave |
|
|
|
> The board would have a real time clock and serial mammary chip and > probably the 16F876 or similar. That's one mother of a chip ;-) |
|
|
|
--- In , "sergio masci" <smypl@x> wrote:
> > The board would have a real time clock and serial mammary chip and > > probably the 16F876 or similar. > > That's one mother of a chip ;-) yeah, I'm nursing this project along...... |
|
just a couple of thoughts . . . a) you really don't need an external clock, if you use a crystal you can make a PIC to clock functions that are within a minute-per-week b) why not just write the data to the PIC data eeprom, one write a minute would let the eeprom live for ninteen years or so. c) I would consider powering it off of the available 24vdc, and use a 9vdc battery for a backup if the 24 goes down. A couple of diodes does this nicely. Or maybe even put a lithium ion rechargeable in there and build a charging curcuit for it. d) Interrupts are not that hard to do. You can use the interrupt routine to do your clock functions, and to wake up the mu from sleep mode. Regards, John. --- Dave Mucha <> wrote: > --- In , "upand_at_them" <upand_at_them@y...> > wrote: > > Like Wilson said you can use interrupts. I'm not sure if all PIC > > have it, but my experience with interrupts on the AVR is that the > > power-on interrupt can signal if it was a power-on or a reset. > > > > Refresh my memory...What are you trying to do? And how can you > even > > do anything if there is no power at Vdd? > > > > Mike > > I guess I'm thinking ahead of myself…. Sorry for not being as clear > as I could be. > > My brother runs a greenhouse and wanted me to make him a portable > controller(s) that can be used for different plants, different types > of plants and different watering routines. > > The variables are frequency of watering, duration of watering and > monitor soil moisture and temperature. > > The idea is to make a half dozen units that would all have the same > basic type of program, and then offer field settings of watering > times and such. > > The board would have a real time clock and serial mammary chip and > probably the 16F876 or similar. > > The sprinkler connection has 24VAC so it would be no problem adding a > > power supply on the board. > > I am hoping to be able to program the PIC and then store user setting > > in serial memory. The options are the 31k of scratchpad ram on the > clock or a section of memory in the serial memory chip. > > The clock will have a button battery so there will be some battery > on- > board, but not enough to do much of anything but back up the clock. > > When one plugs the unit in to the power at the sprinkler, the PIC > would wake up, look at the parameters stored in the memory and then > use those as settings for how to operate in that location. > > Periodically, someone would go to the unit, connect a PALM, download > the data of soil moisture and temperature, then take that back to the > > office and someone there would figure out what changes to make. > > Then someone would go back to the unit, again with a PALM, connect to > > the board and upload new operation settings of water frequency and > duration. > > The original concept was using a 9v or some AA batteries, but that > seemed like I would have to make the unit twice as large as 4 AA > batteries are as large as the board I've started to lay out. > > I'm on the fence about batteries and not using batteries. I figure > that if one of these would sit on the shelf for a season, 3 months or > > more, the batteries would be dead. That was the reason I want to > understand more about sleep and wake-up conditions. > > If using batteries, sleep could be ended with the application of the > external power, or I could routinely wake-up, check for an external > setting then either go back to sleep, or run. I'm not familiar with > interrupts that would wake up the PIC. > > Another question that I have not resolved (please change the subject > line if you respond to this question) is one of writing to memory. > 512k serial memory chips can be page written, but I do not have a > page of memory to write unless I store data on a secondary chip and > then write the whole lot. But, that means bunches of smaller writes > to that secondary memory chip which means a shorter life for that. > Please offer alternatives if I missed something. > > Also, I have not thought about storing data after a power failure, > resuming from the last write. I don't mind losing a page of data > or whatever, but if I'm storing 2 weeks data and lose power after a > week for one hour, I want to retain the first week and just have a > gap where there was no data stored. > > Hope the bigger picture makes more sense. > > Dave __________________________________ ">http://mail.yahoo.com |
|
|
|
I would agree with most of these thoughts but I would have selected a different type of battery. I have just completed a project that includes a high performance battery pack. Lithium ion was my first choice until I studied them closely. Lithium suffers from a loss of capacity over time that is independant of the number of charges, so that after one year, it is reasonable to expect the battery to be as little as 60% of it's new capacity. The rate of decay is also linked closely to temperature. In a high temerature, the batteries can lose a huge amount of their capacity in a matter of weeks or months. In my case, the battery pack was likely to live inside a car for significant parts of its life and therefore was likely to suffer a reduced life as a result. Typical temperatures in a greehouse are likely to severely limit the lide of lithium ion batteries. Our choice was for NiMh which, although not the same energy density, appears to offer up to about 500 full charges (or the equivalent in partial charges). There is very little decay over time and they are comfortable in most temeratures. Bearing in mind that this application is unlikely to discharge the battery to any extent, I think that one can consider NiMh suitable for the life of the product - maybe not the 19 years the eprom offers, but certainly a good proportion of that time. The battery pack we used was a 3500mAH 8.4V unit (7 x 1.2V C size cells). This pack would drive a camcorder sized video recorder and screen for 8 hours. When the recorder and screen are turned off, the battery will operate the PIC and associated circuitry for 4 weeks without putting any device into sleep. I am sure that a PP3 NiMh battery will offer 24 - 48 hours life from fully charged and therefore is almost certainly sufficient to cope with intermittant power failures. Charging is a little problematic, but with a little care, the charging algorythms can operate within the remainder of the PIC programme. I can offer some suggestions for charging if you want to explore that route. Finally, John suggests avoiding the real time clock - I would agree, but remember that the PIC will accurately count elapsed time but is not so good at real time, so if an accurate time and date stamp is required, a separate clock might be the way to go. Personaly, I always look for ways to avoid using external clocks and employ various methods to record time such as timed loops that wait for user input or counting fixed length routines as well as using the internal timers and counters. Good luck in your project. It sounds interesting and I for one would like to hear of your progress as you develop it. Peter --- In , jrem <jrem123@y...> wrote: > just a couple of thoughts . . . > > a) you really don't need an external clock, if you use a crystal you > can make a PIC to clock functions that are within a minute-per-week > > b) why not just write the data to the PIC data eeprom, one write a > minute would let the eeprom live for ninteen years or so. > > c) I would consider powering it off of the available 24vdc, and use a > 9vdc battery for a backup if the 24 goes down. A couple of diodes does > this nicely. Or maybe even put a lithium ion rechargeable in there and > build a charging curcuit for it. > > d) Interrupts are not that hard to do. You can use the interrupt > routine to do your clock functions, and to wake up the mu from sleep > mode. > > Regards, John. > --- Dave Mucha <davemucha@j...> wrote: > > --- In , "upand_at_them" <upand_at_them@y...> > > wrote: > > > Like Wilson said you can use interrupts. I'm not sure if all PIC > > > have it, but my experience with interrupts on the AVR is that the > > > power-on interrupt can signal if it was a power-on or a reset. > > > > > > Refresh my memory...What are you trying to do? And how can you > > even > > > do anything if there is no power at Vdd? > > > > > > Mike > > > > > > > > > I guess I'm thinking ahead of myself…. Sorry for not being as clear > > as I could be. > > > > My brother runs a greenhouse and wanted me to make him a portable > > controller(s) that can be used for different plants, different types > > of plants and different watering routines. > > > > The variables are frequency of watering, duration of watering and > > monitor soil moisture and temperature. > > > > The idea is to make a half dozen units that would all have the same > > basic type of program, and then offer field settings of watering > > times and such. > > > > The board would have a real time clock and serial mammary chip and > > probably the 16F876 or similar. > > > > The sprinkler connection has 24VAC so it would be no problem adding a > > > > power supply on the board. > > > > I am hoping to be able to program the PIC and then store user setting > > > > in serial memory. The options are the 31k of scratchpad ram on the > > clock or a section of memory in the serial memory chip. > > > > The clock will have a button battery so there will be some battery > > on- > > board, but not enough to do much of anything but back up the clock. > > > > When one plugs the unit in to the power at the sprinkler, the PIC > > would wake up, look at the parameters stored in the memory and then > > use those as settings for how to operate in that location. > > > > Periodically, someone would go to the unit, connect a PALM, download > > the data of soil moisture and temperature, then take that back to the > > > > office and someone there would figure out what changes to make. > > > > Then someone would go back to the unit, again with a PALM, connect to > > > > the board and upload new operation settings of water frequency and > > duration. > > > > The original concept was using a 9v or some AA batteries, but that > > seemed like I would have to make the unit twice as large as 4 AA > > batteries are as large as the board I've started to lay out. > > > > I'm on the fence about batteries and not using batteries. I figure > > that if one of these would sit on the shelf for a season, 3 months or > > > > more, the batteries would be dead. That was the reason I want to > > understand more about sleep and wake-up conditions. > > > > If using batteries, sleep could be ended with the application of the > > external power, or I could routinely wake-up, check for an external > > setting then either go back to sleep, or run. I'm not familiar with > > interrupts that would wake up the PIC. > > > > Another question that I have not resolved (please change the subject > > line if you respond to this question) is one of writing to memory. > > 512k serial memory chips can be page written, but I do not have a > > page of memory to write unless I store data on a secondary chip and > > then write the whole lot. But, that means bunches of smaller writes > > to that secondary memory chip which means a shorter life for that. > > Please offer alternatives if I missed something. > > > > Also, I have not thought about storing data after a power failure, > > resuming from the last write. I don't mind losing a page of data > > or whatever, but if I'm storing 2 weeks data and lose power after a > > week for one hour, I want to retain the first week and just have a > > gap where there was no data stored. > > > > Hope the bigger picture makes more sense. > > > > Dave > > > > > > > > > > > > > > > > > > __________________________________ > ">http://mail.yahoo.com |
|
Sounds cool. Here's what I'm thinking. And correct me if I have your idea wrong... I'm thinking you probably don't need the RTC; you probably don't need to know what temperature and soil conditions at a specific date and time as much as you want to see trends over reasonably accurate periods. If that's so, then I would use the watchdog timer - and with the scaler and a couple lines of code you could get it to operate at almost any period. So when it sleeps it does nothing and when it is awake and the proper period has been reached (using the clock frequency in the calculations to get your approximate period - I think this will be more than accurate enough)...then you would switch power on to a serial EEPROM (no sense powering it while sleeping), write a few bytes of measurements, control whatever else you have to control (water, etc.) and then go back to sleep. Your circuit would check for changed parameters when they're uploaded, no? There's no reason to code for it in your interrupt routine if it only changes when someone uploads data to it (and it'll have to be awake for that anyway). I was also thinking about using an IR communication instead of a physical connection to download/upload data. Mike |
|
|
|
--- In , "upand_at_them" <upand_at_them@y...> wrote: > Sounds cool. Here's what I'm thinking. And correct me if I have > your idea wrong... > > I'm thinking you probably don't need the RTC; you probably don't need > to know what temperature and soil conditions at a specific date and > time as much as you want to see trends over reasonably accurate > periods. If that's so, then I would use the watchdog timer - and > with the scaler and a couple lines of code you could get it to > operate at almost any period. > > So when it sleeps it does nothing and when it is awake and the proper > period has been reached (using the clock frequency in the > calculations to get your approximate period - I think this will be > more than accurate enough)...then you would switch power on to a > serial EEPROM (no sense powering it while sleeping), write a few > bytes of measurements, control whatever else you have to control > (water, etc.) and then go back to sleep. > > Your circuit would check for changed parameters when they're > uploaded, no? There's no reason to code for it in your interrupt > routine if it only changes when someone uploads data to it (and it'll > have to be awake for that anyway). > > I was also thinking about using an IR communication instead of a > physical connection to download/upload data. > > Mike Really neat ideas. You are correct that exact time is not a high priority, so knowing it was in the morning is probably good enough. If the PIC can keep withing about a minute a week, then 3 months would be within about 15 minutes and that is pleanty accurate. Dave |
|
|
|
> If the PIC can keep withing about a minute a week, then 3 months > would be within about 15 minutes and that is pleanty accurate. I haven't tested the accuracy of a uC based clock, but you could always have a RTC on the hand circuit and upload the time whenever an upload takes place if you were trying to minimize cost. Mike |
|
|
|
--- In , "upand_at_them" <upand_at_them@y...> wrote: > > If the PIC can keep withing about a minute a week, then 3 months > > would be within about 15 minutes and that is pleanty accurate. > > I haven't tested the accuracy of a uC based clock, but you could > always have a RTC on the hand circuit and upload the time whenever an > upload takes place if you were trying to minimize cost. > > Mike The idea of the RTC is interesting in that it adds scratch pad RAM. I have an RTC on order so I'll at least test it in the circuit. I have not determined if the back-up battery holds that with power off so it may not be as valuable as it could be. I think I will see just how accurate the timing is on a PIC with a crystal. Another question I have is about the Guard Ring on the DS1302 RTC chip. The spec sheet calls for a Guard Ring around the crystal pins connected to ground. I am looking at an 8 pin SOIC chip and am using a PCB etching machine so my isolation between traces is limited to a minimum of about 10 mill. With a 10 mil trace, and two 10 ten mill isolation spaces, there is little left over when there is only 50 mil between pads. Can anybody offer any experience with the differences between using and not using a Guard Ring on one of these clocks ? Or, maybe offer a list/site/url where I can get someone with personal experience ? Dave (Funny how the days waiting for the parts generates so many questions....) |
|
|
|
> The idea of the RTC is interesting in that it adds scratch pad RAM. True. But you won't have room in the PIC's data EEPROM? > I think I will see just how accurate the timing is on a PIC with a > crystal. And I think I'll try an experiment with a PIC and the RC oscillator option and post the results. I don't know anything about the guard ring, but I had a DS1302 sitting in a breadboard for a week at it was still accurate to the second. Mike --- In , "Dave Mucha" <davemucha@j...> wrote: > The idea of the RTC is interesting in that it adds scratch pad RAM. > I have an RTC on order so I'll at least test it in the circuit. > > I have not determined if the back-up battery holds that with power > off so it may not be as valuable as it could be. > > I think I will see just how accurate the timing is on a PIC with a > crystal. > > Another question I have is about the Guard Ring on the DS1302 RTC > chip. > > The spec sheet calls for a Guard Ring around the crystal pins > connected to ground. I am looking at an 8 pin SOIC chip and am > using a PCB etching machine so my isolation between traces is limited > to a minimum of about 10 mill. With a 10 mil trace, and two 10 ten > mill isolation spaces, there is little left over when there is only > 50 mil between pads. > > Can anybody offer any experience with the differences between using > and not using a Guard Ring on one of these clocks ? > > Or, maybe offer a list/site/url where I can get someone with personal > experience ? > > Dave > (Funny how the days waiting for the parts generates so many > questions....) |
|
|
|
--- In , "upand_at_them" <upand_at_them@y...> wrote: > > The idea of the RTC is interesting in that it adds scratch pad RAM. > > True. But you won't have room in the PIC's data EEPROM? The question here is about what happens to the variables when the power is lost. If there is no battery to the PIC, I thought everything except what you programmed was lost and that nothing was stored ? Never had to try to do that before so I just don't know. Dave |
|
|
|
two things . . . a) the data memory is EEPROM, that's eraseable electronic programmable read only memory, it keeps data when no power is on the chip b) I took a pic of my 16F628 running a stop watch routine, the LCD is next to a Casio dive watch (the watch shows minutes/seconds/hundreths, the LCD is hours/minutes/seconds). I started them both last night, and I was probably within a quarter second on each device. 23:46 later they are about a second apart. I had 00:00 and 23:46 movies but they didn't turn out due to lighting. The 16F628 is running at 4mhz doing an interrupt routine for the clock. The jpg is here: http://jrem.webhop.net/dscn0617.jpg Regards, John. --- Dave Mucha <> wrote: > --- In , "upand_at_them" <upand_at_them@y...> > wrote: > > > The idea of the RTC is interesting in that it adds scratch pad > RAM. > > > > True. But you won't have room in the PIC's data EEPROM? > The question here is about what happens to the variables when the > power is lost. If there is no battery to the PIC, I thought > everything except what you programmed was lost and that nothing was > stored ? > > Never had to try to do that before so I just don't know. > Dave __________________________________ ">http://mail.yahoo.com |
|
|
|
There are three types of memory in a PIC: 1) Program memory. This is where the program resides and it, obviously, remains untouched when the power is lost. 2) RAM. This is what the program uses for variables, etc. When power is lost so are the contents. 3) EEPROM data memory. This is like RAM, but when power is lost the contents remain. This is where people put calibration factors, etc. It can be programmed internally, through the program, or externally, through the device programmer. Not all PICs have this. And, btw, the RAM in the DS1302 is SRAM, so once power is lost...that's it. Mike --- In , "Dave Mucha" <davemucha@j...> wrote: > The question here is about what happens to the variables when the > power is lost. If there is no battery to the PIC, I thought > everything except what you programmed was lost and that nothing was > stored ? > > Never had to try to do that before so I just don't know. > Dave |
|
--- In , jrem <jrem123@y...> wrote: > b) I took a pic of my 16F628 running a stop watch routine, the LCD is > next to a Casio dive watch (the watch shows minutes/seconds/hundreths, > the LCD is hours/minutes/seconds). I started them both last night, and > I was probably within a quarter second on each device. 23:46 later > they are about a second apart. I had 00:00 and 23:46 movies but they > didn't turn out due to lighting. The 16F628 is running at 4mhz doing > an interrupt routine for the clock. Coded properly, there is no reason why a PIC clocked from a crystal won't be as accurate a time keeper as the cystal is. Thus if you have a 100ppm part then you should see less than 1 second drift in ~2.78 hours. If you have a 25ppm part it would no more than 1 second in ~11.11 hours. Note that these are worst case scenarios. This testing seems to confirm this. (And would anyone expect different?) |
|
--- In , "upand_at_them" <upand_at_them@y...> wrote: ... > > And I think I'll try an experiment with a PIC and the RC oscillator > option and post the results. > > I don't know anything about the guard ring, but I had a DS1302 > sitting in a breadboard for a week at it was still accurate to the > second. > > Mike the problem with RC (and intosc) is that RC drifts with the temperature. even if you found a combination that appeared to be accurate for a given test, change the temp and your frequency will drift. |
|
I have not looked at the specs for the part, but the ring guard is used for very high impedance inputs to reduce surface leakage current on the PWB. Very high impeadance means long battery life, but also very little drive requirements, which means any leakage may kill the oscillator, or if it has AGC will increase the battery current. Chad <<< Snip >>> > > Another question I have is about the Guard Ring on the DS1302 RTC > chip. > > The spec sheet calls for a Guard Ring around the crystal pins > connected to ground. I am looking at an 8 pin SOIC chip and am > using a PCB etching machine so my isolation between traces is limited > > to a minimum of about 10 mill. With a 10 mil trace, and two 10 ten > > mill isolation spaces, there is little left over when there is only > 50 mil between pads. > > Can anybody offer any experience with the differences between using > and not using a Guard Ring on one of these clocks ? > > Or, maybe offer a list/site/url where I can get someone with personal > > experience ? > > Dave > (Funny how the days waiting for the parts generates so many > questions....) ===== My software has no bugs. Only undocumented features. __________________________________ |