6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 15, 2024 7:04 pm

All times are UTC




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Dec 14, 2012 8:52 pm 
Offline

Joined: Wed May 20, 2009 1:06 pm
Posts: 491
I thought this might be worth posting. This would free up your 6502 projects, save memory, free up your intererupt requests. Let me know what you think...

PS/2 Keyboard to TTL Serial Converter

Quote:
The E1115 PS/2 Keyboard to ASCII Converter is a single chip solution dedicated to producing a single TTL ASCII character on the "press" of a keystroke. It is designed to offload the process intensive complex keyboard decoding of PS/2, allowing the host microcontroller to better allocate its resources. The output is a selectable TTL serial or a clocked serial data with interrupt signal.

Plug in a PS/2 Keyboard in one end, and you can type away, with 57.6K or 115.2Kbaud (pin-selectable) TTL spit out of the TX pin. This can make adding a UI much easier for many projects where you can't sit around and wait for the interrupts from the keyboard port. Please note that we've tested it and it works great with our PS/2 keyboard but it does not work with our PS/2 Magstripe reader or the PS/2 Touchpad.

Comes as a ready-to-go pre-soldered and tested module


http://www.adafruit.com/products/1136


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 14, 2012 9:44 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
I really need to look into keyboard converters like this. Darel has a similar one at http://sbc.rictor.org/pckbavr.html, and you can download the AVR code there too. I put a PS/2 port on my workbench computer but never wrote the code for it.

I see they implemented a set delay before repeat on this one (one second) and a set repeat rate (10 per second), something I was wondering about since the feature is so convenient sometimes like for space, delete, arrow keys, etc.. What I was not able to find out with a quick read of the data sheet is whether the CTRL and ALT keys give more than a single output when you press them, ie, whether they (unlike the other keys) give you a code telling when you release them, so you can determine whether the user pressed <ALT> F for example, or pressed <CTRL> and then changed his mind, released it, then pressed F. I guess I could buy one and find out.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 14, 2012 10:41 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8490
Location: Midwestern USA
ChuckT wrote:
I thought this might be worth posting. This would free up your 6502 projects, save memory, free up your intererupt requests. Let me know what you think...

PS/2 Keyboard to TTL Serial Converter

Quote:
The E1115 PS/2 Keyboard to ASCII Converter is a single chip solution dedicated to producing a single TTL ASCII character on the "press" of a keystroke. It is designed to offload the process intensive complex keyboard decoding of PS/2, allowing the host microcontroller to better allocate its resources. The output is a selectable TTL serial or a clocked serial data with interrupt signal.

Plug in a PS/2 Keyboard in one end, and you can type away, with 57.6K or 115.2Kbaud (pin-selectable) TTL spit out of the TX pin. This can make adding a UI much easier for many projects where you can't sit around and wait for the interrupts from the keyboard port. Please note that we've tested it and it works great with our PS/2 keyboard but it does not work with our PS/2 Magstripe reader or the PS/2 Touchpad.

Comes as a ready-to-go pre-soldered and tested module

http://www.adafruit.com/products/1136

From the datasheet:

    The E1115B decodes the unshifted and shifted keys using the state of the Shift key or CapsLock key. Other control keys such as Alt, Ctrl, NumLock, and ScrollLock have no effect on the keys although outputs are produced. The CapsLock, NumLock, and ScrollLock toggle their respective indicators on the keyboard. While the CapsLock key produces no output, the NumLock and ScrollLock keys produce outputs which toggle between two values. All the non-ASCII keys on the PS/2 keyboard also produce unique codes. The E1115B allows typematic functionality where ASCII codes are repeated at a 10Hz rate when a key is held down for more than a second. The only exception to the typematic functionality is the Pause/Break key which only puts out one code when the key is held down.

Emphasis added. As can be deduced from the above, most of the modifier keys (e.g., Ctrl) effectively don't exist with this module—typing Ctrl-C, for example, would not result in the keyboard emitting an <ETX> character. Instead, you have to trap for the byte sent when the modifier key is depressed (e.g., $88 for the Ctrl key), get the code for the other key (e.g., $43 or $63 for the C key) and then change the received code to what it should be. Also, since the module doesn't have a data-in connection, it isn't possible to change the typematic rate or operate the keyboard LEDs under program control. The default typematic rate of 10 CPS is too slow in my opinion.

I think Daryl's solution using an Atmel ATTiny microcontroller is as good or perhaps better choice.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 14, 2012 10:57 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
I've also placed the converter in an ATMega8, which has a proper USART if TTL serial is desired. The ATTiny has a universal serial port but I have not tried to send async serial through it. With the Mega8, you can use parallel, serial, I2C, or SPI host interfaces easily.

Plus, since my source code is published, modifications and customization are possible.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Fri Dec 14, 2012 11:47 pm 
Offline

Joined: Wed May 20, 2009 1:06 pm
Posts: 491
BigDumbDinosaur wrote:
The default typematic rate of 10 CPS is too slow in my opinion.


500 Characters = 100 Words based on a 5 character per word average.


I don't think I can type 10 CPS per second. 10 CPS per second times 60 = 600 Characters. That would be 120 Words Per minute. Unless you type on a Dvorak keyboard, I don't think many people will type that fast.


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 1:02 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
BigDumbDinosaur wrote:
From the datasheet:

    [...] Other control keys such as Alt, Ctrl, NumLock, and ScrollLock have no effect on the keys although outputs are produced. The CapsLock, NumLock, and ScrollLock toggle their respective indicators on the keyboard. While the CapsLock key produces no output, the NumLock and ScrollLock keys produce outputs which toggle between two values. [...]

Emphasis added. As can be deduced from the above, most of the modifier keys (e.g., Ctrl) effectively don't exist with this module—typing Ctrl-C, for example, would not result in the keyboard emitting an <ETX> character. Instead, you have to trap for the byte sent when the modifier key is depressed (e.g., $88 for the Ctrl key), get the code for the other key (e.g., $43 or $63 for the C key) and then change the received code to what it should be.

What I'm wondering is if it tells you when the Ctrl key is released, or only when it is pressed, like the other ones. If the user presses <Ctrl> and then changes his mind as to what he were going to do, and continues typing with a word that starts with "c", I hope it would tell you the <Ctrl> key was released and the user doesn't really want Ctrl-C.

On the repeat speed, I don't think I would want it any slower, but I think too fast is more common than too slow.

I'll take a closer look at Daryl's with one of the synchronous-serial interfaces. Also:
8BIT wrote:
Plus, since my source code is published, modifications and customization are possible.

I like that. If all designs were published, and it should calm fears about being orphaned if something is no longer available in the future when the customer decides he wants more after having invested time or committed accompanying designs. It makes me think I should put by memory module designs on my website, the gerber views and maybe even gerber and excellon files.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 2:02 am 
Offline

Joined: Wed May 20, 2009 1:06 pm
Posts: 491
What is the source of your Datasheet? I had to go looking online and CTRL is 81 on the .pdf.

E1115 PS/2 Keyboard to ASCII Converter
http://www.chipdesign.ca/sites/default/ ... aSheet.pdf


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 2:03 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
I cut this from the header of my source code. It explains the decoding somewhat.

The nice thing is the behaviors can be modified. You can even modifiy the code to modify the keyboards parameters, using the SEND routine. On SBC-3, I used the Scroll-Lock LED to signal when the keyboard was being scanned by software, that way the user would know why his keyboard was not responding.

Since the SBC-3 AVR had two functions (keyboard decoding and RS-232 port), I modified the code to allow
multitasking between the two, as well as monitoring the SPI port for host commands. That code can be found in the SBC-3 support file, found at the bottom of this page: http://sbc.rictor.org/info3.html

Cheers!

Daryl

Code:
;/******************************************************************************/
;/  PC Keyboard decoder                                             /
;/                                                            /
;/  Designed and written by Daryl Rictor (c)2004                        /
;/******************************************************************************/
;
; All standard keys and control keys are decoded to 7 bit (bit 7=0) standard ASCII.
; Control key note: It is being assumed that if you hold down the ctrl key,
; you are going to press an alpha key (A-Z) with it (except break key defined below.)
; If you press another key, its ascii code's lower 5 bits will be send as a control
; code.  For example, Ctrl-1 sends $11, Ctrl-; sends $2B (Esc), Ctrl-F1 sends $01.
;
; The following non-standard keys are decoded with bit 7=1, bit 6=0 if not shifted,
; bit 6=1 if shifted, and bits 0-5 identify the key.
;
; Function key translation: 
;              ASCII / Shifted ASCII
;            F1 - 81 / C1
;            F2 - 82 / C2
;            F3 - 83 / C3
;            F4 - 84 / C4
;            F5 - 85 / C5
;            F6 - 86 / C6
;            F7 - 87 / C7
;            F8 - 88 / C8
;            F9 - 89 / C9
;           F10 - 8A / CA
;           F11 - 8B / CB
;           F12 - 8C / CC
;
; The Print screen and Pause/Break keys are decoded as:
;                ASCII  Shifted ASCII
;    Ctrl-Break - 02       02  (Ctrl-B) (can be changed to AE/EE)(non-repeating key) 
;     Pause/Brk - 03       03  (Ctrl-C) (can change to 8E/CE)(non-repeating key)
;      Scrl Lck - 8D       CD 
;        PrtScn - 8F       CF
;
; The Alt key is decoded as a hold down (like shift and ctrl) but does not
; alter the ASCII code of the key(s) that follow.  Rather, it sends
; a Alt key-down code and a seperate Alt key-up code.  The user program
; will have to keep track of it if they want to use Alt keys.
;
;      Alt down - A0
;        Alt up - E0
;
; Example byte stream of the Alt-F1 sequence:  A0 81 E0.  If Alt is held down longer
; than the repeat delay, a series of A0's will preceeed the 81 E0.
; i.e. A0 A0 A0 A0 A0 A0 81 E0.
;
; The special windows keys are decoded as follows:
;                           ASCII    Shifted ASCII
;        Left Menu Key -      A1          E1
;       Right Menu Key -      A2          E2
;     Right option Key -      A3          E3
;            Power Key -      A4          E4 
;            Sleep Key -      A5          E5
;             Wake Key -      A6          E6
;
;
; The following "cursor" keys ignore the shift key and return their special key code
; when numlock is off or their direct labeled key is pressed.  When numlock is on, the digits
; are returned reguardless of shift key state.       
; keypad(NumLck off) or Direct - ASCII    Keypad(NumLck on) ASCII
;          Keypad 0        Ins - 90                 30
;          Keypad .        Del - 7F                 2E
;          Keypad 7       Home - 97                 37
;          Keypad 1        End - 91                 31
;          Keypad 9       PgUp - 99                 39
;          Keypad 3       PgDn - 93                 33
;          Keypad 8    UpArrow - 98                 38
;          Keypad 2    DnArrow - 92                 32
;          Keypad 4    LfArrow - 94                 34
;          Keypad 6    RtArrow - 96                 36
;          Keypad 5    (blank) - 95                 35
;

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 3:32 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Is it easier today to stick with a PS/2 keyboard, which is a vanishing breed, vs USB? I imagine I may still have a PS/2 keyboard around here somewhere, but most are USB. I can see it being cheaper with less components than USB, but if the point is having some stock module to act in the middle, does USB make any more sense?


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 3:50 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8541
Location: Southern California
Since keyboards are cheap, I was thinking maybe I should buy several PS/2 ones while they're available. I do wear out keyboards with all my typing, and USB is not hobbyist-friendly at all. It's ok for digital cameras and other consumer items, but I hope other alternatives remain available for hobbyists.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 4:34 am 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
I think cheap ps/2 keyboards are not going to vanish so fast.
Recently while watching a video of a fancy keyboard review, it was mentioned that the usb keyboards must be pooled, while ps/2 cause interrupts, so they have faster reaction times, which is more suitable for gamers.


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 12:32 pm 
Offline

Joined: Mon Mar 02, 2009 7:27 pm
Posts: 3258
Location: NC, USA
GARTHWILSON wrote:
... I do wear out keyboards with all my typing, and USB is not hobbyist-friendly at all. It's ok for digital cameras and other consumer items, but I hope other alternatives remain available for hobbyists.

Those PS2 to USB adapters are straight-through adapters, meaning the D+ and D- signals are not special. They connect to the data and clock lines. We discussed it here not too long ago. YT2095 brought it up towards the bottom.

_________________
65Org16:https://github.com/ElEctric-EyE/verilog-6502


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 3:09 pm 
Offline

Joined: Wed May 20, 2009 1:06 pm
Posts: 491
Graham from Ditital-DIY.com put together a module using Swordfish Basic. Scroll down when you click on the link:

http://www.digital-diy.com/swordfish-mo ... bdbas.html

Swordfish Basic is used on Microchip Pics and I will inquire which PIC he is using.


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 3:22 pm 
Offline

Joined: Wed May 20, 2009 1:06 pm
Posts: 491
I received an answer back.

"It looks like he is using a 18F2520 microchip, but you could use any 18F PIC".

Swordfish basic is a free program and an 18F pic is probably less than $2 dollars. You just need a Pikit 2 or Pikit 3 to program it and there are cheap clones of the Pikit 2.


Top
 Profile  
Reply with quote  
PostPosted: Sat Dec 15, 2012 3:52 pm 
Offline
User avatar

Joined: Mon Aug 08, 2011 2:48 pm
Posts: 808
Location: Croatia
ChuckT wrote:
there are cheap clones of the Pickit 2

O.T. I bought one of them, and it works fine, but there is a weird issue that I can't run any application that uses 3D graphic(ie. games) while it is plugged in.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: