Time calculations
Hi group.
My R/C submarine and home built control unit both have Dallas real time
clocks in them. I have a need to look at the time and determine if a given
amout of time has passed. Doing time math is a pain and I wondered if someone
has "walked the mile" and come up with a routine to subtract time 2 from time
1??
Thanks
Mike B.
(This sounds like a job for Al Williams)
[noparse][[/noparse]Non-text portions of this message have been removed]
My R/C submarine and home built control unit both have Dallas real time
clocks in them. I have a need to look at the time and determine if a given
amout of time has passed. Doing time math is a pain and I wondered if someone
has "walked the mile" and come up with a routine to subtract time 2 from time
1??
Thanks
Mike B.
(This sounds like a job for Al Williams)
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
sprinkler controllers, we always dealt in minutes so time was represented by
a value from 0 (midnight) to 1439 (11:59 PM). This makes doing the math
pretty easy. It wouldn't be horribly difficult to deal with seconds
separately.
Here some easy math:
rawTimeVal = (hours * 60) + minutes
hours = rawTimeVal / 60
minutes = rawTimeVal // 60
-- Jon Williams
-- Parallax
In a message dated 5/5/02 6:47:40 PM Central Daylight Time, w6ffc@p...
writes:
> My R/C submarine and home built control unit both have Dallas real time
> clocks in them. I have a need to look at the time and determine if a given
> amout of time has passed. Doing time math is a pain and I wondered if
> someone has "walked the mile" and come up with a routine to subtract time 2
> from time 1??
>
[noparse][[/noparse]Non-text portions of this message have been removed]
Thanks for the reply. Kind of expected to hear bad news. I'll have to
see if the RTC accumulates seconds and then does the conversion for you.
Don't know yet. Just getting started with the RTC portion of this
"SuperMax" add on board.
Here's what the hand held controller side has connected to the
SuperMax/Stamp 2 so far.
2 digit BCD thumbwheel via 3 wire serial 74LS165 for
function/display/play sound selection
QuadraVox voice recorder (four minute version)
5 watt, serially controlled UHF two way data radio for comms with the
submarine
6 two color LEDs via 3 wire serial to a 74HC595 to show submaring systems
status (looking for all green before diving, the "Green Board")
Serial LCD 4 X 20 display (Scott Edwards)
3 linear taper pot through 8 bit A/Ds for rudder, dive planes and speed
control
3 toggle switches to blow/vent the tanks
In the submarine there is a "Time Keeper 3.1" add on board for the
Stamp 2 with RTC and 128k EEPROM
serial 8 channel servo controller to control rudder/dive planes and
blow/vent valves. Speed is via an 80 amp R/C car speed control (looks like
a servo)
2 pressure transducers to measure the high pressure CO2 gas supply and the
low pressure distributed CO2
Several reed switches to a serial 74LS165 to indicate valve positions for
failure detection etc.
Serial two way UHF data radio
The controller portion is talking to the BCD, LCD and voice board today.
Tomorrow will get the POTS talking to the ADC's.
Love this Stamp stuff...
MIke B.
Original Message
From: <jonwms@a...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, May 05, 2002 4:53 PM
Subject: Re: [noparse][[/noparse]basicstamps] Time calculations
> Ease depends on the resolution you need, timewise. When I used to design
> sprinkler controllers, we always dealt in minutes so time was represented
by
> a value from 0 (midnight) to 1439 (11:59 PM). This makes doing the math
> pretty easy. It wouldn't be horribly difficult to deal with seconds
> separately.
>
> Here some easy math:
>
> rawTimeVal = (hours * 60) + minutes
>
> hours = rawTimeVal / 60
> minutes = rawTimeVal // 60
>
> -- Jon Williams
> -- Parallax
>
>
> In a message dated 5/5/02 6:47:40 PM Central Daylight Time,
w6ffc@p...
> writes:
>
>
> > My R/C submarine and home built control unit both have Dallas real
time
> > clocks in them. I have a need to look at the time and determine if a
given
> > amout of time has passed. Doing time math is a pain and I wondered if
> > someone has "walked the mile" and come up with a routine to subtract
time 2
> > from time 1??
> >
>
>
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
read by nibbles (i.e HIGH NIB and LOW NIB), I did the math like this
timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
This gives me a time in total seconds. You should be able to compare
time1 and time2 as long as you don't exceed 1 hour. You could up the
time values to hours and minutes as long as you don't compare for
more than 24 hours apart.
HTH
Don
--- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> Hi group.
>
> My R/C submarine and home built control unit both have Dallas
real time clocks in them. I have a need to look at the time and
determine if a given amout of time has passed. Doing time math is a
pain and I wondered if someone has "walked the mile" and come up with
a routine to subtract time 2 from time 1??
>
> Thanks
>
> Mike B.
>
> (This sounds like a job for Al Williams)
>
>
> [noparse][[/noparse]Non-text portions of this message have been removed]
hear from the boat in x number of seconds I need to panic and do something.
The problem as I saw it was if I heard from the boat at 58 seconds past the
minute and then again at 12 seconds past the going over 59 makes the math a
bit of a problem. I'm not so interested in the exact time as I am an
elapsed time.
Thanks, this message goes to the project folder....
Mike B.
Original Message
From: "mtlhead7" <renegade.engineer@v...>
To: <basicstamps@yahoogroups.com>
Sent: Sunday, May 05, 2002 5:13 PM
Subject: [noparse][[/noparse]basicstamps] Re: Time calculations
> Knowing that the DS1302 RTC outputs byte values that need to be
> read by nibbles (i.e HIGH NIB and LOW NIB), I did the math like this
>
> timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
> Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
>
> This gives me a time in total seconds. You should be able to compare
> time1 and time2 as long as you don't exceed 1 hour. You could up the
> time values to hours and minutes as long as you don't compare for
> more than 24 hours apart.
>
> HTH
> Don
>
>
> --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > Hi group.
> >
> > My R/C submarine and home built control unit both have Dallas
> real time clocks in them. I have a need to look at the time and
> determine if a given amout of time has passed. Doing time math is a
> pain and I wondered if someone has "walked the mile" and come up with
> a routine to subtract time 2 from time 1??
> >
> > Thanks
> >
> > Mike B.
> >
> > (This sounds like a job for Al Williams)
> >
> >
> > [noparse][[/noparse]Non-text portions of this message have been removed]
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
midnight every time you heard from the boat? In this manner, your RTC
becomes and elapsed time timer.
-- Jon Williams
-- Parallax
In a message dated 5/5/02 8:03:06 PM Central Daylight Time, w6ffc@p...
writes:
> Ok, now were talking. I only need several second intervals. ie: if I don't
> hear from the boat in x number of seconds I need to panic and do something.
> The problem as I saw it was if I heard from the boat at 58 seconds past the
> minute and then again at 12 seconds past the going over 59 makes the math a
> bit of a problem. I'm not so interested in the exact time as I am an
>
[noparse][[/noparse]Non-text portions of this message have been removed]
like this:
timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
(Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
Sorry, I forgot a couple parenthesis when I wrote before.
Good Luck
Don
--- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> Ok, now were talking. I only need several second intervals. ie:
if I don't
> hear from the boat in x number of seconds I need to panic and do
something.
> The problem as I saw it was if I heard from the boat at 58 seconds
past the
> minute and then again at 12 seconds past the going over 59 makes
the math a
> bit of a problem. I'm not so interested in the exact time as I am
an
> elapsed time.
>
> Thanks, this message goes to the project folder....
>
> Mike B.
>
Original Message
> From: "mtlhead7" <renegade.engineer@v...>
> To: <basicstamps@y...>
> Sent: Sunday, May 05, 2002 5:13 PM
> Subject: [noparse][[/noparse]basicstamps] Re: Time calculations
>
>
> > Knowing that the DS1302 RTC outputs byte values that need to be
> > read by nibbles (i.e HIGH NIB and LOW NIB), I did the math like
this
> >
> > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
> > Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> >
> > This gives me a time in total seconds. You should be able to
compare
> > time1 and time2 as long as you don't exceed 1 hour. You could up
the
> > time values to hours and minutes as long as you don't compare for
> > more than 24 hours apart.
> >
> > HTH
> > Don
> >
> >
> > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > Hi group.
> > >
> > > My R/C submarine and home built control unit both have Dallas
> > real time clocks in them. I have a need to look at the time and
> > determine if a given amout of time has passed. Doing time math
is a
> > pain and I wondered if someone has "walked the mile" and come up
with
> > a routine to subtract time 2 from time 1??
> > >
> > > Thanks
> > >
> > > Mike B.
> > >
> > > (This sounds like a job for Al Williams)
> > >
> > >
> > > [noparse][[/noparse]Non-text portions of this message have been removed]
> >
> >
> > To UNSUBSCRIBE, just send mail to:
> > basicstamps-unsubscribe@y...
> > from the same email address that you subscribed. Text in the
Subject and
> Body of the message will be ignored.
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
((Minutes.HIGHNIB*600)+Minutes.LOWNIB*60))
I've been working on an array input problem all day and am getting
delirious.
I promise this one works!
Don
--- In basicstamps@y..., "mtlhead7" <renegade.engineer@v...> wrote:
> I looked back at my program and the formula should actually look
> like this:
>
> timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
> (Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
>
> Sorry, I forgot a couple parenthesis when I wrote before.
>
> Good Luck
> Don
>
> --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > Ok, now were talking. I only need several second intervals. ie:
> if I don't
> > hear from the boat in x number of seconds I need to panic and do
> something.
> > The problem as I saw it was if I heard from the boat at 58
seconds
> past the
> > minute and then again at 12 seconds past the going over 59 makes
> the math a
> > bit of a problem. I'm not so interested in the exact time as I
am
> an
> > elapsed time.
> >
> > Thanks, this message goes to the project folder....
> >
> > Mike B.
> >
Original Message
> > From: "mtlhead7" <renegade.engineer@v...>
> > To: <basicstamps@y...>
> > Sent: Sunday, May 05, 2002 5:13 PM
> > Subject: [noparse][[/noparse]basicstamps] Re: Time calculations
> >
> >
> > > Knowing that the DS1302 RTC outputs byte values that need to
be
> > > read by nibbles (i.e HIGH NIB and LOW NIB), I did the math like
> this
> > >
> > > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
> > > Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> > >
> > > This gives me a time in total seconds. You should be able to
> compare
> > > time1 and time2 as long as you don't exceed 1 hour. You could
up
> the
> > > time values to hours and minutes as long as you don't compare
for
> > > more than 24 hours apart.
> > >
> > > HTH
> > > Don
> > >
> > >
> > > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > > Hi group.
> > > >
> > > > My R/C submarine and home built control unit both have
Dallas
> > > real time clocks in them. I have a need to look at the time and
> > > determine if a given amout of time has passed. Doing time math
> is a
> > > pain and I wondered if someone has "walked the mile" and come
up
> with
> > > a routine to subtract time 2 from time 1??
> > > >
> > > > Thanks
> > > >
> > > > Mike B.
> > > >
> > > > (This sounds like a job for Al Williams)
> > > >
> > > >
> > > > [noparse][[/noparse]Non-text portions of this message have been removed]
> > >
> > >
> > > To UNSUBSCRIBE, just send mail to:
> > > basicstamps-unsubscribe@y...
> > > from the same email address that you subscribed. Text in the
> Subject and
> > Body of the message will be ignored.
> > >
> > >
> > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> > >
> > >
Last time, I swear:
timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
((Minutes.HIGHNIB*600)+(Minutes.LOWNIB*60))
Don
--- In basicstamps@y..., "mtlhead7" <renegade.engineer@v...> wrote:
> Ok, my brain is fried. Try this one:
>
> timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
> ((Minutes.HIGHNIB*600)+Minutes.LOWNIB*60))
>
> I've been working on an array input problem all day and am
getting
> delirious.
> I promise this one works!
> Don
>
>
> --- In basicstamps@y..., "mtlhead7" <renegade.engineer@v...> wrote:
> > I looked back at my program and the formula should actually
look
> > like this:
> >
> > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
> > (Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> >
> > Sorry, I forgot a couple parenthesis when I wrote before.
> >
> > Good Luck
> > Don
> >
> > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > Ok, now were talking. I only need several second intervals.
ie:
> > if I don't
> > > hear from the boat in x number of seconds I need to panic and
do
> > something.
> > > The problem as I saw it was if I heard from the boat at 58
> seconds
> > past the
> > > minute and then again at 12 seconds past the going over 59
makes
> > the math a
> > > bit of a problem. I'm not so interested in the exact time as I
> am
> > an
> > > elapsed time.
> > >
> > > Thanks, this message goes to the project folder....
> > >
> > > Mike B.
> > >
Original Message
> > > From: "mtlhead7" <renegade.engineer@v...>
> > > To: <basicstamps@y...>
> > > Sent: Sunday, May 05, 2002 5:13 PM
> > > Subject: [noparse][[/noparse]basicstamps] Re: Time calculations
> > >
> > >
> > > > Knowing that the DS1302 RTC outputs byte values that need
to
> be
> > > > read by nibbles (i.e HIGH NIB and LOW NIB), I did the math
like
> > this
> > > >
> > > > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
> > > > Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> > > >
> > > > This gives me a time in total seconds. You should be able to
> > compare
> > > > time1 and time2 as long as you don't exceed 1 hour. You
could
> up
> > the
> > > > time values to hours and minutes as long as you don't compare
> for
> > > > more than 24 hours apart.
> > > >
> > > > HTH
> > > > Don
> > > >
> > > >
> > > > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > > > Hi group.
> > > > >
> > > > > My R/C submarine and home built control unit both have
> Dallas
> > > > real time clocks in them. I have a need to look at the time
and
> > > > determine if a given amout of time has passed. Doing time
math
> > is a
> > > > pain and I wondered if someone has "walked the mile" and come
> up
> > with
> > > > a routine to subtract time 2 from time 1??
> > > > >
> > > > > Thanks
> > > > >
> > > > > Mike B.
> > > > >
> > > > > (This sounds like a job for Al Williams)
> > > > >
> > > > >
> > > > > [noparse][[/noparse]Non-text portions of this message have been removed]
> > > >
> > > >
> > > > To UNSUBSCRIBE, just send mail to:
> > > > basicstamps-unsubscribe@y...
> > > > from the same email address that you subscribed. Text in the
> > Subject and
> > > Body of the message will be ignored.
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> > > >
> > > >
Last time, I swear:
timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
((Minutes.HIGHNIB*600)+(Minutes.LOWNIB*60))
Don
--- In basicstamps@y..., "mtlhead7" <renegade.engineer@v...> wrote:
> Ok, my brain is fried. Try this one:
>
> timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
> ((Minutes.HIGHNIB*600)+Minutes.LOWNIB*60))
>
> I've been working on an array input problem all day and am
getting
> delirious.
> I promise this one works!
> Don
>
>
> --- In basicstamps@y..., "mtlhead7" <renegade.engineer@v...> wrote:
> > I looked back at my program and the formula should actually
look
> > like this:
> >
> > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB)+
> > (Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> >
> > Sorry, I forgot a couple parenthesis when I wrote before.
> >
> > Good Luck
> > Don
> >
> > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > Ok, now were talking. I only need several second intervals.
ie:
> > if I don't
> > > hear from the boat in x number of seconds I need to panic and
do
> > something.
> > > The problem as I saw it was if I heard from the boat at 58
> seconds
> > past the
> > > minute and then again at 12 seconds past the going over 59
makes
> > the math a
> > > bit of a problem. I'm not so interested in the exact time as I
> am
> > an
> > > elapsed time.
> > >
> > > Thanks, this message goes to the project folder....
> > >
> > > Mike B.
> > >
Original Message
> > > From: "mtlhead7" <renegade.engineer@v...>
> > > To: <basicstamps@y...>
> > > Sent: Sunday, May 05, 2002 5:13 PM
> > > Subject: [noparse][[/noparse]basicstamps] Re: Time calculations
> > >
> > >
> > > > Knowing that the DS1302 RTC outputs byte values that need
to
> be
> > > > read by nibbles (i.e HIGH NIB and LOW NIB), I did the math
like
> > this
> > > >
> > > > timeX=(Seconds.HIGHNIB*10+Seconds.LOWNIB+
> > > > Minutes.HIGHNIB*600+Minutes.LOWNIB*60)
> > > >
> > > > This gives me a time in total seconds. You should be able to
> > compare
> > > > time1 and time2 as long as you don't exceed 1 hour. You
could
> up
> > the
> > > > time values to hours and minutes as long as you don't compare
> for
> > > > more than 24 hours apart.
> > > >
> > > > HTH
> > > > Don
> > > >
> > > >
> > > > --- In basicstamps@y..., Mike Blier <w6ffc@p...> wrote:
> > > > > Hi group.
> > > > >
> > > > > My R/C submarine and home built control unit both have
> Dallas
> > > > real time clocks in them. I have a need to look at the time
and
> > > > determine if a given amout of time has passed. Doing time
math
> > is a
> > > > pain and I wondered if someone has "walked the mile" and come
> up
> > with
> > > > a routine to subtract time 2 from time 1??
> > > > >
> > > > > Thanks
> > > > >
> > > > > Mike B.
> > > > >
> > > > > (This sounds like a job for Al Williams)
> > > > >
> > > > >
> > > > > [noparse][[/noparse]Non-text portions of this message have been removed]
> > > >
> > > >
> > > > To UNSUBSCRIBE, just send mail to:
> > > > basicstamps-unsubscribe@y...
> > > > from the same email address that you subscribed. Text in the
> > Subject and
> > > Body of the message will be ignored.
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/
> > > >
> > > >