It would help if you gave us an idea of what are you are using your "exact second" for, and why it has to be so accurate.
It would help if you gave us an idea of what are you are using your "exact second" for, and why it has to be so accurate.
Actually, Melanie, hundreths or thousandths would be even better. I am monitoring the current flow through transistors and keeping track of the mAH as it counts up on the LCD. When the current stops the count stops. I will be monitoring the current through 4 transistors simultaneously. With a time reference that each sub program can access, the math in the sub program can make the calculations and display them on the four lines of the LCD. When the current flow stops, the readings will remain on the LCD until the user decides otherwise.
I can do this with seconds, but the math will work even better with hundredths or thousandths, without floating point.
You're obsessed! Look, you're charging/discharging batteries for Gawds sake, not measuring the velocity of a speeding bullet!
Who cares if it's exactly an hour, or an hour and 15 seconds...
Do your ADC's, do your calculations (assuming a 100mS time interval), insert a Pause 100 and simply Loop. Just forget the time for the ADC's to operate and your math time. Just do a Pause 100.
The first time you run your program insert a message to appear on your LCD after 36000 loops... (an hours worth of 100mS loops). You run a stop-watch and compare your watch against the PIC. You'll probably find it'll be an hour and a few minutes. Calculate the overspill time and reduce the Pause 100 statement accordingly. Hey presto - you're done.
Now, if it ends up a few seconds out per hour, the batteries aren't going to care, after all they're a big chemical pile and you can't predict how chemicals will react from charge to charge, let alone down to fractions of a second. You're going to charge a 2200mAH Battery for example... it'll behave differently when factory fresh to when it's a year old. Best guess is close enough. So if you're charging a Battery for an hour, so what if you charge for one hour, one minute and seventeen seconds? It's not going to hurt.
Very perceptive Mel, I'm impressed! I'll give it a try. 15 sec. an hour is less than 1%, I could live with that. One minute and fifteen seconds would not let an obsessed geezer sleep at night.
I am an old broadcast engineer, +/- 20 cycles per million in the days of vacuum tubes and crystal ovens. I'm too old to change very much now.
I didn't expect the pause command would be that accurate, but i'll try anything once.
This is a great forum, lots of idea exchange, and helpful people. It's a fast track for those just getting started, especially the chronologically handicapped.
Thanks for your help.
The obsessed Geezer
Bookmarks