keyboard to BS2
Archiver
Posts: 46,084
hello
Could anyone please point me in the right direction as to how to read
from a pc keyboard with 5-pin DIN to my BS2?
All help greatly appreciated.
Could anyone please point me in the right direction as to how to read
from a pc keyboard with 5-pin DIN to my BS2?
All help greatly appreciated.
Comments
>hello
>
>Could anyone please point me in the right direction as to how to read
>from a pc keyboard with 5-pin DIN to my BS2?
>
>All help greatly appreciated.
This is the easiest way to do it:
http://www.al-williams.com/pak6.htm
Regards,
Bruce Bates
The PAK-VI would be ideal but I have just a couple of days, so I
think I need to tackle this by wiring directly to the DIN. Has anyone
tried this?
-Dave.
--- In basicstamps@yahoogroups.com, Bruce Bates <bvbates@u...> wrote:
> At 07:03 PM 5/24/04 +0000, dterryr2000 wrote:
> >hello
> >
> >Could anyone please point me in the right direction as to how to
read
> >from a pc keyboard with 5-pin DIN to my BS2?
> >
> >All help greatly appreciated.
>
> This is the easiest way to do it:
> http://www.al-williams.com/pak6.htm
>
> Regards,
>
> Bruce Bates
on its own. The keyboard produces a clock so the Stamp must be listening for
it all the time and must keep up, both of what it can't do.
I have seem someone connect a keyboard to the Stamp with a hardware shift
register, but it was a lot of work. Even then you get the raw key codes and
not ASCII input, so factor in a lot of software to look at things like:
Shift-Down "a"-down "a"-up (upper case A).
Shift-Up Control-Down "a"-down "a"-up (Control+A)
Etc.
As anyone on the list will tell you, if I knew of another way to do it, I'd
tell you.
Regards,
Al Williams
AWC
http://www.awce.com
Original Message
From: dterryr2000 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=4m2ryYdGRj_QmYYf-h6R3--zeEwzYAQl_WRwa2S5F9Gj_aj00RV6t1rWGtlfJBZdNk3VaR68HumdUDOmvn0c]dterryr2000@y...[/url
Sent: Monday, May 24, 2004 3:23 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: keyboard to BS2
Thanks Bruce.
The PAK-VI would be ideal but I have just a couple of days, so I
think I need to tackle this by wiring directly to the DIN. Has anyone
tried this?
-Dave.
--- In basicstamps@yahoogroups.com, Bruce Bates <bvbates@u...> wrote:
> At 07:03 PM 5/24/04 +0000, dterryr2000 wrote:
> >hello
> >
> >Could anyone please point me in the right direction as to how to
read
> >from a pc keyboard with 5-pin DIN to my BS2?
> >
> >All help greatly appreciated.
>
> This is the easiest way to do it:
> http://www.al-williams.com/pak6.htm
>
> Regards,
>
> Bruce Bates
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Yahoo! Groups Links
>hello
>
>Could anyone please point me in the right direction as to how to read
>from a pc keyboard with 5-pin DIN to my BS2?
The following is some PBP code originally written by Daryl Owens, then
modified by someone else. While it targets a PIC directly via PBP, I
*think* that it should work with a BS2.
dwayne
Keyboard_Clock Var PortB.1
Key_Clock_Tris Var TrisB.1
Keyboard_Data Var PortB.0
Keypress var byte 'Keyboard code value read from keyboard
AscKey var byte 'This is used to send key scan data and subroutine controls
to other subroutines
TempReg var byte 'Misc temp register
Temp2Reg var byte 'Misc temp register
ShiftReg var bit 'Stores the shift key status. 1=shift 0=no shift
DumpReg var bit 'Temp reg for dumping keypress values after a release
command
Key Var Byte 'Actual key
ShiftReg = 0
LCDOUT $FE,1, " Creative Automation "
Pause 1000
LCDOUT $FE,1, " Keyboard Tester "
Pause 1000
LCDOUT $FE,1
ScanKeys:
Gosub ScanKeyboard 'Gets key pressed keycode
Gosub ChrtoASCII 'Changes keycode into ascii
Gosub UpdateLCD
Goto ScanKeys 'Goto your mainloop overhere
ScanKeyboard:
DumpReg = 0
DumpKeys:
KeyPress = 0
Key_Clock_Tris = 1 : Keyboard_Clock = 1 'Release Clock Line for Com
from Keyboard to PIC
Gosub ClockCycle 'Dumps start bit
For TempReg = 0 to 7
Gosub ClockCycle
If Keyboard_Data = 1 Then 'Calculates bit value
Lookup TempReg,[noparse][[/noparse]1,2,4,8,16,32,64,128],Temp2Reg
KeyPress = KeyPress + Temp2Reg 'Adds the bit values together
Endif
Next TempReg
Gosub ClockCycle 'Dumps parity bit
Gosub ClockCycle 'Dumps stop bit
Key_Clock_Tris = 0 : Keyboard_Clock = 0 'Set Clock Line Low and hold
Com from Keyboard to PIC
If KeyPress = $F0 Then 'If key release command then go again
DumpReg = 1 'Set so that next key will also get dumped
Goto DumpKeys 'Rerun loop
Endif
If Keypress=$12 || Keypress=$59 && DumpReg = 1 Then 'Turn off ShiftReg
ShiftReg = 0 'Sets the Shift Reg for Shift
Endif
If DumpReg = 1 Then 'If this loop was to dump chr then send a 255 to
next
DumpReg = 0
KeyPress = 255
Endif
If Keypress=$12 || Keypress=$59 Then 'Turn on ShiftReg
ShiftReg = 1 'Sets the Shift Reg for Shift
Endif
'If keypress=255 then
' key=255 'null key variable out between
keystrokes
'endif
Return
UpdateLCD:
If AscKey <> 255 Then 'Skip routine if not an ascii key
LCDOUT $FE,1
LCDOUT $FE,2, Key," ASCII= ",dec3 Key
LCDOUT $FE,$c0,"Code= ", Dec3 Keypress," Shift=", Dec2 shiftReg
'Code is the keyboard code
Endif
Return
ClockCycle: 'Waits for the clock to cycle from keyboard
HoldClockLow:
If Keyboard_Clock = 0 Then HoldClockLow
HoldClockHi:
If Keyboard_Clock = 1 Then HoldClockHi
Return
ChrtoASCII: 'Converts keycode into ASCII
AscKey = 255
If KeyPress=$66 then 'Backspace
'do something
LCDOUT $FE,1,"Backspace" 'For fun
Return
Endif
If KeyPress=$5A then 'Enter Key
'do something
LCDOUT $FE,1,"Enter"
Return
Endif
If KeyPress=$72 then 'Down Arrow
'do something
LCDOUT $FE,1,"Down Arrow"
Return
Endif
If KeyPress=$75 then 'Up Arrow
'do something
LCDOUT $FE,1,"Up Arrow"
Return
Endif
If KeyPress=$74 then 'Right Arrow
'do something
LCDOUT $FE,1,"Right Arrow"
Return
Endif
If KeyPress=$6B then 'Left Arrow
'do something
LCDOUT $FE,1,"Left Arrow"
Return
Endif
If KeyPress=$0D then 'Tab
'do something
LCDOUT $FE,1,"Tab"
Return
Endif
If KeyPress=$76 then 'Escape
'do something
LCDOUT $FE,1,"Escape"
Return
Endif
Lookdown
Keypress[noparse][[/noparse]69,22,30,38,37,46,54,61,62,70,28,50,33,35,36,43,52,51,67,59,66,75,5
8,49,68,77,21,45,27,44,60,42,29,34,53,26,41,78,85,93,84,91,76,82,65,73,74,14
],AscKey
If shiftReg=0 then
Lookup
AscKey,[noparse]/noparse]"0123456789abcdefghijklmnopqrstuvwxyz -=\[noparse][[/noparse;',./`"],Key
Else
Lookup AscKey,[noparse][[/noparse]"-(ABCDEFGHIJKLMNOPQRSTUVWXYZ
_+|{}:'<>?~"],Key
Endif
Return
--
Dwayne Reid <dwayner@p...>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.
to get things up and running...
I have interfaced a UNIX/Sun keyboard directly to a Stamp without
much software overhead... 1200 baud
The 3 byte overhead looks something like
M L M L M L
S S S S S S
B B B B B B
0xxxxxxx 1xxxxxxx 10000000
1st Byte 2nd Byte 3rd Byte
Where x = the "keyboard scan value"
When a key is pressed, the first byte is sent.
When a key is released, the second & third bytes are sent.
Since the Press/Release Data is contained in the
First and Second Byte, I ignored the Third Byte
and haven't had any trouble.
The numbers returned are consecutive corresponding to
the number or letter, so simple additive or subtractive
logic can be applied to produce ASCII, rather than a
lookup table.
>To the best of my knowledge, the Stamp is simply not fast enough to do this
>on its own. The keyboard produces a clock so the Stamp must be listening for
>it all the time and must keep up, both of what it can't do.
>
>I have seem someone connect a keyboard to the Stamp with a hardware shift
>register, but it was a lot of work. Even then you get the raw key codes and
>not ASCII input, so factor in a lot of software to look at things like:
>
>Shift-Down "a"-down "a"-up (upper case A).
>Shift-Up Control-Down "a"-down "a"-up (Control+A)
>Etc.
>
>As anyone on the list will tell you, if I knew of another way to do it, I'd
>tell you.
>
>Regards,
>
>Al Williams
>AWC
>http://www.awce.com
>
>
>Thanks Bruce.
>
>The PAK-VI would be ideal but I have just a couple of days, so I
>think I need to tackle this by wiring directly to the DIN. Has anyone
>tried this?
>
>-Dave.
>
> > >
> > >Could anyone please point me in the right direction as to how to
>read
> > >from a pc keyboard with 5-pin DIN to my BS2?
> > >
> > >All help greatly appreciated.
> >
> > This is the easiest way to do it:
> > http://www.al-williams.com/pak6.htm
> >
> > Regards,
> >
> > Bruce Bates
>
>
Beau Schwabe Mask Designer II National Semiconductor Corporation
500 Pinnacle Court, Suite 525
Mail Stop GA1
Yes, with a 1200 baud serial keyboard this would not be an issue. But I
think the original question was for a PS/2 or AT keyboard. The clocks on
these vary, but even the slowest is probably too fast for the Stamp.
The keyboards I've seen like this are known as "Sun type 5".
Al Williams
AWC
*Kits: http://www.awce.com/kits.htm
Original Message
From: Beau Schwabe [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ksHGChZDCcsUW0uxUW6_JNstwye1ce-zk3pZasFqrB9sTm6IToch3NDFz7Pa_mFVX0jK2qvdUUOz-0i7gsA]bschwabe@a...[/url
Sent: Monday, May 24, 2004 3:54 PM
To: basicstamps@yahoogroups.com
Subject: RE: [noparse][[/noparse]basicstamps] Re: keyboard to BS2
If you can find a serial keyboard this might be a "quick" solution to get
things up and running...
I have interfaced a UNIX/Sun keyboard directly to a Stamp without much
software overhead... 1200 baud
The 3 byte overhead looks something like
M L M L M L
S S S S S S
B B B B B B
0xxxxxxx 1xxxxxxx 10000000
1st Byte 2nd Byte 3rd Byte
Where x = the "keyboard scan value"
When a key is pressed, the first byte is sent.
When a key is released, the second & third bytes are sent.
Since the Press/Release Data is contained in the
First and Second Byte, I ignored the Third Byte
and haven't had any trouble.
The numbers returned are consecutive corresponding to
the number or letter, so simple additive or subtractive
logic can be applied to produce ASCII, rather than a
lookup table.
>To the best of my knowledge, the Stamp is simply not fast enough to do
>this on its own. The keyboard produces a clock so the Stamp must be
>listening for it all the time and must keep up, both of what it can't
>do.
>
>I have seem someone connect a keyboard to the Stamp with a hardware
>shift register, but it was a lot of work. Even then you get the raw key
>codes and not ASCII input, so factor in a lot of software to look at
>things like:
>
>Shift-Down "a"-down "a"-up (upper case A).
>Shift-Up Control-Down "a"-down "a"-up (Control+A)
>Etc.
>
>As anyone on the list will tell you, if I knew of another way to do it,
>I'd tell you.
>
>Regards,
>
>Al Williams
>AWC
>http://www.awce.com
>
>
>Thanks Bruce.
>
>The PAK-VI would be ideal but I have just a couple of days, so I think
>I need to tackle this by wiring directly to the DIN. Has anyone tried
>this?
>
>-Dave.
>
> > >
> > >Could anyone please point me in the right direction as to how to
>read
> > >from a pc keyboard with 5-pin DIN to my BS2?
> > >
> > >All help greatly appreciated.
> >
> > This is the easiest way to do it:
> > http://www.al-williams.com/pak6.htm
> >
> > Regards,
> >
> > Bruce Bates
>
>
Beau Schwabe Mask Designer II National Semiconductor Corporation
500 Pinnacle Court, Suite 525
Mail Stop GA1
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Yahoo! Groups Links
Agreed, however since it appears that this guy is just
starting out in the thought process of how things will
come together, I thought I would throw in an alternate
option that may or may not be doable.
>Hi Beau,
>
>Yes, with a 1200 baud serial keyboard this would not be an issue. But I
>think the original question was for a PS/2 or AT keyboard. The clocks on
>these vary, but even the slowest is probably too fast for the Stamp.
>
>The keyboards I've seen like this are known as "Sun type 5".
>
>Al Williams
>AWC
>*Kits: http://www.awce.com/kits.htm
>
>
>
Beau Schwabe Mask Designer II National Semiconductor Corporation
500 Pinnacle Court, Suite 525
Mail Stop GA1