Sunday, March 30, 2008

Re: [oopic] Providing a clock/time to the PIC

minghui1984 wrote:
> Hi guys, i got a question. As i am dealing with solar tracking
> device, i would like to be able to feedback the time to the PIC. i
> look through the object list and found several options that i could
> use. Thought i just ask if there is any shorter way of doing it.
>
> What i need:
> Implementing a "clock" by using counters, using the execution cycle
> and frequency of the PIC (in this case ooPIC is 20MHz). I would
>
> counter_sec++;
> if counter_sec == 60
> {
> counter_min++;
> counter_sec = 0; 'resetting it back to 0
> }
> if counter_min == 60
> {
> counter_hrs++;
> counter_min = 0; 'resetting it back to 0
> }
>
> if counter_hrs == 24
> {
> day++;
> counter_hrs =0; 'resetting it back to 0
> }
>
> Loop
>
> My question is will this code work?
> how do i make this function keep on running outside the main function
> Is this a good way of "telling" the time? Cos my device is a
> standalone kind so no PC/Laptops will be connected once its configured
>
> In the object list, there are oTimer, oCounter, oClock, are these
> suited for the purpose? I looked thru the example, but i dun quite
> get it. >.<
>
> Anyone got any hints to how i might make this thing work?
>
>
I would think the oRTC object would be best suited for your purpose. It
is an object that maintains a real-time clock. It's been a few years
since I last played with this object but I do remember that it was
accurate to about 2 sec in a 24 hour period.
Also it will lose its current state when power to the oopic is interrupted.

Good luck

Ian

------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:

http://groups.yahoo.com/group/oopic/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:

http://groups.yahoo.com/group/oopic/join

(Yahoo! ID required)

<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

http://docs.yahoo.com/info/terms/

No comments:

Post a Comment