Re: [vcf-midatlantic] Computing time in BASIC
There was a whole industry in 8bit times selling clock cards with batteries. I have also seen replacement chips with clock/batteries on them. Not sure what specifically was used for your machine to accomplish this but that's one thing you can do, IF the clock writes to a memory location that BASIC can then access. Poor man's alternative, use a stopwatch and run the program. Have an on-screen counter running that shoes your program loop counter maybe a space bar to force a stop. Eventually you'll find the best method to accomplish. Help? Bill Degnan twitter: billdeg vintagecomputer.net On May 24, 2017 1:03 AM, "Evan Koblentz via vcf-midatlantic" < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote: Suppose I want an Applesoft (Microsoft) BASIC program to do something for a certain amount of time as measured in seconds or minutes. FOR-NEXT loops don't align to any real increment -- they just count based on how fast the processor can go, right? If so, then how do you make something happen for a time amount? ------------------------- Evan Koblentz, director Vintage Computer Federation A 501(c)3 educational non-profit Evan@vcfed.org (646) 546-9999 www.vcfed.org facebook.com/vcfederation twitter.com/vcfederation
three ways come to mind to do timing. one is the brute force FOR..NEXT loop, which of course is completely dependent on CPU speed and generally non-portable. As Bill says use a stopwatch! In the world of Heathkit (and probably many others) there's a "heartbeat" interrupt that occurs every 2 milliseconds. You can use this to count interrupts and very accurately measure time. This is more portable (at least within the Heath ecosystem) and is generally independent of CPU speed. A popular Heath hack was to use the H8 front panel LEDs to show a real time clock using this technique. If you have a hardware clock/calendar chip or board you can read the clock and count out time that way (usually via direct Port I/O or possibly memory mapped I/O). This is most useful for longer time periods (minutes or hours) as the clock resolution may or may not be very fine grained (some simply count seconds). Most such clock cards can be configured to be interrupt driven as well. hope this helps. - Glenn Roberts On Wed, May 24, 2017 at 7:36 AM, william degnan via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
There was a whole industry in 8bit times selling clock cards with batteries. I have also seen replacement chips with clock/batteries on them. Not sure what specifically was used for your machine to accomplish this but that's one thing you can do, IF the clock writes to a memory location that BASIC can then access.
Poor man's alternative, use a stopwatch and run the program. Have an on-screen counter running that shoes your program loop counter maybe a space bar to force a stop. Eventually you'll find the best method to accomplish.
Help?
Bill Degnan twitter: billdeg vintagecomputer.net On May 24, 2017 1:03 AM, "Evan Koblentz via vcf-midatlantic" < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
Suppose I want an Applesoft (Microsoft) BASIC program to do something for a certain amount of time as measured in seconds or minutes.
FOR-NEXT loops don't align to any real increment -- they just count based on how fast the processor can go, right?
If so, then how do you make something happen for a time amount? ------------------------- Evan Koblentz, director Vintage Computer Federation A 501(c)3 educational non-profit
Evan@vcfed.org (646) 546-9999
www.vcfed.org facebook.com/vcfederation twitter.com/vcfederation
Some languages have a function called 'sleep()' or similar where you can tell it to pause for a period of time. don't recall if basic has something like that or not -----Original Message----- From: vcf-midatlantic [mailto:vcf-midatlantic-bounces@lists.vintagecomputerfederation.org] On Behalf Of Glenn Roberts via vcf-midatlantic Sent: Wednesday, May 24, 2017 8:52 AM To: vcf-midatlantic Cc: Glenn Roberts Subject: Re: [vcf-midatlantic] Computing time in BASIC three ways come to mind to do timing. one is the brute force FOR..NEXT loop, which of course is completely dependent on CPU speed and generally non-portable. As Bill says use a stopwatch! In the world of Heathkit (and probably many others) there's a "heartbeat" interrupt that occurs every 2 milliseconds. You can use this to count interrupts and very accurately measure time. This is more portable (at least within the Heath ecosystem) and is generally independent of CPU speed. A popular Heath hack was to use the H8 front panel LEDs to show a real time clock using this technique. If you have a hardware clock/calendar chip or board you can read the clock and count out time that way (usually via direct Port I/O or possibly memory mapped I/O). This is most useful for longer time periods (minutes or hours) as the clock resolution may or may not be very fine grained (some simply count seconds). Most such clock cards can be configured to be interrupt driven as well. hope this helps. - Glenn Roberts On Wed, May 24, 2017 at 7:36 AM, william degnan via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
There was a whole industry in 8bit times selling clock cards with batteries. I have also seen replacement chips with clock/batteries on them. Not sure what specifically was used for your machine to accomplish this but that's one thing you can do, IF the clock writes to a memory location that BASIC can then access.
Poor man's alternative, use a stopwatch and run the program. Have an on-screen counter running that shoes your program loop counter maybe a space bar to force a stop. Eventually you'll find the best method to accomplish.
Help?
Bill Degnan twitter: billdeg vintagecomputer.net On May 24, 2017 1:03 AM, "Evan Koblentz via vcf-midatlantic" < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
Suppose I want an Applesoft (Microsoft) BASIC program to do something for a certain amount of time as measured in seconds or minutes.
FOR-NEXT loops don't align to any real increment -- they just count based on how fast the processor can go, right?
If so, then how do you make something happen for a time amount? ------------------------- Evan Koblentz, director Vintage Computer Federation A 501(c)3 educational non-profit
Evan@vcfed.org (646) 546-9999
www.vcfed.org facebook.com/vcfederation twitter.com/vcfederation
On Wed, May 24, 2017 at 9:12 AM, W2HX via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
Some languages have a function called 'sleep()' or similar where you can tell it to pause for a period of time. don't recall if basic has something like that or not
I think for Evan's case, which is a 6502 processor using BASIC you have to work within that boundary to answer his question efficiently. Also, there are many ways to do the same thing in BASIC. If you put an on-screen display like this 100 input t "hit space bar and stopwatch simultaneously to start" 150 if spacebar pressed then 200 process starts 300 ...... 400 ...... 449 print "GET READY...." 450 process ends 500 print "HIT STOP ON STOPWATCH!" 600 clear screen and goto 100
Commodore (as an example) has a built-in real-time clock, sort of. I have used it for keeping time in games and such. Perhaps someone who knows machine language (not me, I wish) can take a look at the Commodore Kernel code for that function and write a similar routine for the Apple. A thought, they are both 6502. On Wed, May 24, 2017 at 8:51 AM, Glenn Roberts via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
three ways come to mind to do timing. one is the brute force FOR..NEXT loop, which of course is completely dependent on CPU speed and generally non-portable. As Bill says use a stopwatch!
In the world of Heathkit (and probably many others) there's a "heartbeat" interrupt that occurs every 2 milliseconds. You can use this to count interrupts and very accurately measure time. This is more portable (at least within the Heath ecosystem) and is generally independent of CPU speed. A popular Heath hack was to use the H8 front panel LEDs to show a real time clock using this technique.
If you have a hardware clock/calendar chip or board you can read the clock and count out time that way (usually via direct Port I/O or possibly memory mapped I/O). This is most useful for longer time periods (minutes or hours) as the clock resolution may or may not be very fine grained (some simply count seconds). Most such clock cards can be configured to be interrupt driven as well.
hope this helps.
- Glenn Roberts
On Wed, May 24, 2017 at 7:36 AM, william degnan via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
There was a whole industry in 8bit times selling clock cards with batteries. I have also seen replacement chips with clock/batteries on them. Not sure what specifically was used for your machine to accomplish this but that's one thing you can do, IF the clock writes to a memory location that BASIC can then access.
Poor man's alternative, use a stopwatch and run the program. Have an on-screen counter running that shoes your program loop counter maybe a space bar to force a stop. Eventually you'll find the best method to accomplish.
Help?
Bill Degnan twitter: billdeg vintagecomputer.net On May 24, 2017 1:03 AM, "Evan Koblentz via vcf-midatlantic" < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
Suppose I want an Applesoft (Microsoft) BASIC program to do something for a certain amount of time as measured in seconds or minutes.
FOR-NEXT loops don't align to any real increment -- they just count based on how fast the processor can go, right?
If so, then how do you make something happen for a time amount? ------------------------- Evan Koblentz, director Vintage Computer Federation A 501(c)3 educational non-profit
Evan@vcfed.org (646) 546-9999
www.vcfed.org facebook.com/vcfederation twitter.com/vcfederation
participants (4)
-
Chris Fala -
Glenn Roberts -
W2HX -
william degnan