On Wed, May 24, 2017 at 1:02 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?
On Wed, May 24, 2017 at 10:10 AM, Evan Koblentz via vcf-midatlantic < vcf-midatlantic@lists.vintagecomputerfederation.org> wrote:
Thanks everyone. Interesting stuff. Here's something I do not understand. Lego's modified version of Logo has a command, COUNTER, which they say increments in tenths of a second. One of their sample programs runs the counter to 600 to give you a minute of something happening (a motor spinning). I didn't time it against a real clock, but, how could this work? The same Logo environment disk runs identically in anything from a ][+ through a GS. (My demo uses a Laser 128 as you'll recall.)
The Apple ][ and Applesoft Basic doesn't have an exact counter/timing mechanism built-in. There's only a couple of software methods available in a stock Apple ][ eg #1. For/Next loop -- you know already how to do this #2. Timer [software/Kernal Rom] I mentioned this to you before [see my old email with the sample code in Basic from 4/14/17] Even though this is still software controlled, this is incremented using the Applesoft Kernel machine code, So this is more accurate than the For/Next loop in BASIC In Zero page memory, you have 16bit binary counter, decimal 0 to 65535 at locations $4E, $4F, in basic you would use PEEK(78), PEEK(79) Then, there's the Hardware methods which include such cards as the popular Mountain Clock/Calendar card. This is just a glorified Timer with the values formatted into seconds,minutes, day,date,years, etc and with battery backup. But even if you did use that card, you still have to rely on software to keep track of the time, to keep checking the time in a software loop to find the elapsed time, either 1 sec or 10 sec. So even thought that Clock card is accurate, your added Basic code makes it less accurate. So, The Lego version of Logo is a much different beast than Applesoft Basic. The primary difference is that Lego supports Interrupts and Applesoft Basic doesn't [not without a kludge of assembly code]. Since you keep mentioning these Logo commands, I suppose you are trying this in combination with your Lego robot project using the Lego 9767 Apple card with the Lego 9750 controller box. This is also related to the SETPOWER command you mentioned a while back and there's several other Logo Timer commands. I haven't tried any programming with the Lego version of Logo on my Apple ][ yet. But I suspect this is making use of the Timer built into the 6522 chip on your Lego 9767 card. It's th eonly source of Interrupts in that Hardware. Since they have to assume you don't have a Clock/Calendar card or any other 3rd party card. And it's the only way to get accurate timing measurements using those Commands and with that card. There's the Interrupt signal pin.21 on the 6522 wired to the slot on your Apple ][. And I bet this is how they get the accurate timing measurements with the COUNTER command and the PWM Motor Speed control with the SETPOWER command. This is besides the generic Timer commands in there. I would have to install that Lego version of Logo to verify this and check it with my o'scope. But, the problem with Applesoft Basic as I mentioned above is that it does not support Interrupts. Not without a convoluted mix of assembly code to switch back and forth between your BASIC code and assembly whenever the 6502 receives an interrupt from the 6522. Because the assembly code has to keep track of your Basic code to know which line it's supposed to return and execute next. The only proper way to acknowledge and service the interrupt signal is in assembly code. I would suggest sticking with that Counter I mentioned in zero page memory at $4E,$4F -- PEEK(78), PEEK(79) Dan