Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Advertise Here

Discussion forum for the BasicX family of microcontroller chips.

Timer? - Chris Parker - Nov 19 20:41:00 1999

Hi,

I need to incorporate a stopwatch type timer in a program I am writing for the BX24. I have looked at, and run, TimerExample.bas but it only counts about 9 seconds before rolling over to zero. and continuing from there. The overflow flag doesn't seem to declare overflow. Anyway I need to be able to count and display the time between button presses. It could be up to 30 minutes or more between presses.

Would I be better off using Timer1 or using the GetTime function? Just looking through the book I see that Timer returns the number of seconds since midnight. I guess this would be a good place to start?

Any hints would be appreciated.

Regards
Chris Parker






(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Timer? - Nick Taylor - Nov 19 21:55:00 1999

I've played with the GetTime and PutTime procedures ... they're fine
if you don't need accuracy of better than one second. Peter Anderson
has a digital clock for the BX-1 on his site that moves to the BX-24
easily ... kinda cool. If you need better than whole second resolution,
then the Timer function looks to be the way to go. You can reset the
clock to "midnight" with a call to PutTime(0, 0, 0.0). I haven't
played with the Timer function, but according to the manual it looks
as if it shouldn't rollover till midnight.

- Nick -

Chris Parker wrote:
>
> Hi,
>
> I need to incorporate a stopwatch type timer in a program I am writing for the BX24. I have looked at, and run, TimerExample.bas but it only counts about 9 seconds before rolling over to zero. and continuing from there. The overflow flag doesn't seem to declare overflow. Anyway I need to be able to count and display the time between button presses. It could be up to 30 minutes or more between presses.
>
> Would I be better off using Timer1 or using the GetTime function? Just looking through the book I see that Timer returns the number of seconds since midnight. I guess this would be a good place to start?
>
> Any hints would be appreciated.
>
> Regards
> Chris Parker
>
> [Attachments have been removed from this message]
>
> ---------------------------------------------------------------
> [Image]
> Click Here




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Timer? - Frank Manning - Nov 20 13:54:00 1999

From: Nick Taylor <>

> I've played with the GetTime and PutTime procedures ... they're fine
> if you don't need accuracy of better than one second. Peter Anderson
> has a digital clock for the BX-1 on his site that moves to the BX-24
> easily ... kinda cool. If you need better than whole second resolution,
> then the Timer function looks to be the way to go.
> [...]

Yes, I agree that Timer is probably the way to go for this application. But
GetTime/PutTime both have a resolution of about 2 ms, not integer seconds.

BTW, the Timer function is essentially identical to the functions of the
same name in QuickBasic and Visual Basic, and it has the same Cinderella
problem at midnight :-)

>Chris Parker wrote:
>> [...]
>> Anyway I need to be able to count and display the time
>> between button presses. It could be up to 30 minutes
>> or more between presses.
>> [...]

-- Frank Manning
-- NetMedia, Inc.




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Timer? - Frank Manning - Nov 20 18:23:00 1999

Chris Parker <> wrote:

> [...]
> I have looked at, and run, TimerExample.bas but it only
> counts about 9 seconds before rolling over to zero. and
> continuing from there. The overflow flag doesn't seem to
> declare overflow.
> [...]

TimerExample was intended for BX-01 systems, and hasn't been adapted yet to
the BX-24. Here's the modification needed for the BX-24 -- at the beginning
of module Timer1.bas, these statements appear:

' Timer/Counter1 overflow flag.
Private Const TOV1 As Byte = bx10000000

TOV1 is at a different location in the BX-24. If you make this change:

Private Const TOV1 As Byte = bx00000100 ' BX-24

the overflow flag should work OK.

The main intent of the example program (as well as the edge capture and PWM
example) is to illustrate how you can get low-level access to machine
registers. Unfortunately, BX-01 and BX-24 (Atmel 8515 and 8535) registers
are similar but not identical.

-- Frank Manning
-- NetMedia, Inc.





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )