keyboards
- To: MISC
- Subject: keyboards
- From: jfox@xxxxxxxxxx (Jeff Fox)
- Date: Sat, 23 Nov 1996 23:53:33 -0800
Dear MISC readers:
Andrew asks:
>Thanks for the explanations. A couple more questions, though:
>
>If a parallel input is used, how does the keyboard (or PC parallel port
>or whatever that's serving as a keyboard) signal the P21 system that
>a key has been pressed? There can't just be a parallel ascii character
>presented to the P21 system; the system must also be notified that a key
>has
>been pressed. Unless the P21 system simply looks for _changes_ in the
>input pattern, and assumes the key is released when the input pattern
>returns to all zeros or all ones on the 7 bits of parallel input... ?
When the input is sampled if P21Forth sees something other than 0
then this means a key is being pressed. Pretty simple huh?
There is a delay after a key has been pressed so keys to not repeat
too fast.
>What do you mean by "bitbanging" for serial input? Is there a
>synchronizing clock signal, or does it run at a set asynchronous rate
>such as 9600bps?
BitBang is the term used to describe doing serial without any serial
i/o hardware. You take one bit and you bang out a 0, a 1, a 0 etc.
Or you read a 0, a 1, etc. You can bit bang asynchronous serial
in which a start bit is used, or you can bit bang synchronous in
which a separate bit is used for synchronization. When you bit
bang serial input you first determine the timing from the length
of the first start bit. For this reason we usually recommend the B
(or b) key, but any key with a bit pattern that gives you a start
bit (one bit) sized pulse to start with. Once you get the timing
for a bit you time out each bit either for sampling or writing.
Since P21 has no timer or external timing reference on Dr. Ting's
boards the only timing source is a delay loop. You get the timing
for the dealy loop by reading a bit while timing. However as the
p21 heats up, or warms up etc, the timing can drift. So serial
bit bang is shakey at best.
If you add an external timing reference and read it on a bit on
the input port to get timing then you can bit bang a solidly
timed signal. This is not what P21Forth does because it was
written for Dr. Ting's board with no timing reference. The
cpu cannot see the 14mhz clock. if you add some circuitry
to feed a regular signal into P21 then you can use it as a
timing reference for bit bang. For one client we were doing
115kb on one bit, 9600 on a second bit and 4800 on a third,
all very solid, but as I have said this is not the way
P21Forth works since it does use external timing or everyone
would have had to add a bunch of extra hardware to Dr. Ting's
board to get it to work.
>I will be using the rom image "slow.rom" from the zip file "102roms.zip"
>and will be placing the resultant eprom chip in the system exactly as
>shown in the schematic in the manual. I assume this will work.
I hope so. I think you have about used up your free consulting
on Dr. Ting's board.
>> Do not try to connect a PC keyboard. First of all it uses
>> a funny clocked serial signal, and it outputs funny key codes,
>> not ascii.
>Thank you for the warning. I'll go get my trusty Apple II keyboard
>that reliably outputs simple ascii.
I used a $12 when purchased in 1971 keyboard. I don't know if an
apple II keyboard has the right polarity. I would recommend comparing
it to a PC parallel port. You do need to invert a PC parallel port
to use it as a keyboard. So in a PC Forth you need to do
KEY 7F AND 7F XOR p.port.address p!
or something like that. If your keyboard produces the same signals
you can use the P21Forth roms unmodified.
Jeff Fox