Huge program plus a DS1302
Randy
Posts: 79
I have a project I've been working on for a long time. It measures, displays and stores time and temperature information from eleven sensors. It has an A/D converter, eleven temperature sensors, two Stamps, a clock and a display. It has been pieced together and modified to merge as I built and tested the circuit and the programs in sections. Like many of us "stampers", this is a hobby. I am learning as I go and often don't have time to work on it for months allowing me to forget half what I had learned.·The hardware is pretty straight forward and compact but the program has gotten huge and I still want to add to it. Storing and comparing data takes a lot of precious memory and at some point I would like to add an EEPROM and also use StampDaq, but before that I need to make the program I have more compact. For all the articles I have seen on DS1302 clocks, I've found none that use alll of the chips time and date functions and can be set buttons rather than a PC. This project lives out in the world un-tethered to a computer. I like what my clock setting program does and I think it is user friendly but there has got to be a better way.
Of far less importance, but this bugs me, I never did get the backup charging function to charge the capacitor. I tried every combination of 1s and 0s that would fit but it never did·charge. If you look at the schematic I found a way around it, the clock maintains time for days without power, but I'd still like to know why it won't work from the chip's circuit. I am also suspicious that the SELECT CASE and·STORE routines can be more efficient. Some day I would like to add an EEPROM and give myself a new headache but I would like to learn a better way of what I have before I dive into that pond. So if any of you experienced program writing gurus are fool enough to take the time to look at the attached programs and make suggestions I would be grateful. I have aworking model that has been in use for months. I·periodically·comment out some functions, program a Stamp for the specifics I want to see, and swap Stamps. The clock has a backup power source so I can put in a Stamp, set the clock, remove power from the rest of the circuit, change to a Stamp without the clock setting program, turn it back on with the·new functions and still have time and date. The program is so bloated it stil limits what I can do. Sorry about the long intro but I think this is the minimum explanation to understand what I want this to do. I am not able to check responses to my question very regularly but will be happy to provide more info if needed. Like my programing I can't be succinct.
Randy
Of far less importance, but this bugs me, I never did get the backup charging function to charge the capacitor. I tried every combination of 1s and 0s that would fit but it never did·charge. If you look at the schematic I found a way around it, the clock maintains time for days without power, but I'd still like to know why it won't work from the chip's circuit. I am also suspicious that the SELECT CASE and·STORE routines can be more efficient. Some day I would like to add an EEPROM and give myself a new headache but I would like to learn a better way of what I have before I dive into that pond. So if any of you experienced program writing gurus are fool enough to take the time to look at the attached programs and make suggestions I would be grateful. I have aworking model that has been in use for months. I·periodically·comment out some functions, program a Stamp for the specifics I want to see, and swap Stamps. The clock has a backup power source so I can put in a Stamp, set the clock, remove power from the rest of the circuit, change to a Stamp without the clock setting program, turn it back on with the·new functions and still have time and date. The program is so bloated it stil limits what I can do. Sorry about the long intro but I think this is the minimum explanation to understand what I want this to do. I am not able to check responses to my question very regularly but will be happy to provide more info if needed. Like my programing I can't be succinct.
Randy
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
We use a supercap, and it holds the time for about 3 - 4 weeks without power.
Sorry if the code is a bit meaningless, its mixed in with heaps of other stuff (keypad input and lcd output) which would just make it more confusing, so I have just cut the bit out that actually writes the time / date / setup to the ds1302.
It is a very reliable timekeeper.
Code below,
Cheers, Chris
>>>>>
UPDATE:
TIMER.LOWBYTE = $10 'clear write protect bit in control register
TIMER.HIGHBYTE = %00111
GOSUB writeRTC
TIMER.LOWBYTE = %10100111
TIMER.HIGHBYTE = %01000 'enable trickle charger, 1 diode, 8K resistor
GOSUB writeRTC
TIMER.LOWBYTE = %00010011
TIMER.HIGHBYTE = %00000 'set SECONDS
GOSUB writeRTC
TIMER.LOWBYTE = LITCT.LOWBYTE
TIMER.HIGHBYTE = %00001 'set minutes
GOSUB writeRTC
TIMER.LOWBYTE = LITCT.HIGHBYTE
TIMER.HIGHBYTE = %00010 'set hours
GOSUB writeRTC
TIMER.LOWBYTE = LCDTIME.HIGHBYTE
TIMER.HIGHBYTE = %00011 'set date
GOSUB writeRTC
TIMER.LOWBYTE = LCDTIME.LOWBYTE
TIMER.HIGHBYTE = %00100 'set month
GOSUB writeRTC
TIMER.LOWBYTE = CAP
TIMER.HIGHBYTE = %00110 'set year
GOSUB writeRTC
TIMER.LOWBYTE = $80 'reset write protect bit to "1" in control register
TIMER.HIGHBYTE = %00111
GOSUB writeRTC
GOTO EXITCYCLE
WRITERTC:
HIGH Res1302
SHIFTOUT datapin, clock, LSBFIRST, [noparse][[/noparse]%0\1,TIMER.HIGHBYTE\5,%10\2,TIMER.LOWBYTE] 'write instruction to ds1302
LOW Res1302
RETURN