Prop as Real Time Clock ?
Rayman
Posts: 14,791
Ok, I've already bought some "DS1302 Timekeeping Chip".· And I see there is already code posted to interface to it.
But, couldn't a spare cog be programmed to do the same thing?· The proto and demo boards come with a cyrstal oscillator (maybe it's not as precise as the 32.768 kHz one?).· It seems a cog could just watch the CNT and increment a ms register every 80,000 clocks.· I guess days/month and leap years would take some code to handle, but it doesn't seem too tough...
The one really nice thing that the DS1302 has is a second Vcc input that can come from a backup coin cell lithium battery.· I'm not exactly sure how to implement this with the Prop.· I'm not even sure it would run off a 3V lithium cell...
But, couldn't a spare cog be programmed to do the same thing?· The proto and demo boards come with a cyrstal oscillator (maybe it's not as precise as the 32.768 kHz one?).· It seems a cog could just watch the CNT and increment a ms register every 80,000 clocks.· I guess days/month and leap years would take some code to handle, but it doesn't seem too tough...
The one really nice thing that the DS1302 has is a second Vcc input that can come from a backup coin cell lithium battery.· I'm not exactly sure how to implement this with the Prop.· I'm not even sure it would run off a 3V lithium cell...
Comments
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.
That is why they call it the present.
Don't have VGA?
Newzed@aol.com
·
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.
That is why they call it the present.
Don't have VGA?
Newzed@aol.com
·
Maybe I'm just lucky with my crystal though..
I don't have a power problem here.. we get less than 20 mins downtime per year, and my UPS will cover that standing on its head [noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
Instead of a diode, use a MOSFET with the gate tied to the drain. This will "act" like a diode without the voltage drop.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Graham
Any crystal would need either temperature control, or temperature-sensitive circuit adjustments, or temperature-based software correction, or periodic adjustment based on an external time source to keep accurate time for the long term.
When I started experimenting with high-gain op-amps, I used to pick up lots of interference by 100 kHz signal bursts that I eventually learned were from a LORAN station a few hundred miles away. But later on, I learned that LORAN signals can be used for the most precise time syncronization short of GPS or your own atomic clock. They're much better than WWV (a U.S. precision time broadcast station) because the low frequency isn't as subject to the atmospheric path variations. If a propeller used a cog to detect and lock onto the LORAN pulses, you could design a clock as precise as a GPS-based clock.
But LORAN doesn't transmit time-of-day, just raw pulses at extremely precise intervals (except for some new experimental stations that are transmitting that info). So to get you past a power failure you would need some way to restore the time of day, whether WWV, or GPS, or a battery or capacitor backed RTC.
Graham
(a) There is nothing special with 32768 crystals. They are extraordinary tiny, and they deliver 1 second by a simple division by 2^16. That are all their merrits.
(b) All crystals are extremely precise (someone mentioned 20 ppm) as long as temperature variations are limited. However they need a very specific adaptation of capacity to run at the frequency printed on them, as ALL capacities around them add to their behavior. It generally suffices to add a small 20pf trim cap from XINPUT to griund and adjust it.
(c) Without that correction most likely ALL crystals will run around 0.01% faster than expected (=some seconds per day!)
If you know of one that I can find at Radio Shack, I'll like try it this weekend...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
It may have been the power led on the demo board loading it down. I'm going to try this one on a proto board.
Note: This is just a trade name: No gold in it
Maybe it's better I just get some DS1307 chips...
Gold Caps tolerate low voltage only (2V5; 5 V types are 2 in series) and are susceptable to higher temperature...
But there is a new generation of "super caps" in the make: They use carbon nano-technology and soon will supersede recharcheables... Having the same capacity (1000F) , but unlimited recharge cycles and - if you can supply the current - can be recharged in seconds rather than hours.
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.
That is why they call it the present.
Don't have VGA?
Newzed@aol.com
·
General info on a mosfet for use with the Prop: Fnd one that starts with IRL instead of IRF. (IRL530) The L stands for low threshold, or logic level threshold.
Sid, the capacity of the CR2032 is 240 mAh (source, energizer.com). The continuous current rated on their data sheets is 190 microamps and they also specify for pulse output at 7.5 mA. I have used CR2032s to power data loggers and with careful attention to power budget and with use of capacitors to supply the pulses, they can be a very economical and light weight power source. The Prop can go a long time operating on 4 microamps in RCSLOW mode, with occasional blips to higher power. Sid, I meant to ask you, have you experimented with the DS1338? It is the 3 volt version of the DS1307.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
http://www.sparkfun.com/commerce/present.php?p=Sensor-Interfacing
In a recent project I used Cog 0 as an RTC, with Cog1 handling the time/date display function and other Cogs used for miscellaneous external control functions.
As the unit is only powered up for 8 hours/day, it was necessary to provide battery backup to maintain the clock activity.
It was set up with a Pin dedicated to monitoring the main supply, and when that went off, all Cogs other than Cog0 were shutdown, reducing the Prop's load to <1mA (Xtal 5mHz)
When the main power is restored, the operation returns to normal, with all "off" Cog's re-started.
I used a 140mAH NiMh battery pack (cordless phone unit) fed via a PNP transistor(BC558) and a diode.
The mainpower is obtained from a voltage regulator (LM317T) adjusted for 3.9V and also fed via a diode, resulting in approx. 3.3V at the Prop.
A 1000uF capacitor is across the Prop's power pin to ensure smooth changeover.
When the main power is present, the transistor is biased off the main +ve voltage is connected directly to the base.
If the power goes off, the transistor is biased on, ( resistor from base to 0V) allowing the prop. to be fed from the battery.
The battery is charged via resistor from the voltage that feeds the regulator.
The timing of the RTC can be adjusted per program delay very precisely because the dedicated Cog program path doesn't change - i.e. there are no variations in program overheads.
The major factor in variations in timing accuracy will of course still be the temperature effects on the Xtal.
I haven't yet tried for the absolute maximum accuracy, just sufficient for practical maintenance of the real time - it is only checked/adjusted every two weeks.
Unfortunately I couldn't upload the schematic because it is Open Office format (.odg).
Summarising:
Normal Power
- Prop sees power via monitoring pin, starts all Cogs.
- transistor is biased off by main power
- battery is charged via resistor (trimpot)
Power Off
- Prop. sees no power on monitoring pin, shuts down all cogs except Cog0, reducing load to minimum (<1mA)
- transistor turned on , allows battery to feed the Prop.
- Cog0 continues normal clock timing.
The battery size is chosen to suit the expected maximum "non-power" period that will be experienced. (like several days!)
kenmac
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Perth, Western Australia
Time Zone = GMT + 8