From 545e1d2d9991c4209c3deb833a6ddcdabffd0e51 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 13 Jun 2018 09:43:27 -0400 Subject: [PATCH] First version; a quick note on Apple II analogue inputs. --- Apple-II-style-analogue-inputs.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Apple-II-style-analogue-inputs.md diff --git a/Apple-II-style-analogue-inputs.md b/Apple-II-style-analogue-inputs.md new file mode 100644 index 0000000..759f5b3 --- /dev/null +++ b/Apple-II-style-analogue-inputs.md @@ -0,0 +1,11 @@ +There is one capacitor per input. + +If you access `C070` then all the input capacitors will be allowed to start charging. Each analogue input at `C064` to `C067` will then read b7=1 until its corresponding capacitor has fully charged. Upon any capacitor becoming fully charged, the corresponding b7 will change to 0 and the capacitor will begin to discharge. + +Discharges take 250ns, less than a processor cycle. + +Charges take an amount of time proportional to the analogue input; the built-in routine `PREAD` is implemented so that 2.82ms is assumed to be the longest the capacitor might want to charge, and integer values between 0 and 255 are spread linearly across the time range. E.g. a value of 64 implies approximately 1/4 of 2.82ms passed. + +So the only caveat is that you can't inherently assume whether each capacitor is already charging when you access `C070`. If it is, it will be fully charged sooner than the input suggests it should be. + +The workaround is either to check whether the channels you're interested in are charging before triggering `C070`, or else just leave a long enough period for your application between accesses. With paddles and joysticks, any period longer 2.82ms should do. \ No newline at end of file