connect keyboard to serial port

This is the place for any magazine-related discussions that don't fit in any of the column discussion boards below.
Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

connect keyboard to serial port

Post by Cerf » Sun Apr 03, 2005 10:21 am

Hey,<p>I was just wondering, is there any way to connect a seccond keyboard to the rs232 port. So lets say I type an "A" on the keyboard, an "A" will appear in a program such as hyperterminal?<p>I noticed this from beyondlogic
http://www.beyondlogic.org/keyboard/keybrd.htm<p>But it talkts about connect the keyboard to a microcontroller and not the serial port.<p>Option 1:
I think that I can use some of the same techniques presented and not use a microcontroller. From what I understand, I will need a clock, a keyboard decoder, and a UART (for the serial communication). I was wondering if someone can refer me to a premade schematic if possible or a general rs232 communication schematic?<p>Option 2:
I could obtain a HC705, but I dont know how to use it or how difficult it will be to program, I would need to add a level shifter to use the rs232 but it might be easier.<p>[edit]
It looks like the HC705 is WORM, so it may not be cost effective to use it, but I do have access to a Parallax BASIC stamp 2 and board of education. Would that prove to be a better microcontroller? Is there any way to write ISRs for the basic stamp?
[/edit]<p>What do you all think, which option should I choose?<p>Thanks<p>[ April 03, 2005: Message edited by: Cerf ]<p>[ April 03, 2005: Message edited by: Cerf ]</p>

User avatar
sofaspud
Posts: 531
Joined: Wed Feb 13, 2002 1:01 am
Location: San Antonio, TX
Contact:

Re: connect keyboard to serial port

Post by sofaspud » Sun Apr 03, 2005 12:31 pm

What is this supposed to be when completed? Are you wanting hyperterminal to read in from COM1 and write out to COM2 or some such?

Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

Re: connect keyboard to serial port

Post by Cerf » Sun Apr 03, 2005 1:05 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by sofaspud:
What is this supposed to be when completed? Are you wanting hyperterminal to read in from COM1 and write out to COM2 or some such?<hr></blockquote><p>This is no school project if thats what you mean, this is just something that I want to do.<p>I am hoping the hyperterminal will read from COM1 what was typed out on the keyboard, there is no need to write anything to COM 2. It may later be neccessary to write to COM 1 to enable the caps lock led, but it is not neccessary at this point

User avatar
sofaspud
Posts: 531
Joined: Wed Feb 13, 2002 1:01 am
Location: San Antonio, TX
Contact:

Re: connect keyboard to serial port

Post by sofaspud » Sun Apr 03, 2005 2:43 pm

I dunno, Cerf. I just enable local echo to get a keystroke display on the terminal. Good luck with the project.<p>[ April 03, 2005: Message edited by: sofaspud ]</p>

Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

Re: connect keyboard to serial port

Post by Cerf » Sun Apr 03, 2005 3:16 pm

Does anyone know if a keyboard's clock signal is internal or external to the keyboard.<p>Eg, if I powering the keyboard gnd to ping 2, +5v to ping five, will there be any signal on 1 (kbd clock)? or will I have to supply the clock externally?

hp
Posts: 245
Joined: Sat Aug 09, 2003 1:01 am
Location: Friendswood, TX
Contact:

Re: connect keyboard to serial port

Post by hp » Sun Apr 03, 2005 9:59 pm

Standard AT keyboards are self clocking. They automatically send out a clock and data stream every time you hit a key. The host can send commands to the keyboard (for the num lock, caps lock, and scroll lock leds) by doing something with the clock/data line and then sending a clock signal and a data stream.<p>So in other words, keyboards are pretty complicated. Even if you do manage to get your microcontroller to read the data stream, you will need to convert the scan codes to keycodes.<p>I have managed to read in keystrokes from a keyboard. It involved waiting for a clock signal and shifting in every bit and then doing a scan code lookup. Not fun.<p>Harrison<p>[ April 03, 2005: Message edited by: hp ]</p>

Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

Re: connect keyboard to serial port

Post by Cerf » Tue Apr 05, 2005 12:59 pm

It looks like I cant get any interrupt routines on the basic stamp 2. Therefore it looks like I'm going to go the way of a 68HC705J1A single chip microcontroller. But before I make any final decision, I just wanted to ask: How is it programmed? I have a general idea, after writing the code, it is compiled, and then the code is sent to a physical device that houses the microcontroller where it is programmed. Then the microcontroller is removed and volia?<p>And there is a symbol on a schematic that I do not recognize here: http://www.beyondlogic.org/keyboard/keybrd.htm<p>just underneath where it says
<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>
The schematic below, shows the general connections of the keyboard to the HC705.
<hr></blockquote><p>there is a schematic. In this schematic on the left side there is the value "4.00". Below that value and above "Mhz" is the symbol that I do not recognize. Is that an input clock or something?<p>[edit]
Looks like the hobby shop that i buy all my electronics does not carry the HC705, and anyone suggest any replacements
[/edit]<p>[ April 05, 2005: Message edited by: Cerf ]</p>

User avatar
Dave Dixon
Posts: 436
Joined: Thu May 01, 2003 1:01 am
Location: Wichita, KS
Contact:

Re: connect keyboard to serial port

Post by Dave Dixon » Tue Apr 05, 2005 1:34 pm

That symbol is for a crystal. (4.00 Mhz). Your assumptions about programming are pretty much right-on. Write, compile, program. Good luck,
Dave
BTW If you have only one electronics shop to get your parts, it may be time to find a second source. Motorola microcontrollers aren't usually hard to locate.<p>[ April 05, 2005: Message edited by: Dave Dixon ]</p>

Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

Re: connect keyboard to serial port

Post by Cerf » Tue Apr 05, 2005 2:34 pm

if I connect a usb keyboard to a usb to serial converter cable, and I were to open up hyperterminal and type the letter "a" on the usb keyboard, will I get an "a" in the hyperterminal?<p>Does anyone know how rs232/serial communcation differ compared to usb communications?<p>To be honest, I am looking more to the programming then the electrionics aspect of this project

User avatar
sofaspud
Posts: 531
Joined: Wed Feb 13, 2002 1:01 am
Location: San Antonio, TX
Contact:

Re: connect keyboard to serial port

Post by sofaspud » Tue Apr 05, 2005 6:54 pm

My recollection is a little fuzzy, but I would say the answer to your first question is Yes. If local echo is not disabled, the keystroke should be echoed to the monitor.
An even more basic answer for your second question... RS-232 is 8 or 9 lines which include Request To Send, Clear To Send, Data Terminal Ready, Data Set Ready, etc. Not all are needed in every application. USB is only Power and Ground with 1 or 2 data lines. They're both serial, but all the differences could probably fill a book.

hp
Posts: 245
Joined: Sat Aug 09, 2003 1:01 am
Location: Friendswood, TX
Contact:

Re: connect keyboard to serial port

Post by hp » Tue Apr 05, 2005 10:35 pm

You won't be able to connect a USB Keyboard directly to a USB to Serial adapter. It would be very expensive if you wanted to take that route, because it would require a USB host chipset plus a bunch of other stuff to support the serial converter's propreitary communications protocol.<p>The best way is just to use a simple microcontroller. I really doubt you will need to use interrupts unless you really need fast / immediate response to your typed keys. A simple loop to watch for a clock line state change should be good enough.<p>I am guessing that this is possible with the basic stamp. I would not go with the motorola processor unless you are well versed in the way of asm and interrupts for that specific processor.<p>Harrison

User avatar
sofaspud
Posts: 531
Joined: Wed Feb 13, 2002 1:01 am
Location: San Antonio, TX
Contact:

Re: connect keyboard to serial port

Post by sofaspud » Wed Apr 06, 2005 1:57 pm

From looking at usbgear.com, it appears there are a lot of products to connect RS-232 devices to a USB port, but none to connect USB devices to a RS-232 port. Not that it's impossible, just too rarely needed.

User avatar
jollyrgr
Posts: 1289
Joined: Thu Jan 03, 2002 1:01 am
Location: Northern Illinois
Contact:

Re: connect keyboard to serial port

Post by jollyrgr » Wed Apr 06, 2005 4:29 pm

This can be done and there is a commerical product available to do this. See here:<p>http://l3sys.eskimo.net/kb232/<p>While somewhat expensive ($79) all the work has already been done for you.<p>
From a design perspective it can be done "home grown" if you want. I have connected devices to RS 232 ports. But I used a freeware program called a "keyboard wedge" to get the data from the serial port to the keyboard signal. Basically it is a program that constantly scans the choosen port (Com 1, for example) and copies the ASCII data on that port into the keyboard memory location. The version I used was freeware and was a TSR program that ran under DOS. Basically you put a call into AUTOEXEC.BAT such as LOAD C:\KEYWGE.EXE /COM1 and this would activate the program. Unforunately this did not work under anything like Windows NT 4.0 and higher. I've not seen a free program for these guys.<p>Can you directly connect a PS/2 Keyboad to an RS 232 connector? No; you need to switch the voltage levels using an RS232 to/from TTL circuit. Here are some examples:
http://www.piclist.com/techref/io/serial/ttl-rs232.htm<p>As others have suggested you might be far easier getting an RS232 to USB converter and go from there. There are plenty of commercial adapters to connect a computer USB port and turn it into an RS232 port. Going the other way is much more rare.
No trees were harmed in the creation of this message. But billions of electrons, photons, and electromagnetic waves were terribly inconvenienced!

Cerf
Posts: 20
Joined: Mon Mar 28, 2005 1:01 am
Contact:

Re: connect keyboard to serial port

Post by Cerf » Wed Apr 06, 2005 4:38 pm

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by Jolly Roger:
This can be done and there is a commerical product available to do this. See here:<p>http://l3sys.eskimo.net/kb232/<p>While somewhat expensive ($79) all the work has already been done for you.<p><hr></blockquote><p>That is exactly what I want to build, but I am not going to buy it. I'm going to try using a usb to rs232 adapter and move on from there

wd5gnr
Posts: 104
Joined: Wed Dec 19, 2001 1:01 am
Contact:

Re: connect keyboard to serial port

Post by wd5gnr » Wed Apr 06, 2005 8:48 pm

I know you want to build it yourself, but just for the record: coprocessor. There is also a link to a board-level version on that page.

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests