Jump to content
Electronics-Lab.com Community

RS232 to keyboard converter


Recommended Posts

hi everybody

I have written a C++ application for sending RS232 serial data in single PC and I want the data to be received on another PC and captured as keystrokes. These keystrokes can then be used in any window’s word applications and appeared as though they are typed from the keyboard.

I have also coded the program such that for each ASCII character, it is converted into it’s corresponding set of scancode. For example,’a’ is translated into IC FO IC and sends as string “ICF0IC” over the serial link. This ensures the scancode is correctly interpreted by the keyboard controller on the receiver’s side PC.

However I do not know how to go about implementing a hardware device that can achieve the conversion of RS232 data to keyboard data.

Link to comment
Share on other sites


sorry.below will be a clearer explanation of my project
-----------------------------------------------------------------------

I have written a C++ application for sending RS232 serial data in single PC and I want the data to be received on another PC and captured as keystrokes. These keystrokes can then be used in any window’s word applications and appeared as though they are typed from the keyboard.

I have also coded the program such that for each ASCII character, it is converted into it’s corresponding set of scancode. For example,’a’ is translated into IC FO IC and sends as string “ICF0IC” over the serial link. This ensures the scancode is correctly interpreted by the keyboard controller on the receiver’s side PC.

However I do not know how to go about implementing a hardware device that can achieve the conversion of RS232 data to keyboard data.


Link to comment
Share on other sites

Sorry but i will repeat,you will say if i understood right.
You have two PCs, A and B. On every PC you have a soft. This soft send data to RS port, for example, if you have "Hello" your soft will send characters H,E,L,L,O.
The receiver soft will capture this characters and will use for something.

Now,
1.  You want to put hardware device between PC, that will coding sending data. When this device receive "A" will send "IC F0 IC".

Or ....
2. The first PC send data in this coding, "a" to "IC F0 IC" ..... and the hardware device must receive this data and convert it to standard PS2 protocol and send this data to keyboard on the second PC.

Link to comment
Share on other sites

OK,
now i have some more questions:
1. the first PC make a coding in to PS2 format or just make this coding to protect the data.
2. How long is the cable between PC, if distances is more that 2-3 meters, then you can have a problem.

The conversion can do with a microcontller,:PIC, Atmel etc, or with logic, i talk about CPLD, but if you like the challenge can make this with TTL ;). I will suggest microcontroller, but CPLD is also good solution.

Link to comment
Share on other sites

hi Tom and the rest,

Ans1: the first PC make a coding in to PS2 format. That means i just code it to send 'a' as "ICF01C" instead. So its like sending PS/2 keyboard data scancode.

Ans2: the cables shouldnt be more than 2 metres..the 2 PCs are side by side only.

Qn1: i am not familiar with microcontroller..Actually,i thought i could just implement the circuit using normal IC chips and some FFs as what i uploaded in the schematic.Can i use some simple circuit instead, and can help me to find out if i can build something similar to my schematic?

thanks

Link to comment
Share on other sites

Hi,
yes, of course you can use standard IC but this will be very big and complex circuit diagram. I prefer to use the microcontrollers. I am have no a complete driver for a PS2 keyboard, but can ask some friend.
If this is your software, i can suggest something other, why dont use RTS/CTS signal to generate directly PS2 stream, and then you put only one MAX232 to convert the signal, but actually MAX is not need, the optocoupler will be OK.

p.s. i not have any PC with the PS/2 input, i use the notebooks, and this is the problem, i can't test the soft, in other case i can write this soft for you.

Link to comment
Share on other sites

Hi,
i find 20 minutes and made something for you, but i can't test because have not the PS2. I use PIC16F628, below you can find the HEX, and asm.
PIN 7 is the recive form MAX232
PIN 17 is the Clock
PIN 18 is the Data
Tomorrow, i try to find a time to draw the schecm, but this is standard PIC, MCLR pin to +5 via 2 kOm. Use 20 Mhz quartz with 18 pF capacitor to ground. And nothing more. If this is god for you, i

Serial_to_PS2.rar

Link to comment
Share on other sites

hi tony,

i greatly appreciate what you have come up so far.its an interesting project which have wide applications.Just that now i am stuck with the hardware..and the conversion of RS232 data stream to PS2 is giving me lots of headache.

Qn1: As what you said, i can use RTS/CTS signal to generate directly PS2 stream? How is that possible.. i am sending RS232 stream from transmitter.

P.S: i will be most grateful if you could have a drawing schematic to guide me along..

thanks


regards
junwei

Link to comment
Share on other sites

Hi tony,

I really appreciate yur assistance.Before i jump into real discussion on what you have given me for the schematic..i will like to show you a full summary attachment of my project and what i have come up with so far.

The commercial product is close to what i wanted to built for the hardware interface circuit. In fact, i wanted to use pure logic (logic gates,CMOS,TTL,74's series etc) to build the hardware interface as i am not very familiar with PLL and microcontroller.Is there a way to use pure logic in this case?

thanks a lot

application.zip

Link to comment
Share on other sites

Hi,
you want to produce this device, this is right. If i am right, then you have a need from :
1. Low price
2. EMC certification
3. Reliability
4. Easy to use and compatibility to another devices

1. Low price, this depend from size and numbers of components. For example one microcontroller have a price around 2$, i talk about controller with integrate RS. If you make this with a TTL and CMOS circuit, you will need no less that 10 chips. The price of this chips is may be equal or high that price of a microcontroller. On the other hand for this chips you need 10 time more space, the board will be 10 time expensive.
2. 10 TTL chips have a high EMI vs one microcontroller
3. 10 TTL have around 10 time low reliability
4. With TTL you can realise simple conversion, but my suggestion is to convert ASCI in this hardware device, not in the PC, because if you want to use simple hyper terminal you can't. You can put jumper, or software configuration on the microcontroller version, that will control type of data, simple ASCI or already converted data.

I can give you many other reasons to using the microcontroller, my business is this, to design the device and consultation for my client how they can improve the products. If you still want i can think around TTL version, but this is will be a complex schem, and i don't sure that will have a time to make this for you.

Link to comment
Share on other sites

Personally, I think you are going in a large circle. If you are reading the code in the Terminal of the second PC, then you do not need hardware to do something with it. You only need to know how to write your code in a way that PC #2 will do something with this input as if you pressed a key on the keyboard. This is not done at the keyboard level. It is done on a higher level. You already have the input. You just need to learn how to write the program proficiently. Using some kind of additional hardware will probably achieve the goal, but it is not needed for this task. You are closer than you think. You should consult with someone who is good at this type of coding with C. You should be able to find this on a computer code forum. Members of this forum will be more familiar with making some type of electronic hardware for the same purpose. Basically, you are asking this question on the wrong website.
I mean this post as encouragement and wish you the best of luck on this project.

MP

Link to comment
Share on other sites

hi,

I am exploring various ways to get data across to 2nd PC terminal.
I have tried the software method.I have written a software at the 2nd PC to retrieve the data and upload to any active window.IT has been sucessful.

Now i am exploring the method to get RS232 data across to 2nd PC using a hardware method.that is RS232(PC)->PS/2(PC). This wil then create a hardware device independent of operating system and also save the trouble to build a software in the 2nd PC.



Link to comment
Share on other sites

hi tony,

I will appreciate if i can built the hardware interface by using pure logic TTL/CMOS etc..I am not familiar with microncontroller at all.

as i want the keyboard freq to be between 10k-20khz. Can i set the baud rate for my RS232 data to be within the range and then sent it down the serial link?

Then i just need to add another clock(10k-20khz) to synchronize with the incoming RS232 data.But i am not sure about if this will work.


i wanted the RS232 protocol to work as keyboard protocol so that the keyboard controller at the 2nd PC can receive and interpret the scancode correctly.

thanks

regards

Link to comment
Share on other sites

Hi Tony,

1. If  I send the string “1CF01C” for ASCII character ‘a’ from the 1st PC, will I be sending the correct sequence of bits from LSB to MSB so that the keyboard controller at the 2nd PC will treat the string as a set of scancode?

2. If I do set the baud to be between10kbps-20kbps from the PC software, I will then be able to generate RS232 data at a rate similar to a typical keyboard clock frequency. If the data is passed through a MAX232 chip, it can then be converted it into a TTL/CMOS 0-+5v data to be used as keyboard data. Is my concept so far correct?

3. So at this stage, my main concern is to synchronize the PS/2 clock to the data so that they can be transmitted and correctly interpreted by the keyboard controller at the 2nd PC?


Thanks

Regards

Link to comment
Share on other sites

Hi,
i will try to make some simple, only with logic, but if look for a simple schem, then you must know that have a very big possibility to wrong data transfer. The most simple is if you have the clock generator, when detect start bit will starting sampling on every clock impulse, and this sample will be transfer to the PS2 port. 

Link to comment
Share on other sites

Hi,
pleasesee the attachment.
I not have a time to real test this circuit, i made only computer simulation.
Tx is the input, you must have MAX232 befor this schem or some other level converter.
Xtal is input for sampling, this can be on chip generator, or simple quartz generator whit invertor, the frequency must be exactly 2.4576 Mhz
Data is the data stream to PS2
Clock i the clock to PS2
U8 this is the devider by 128. The devider have a circuit for sync, U7D. R1/C1 give you small time delay, to move the faling edge to the midle of the data bit.
When you reive the start bit the U1A flip-flop change the state. Q output allow the clock to the clock output. This clock increment the U3 counter.
The Tx data going to Data output via U4D. U4D is using to add the parity and stop bit to the data.
U2B is use like a T flip-flop, devider by 2. This flip flop count the rising edge, and giv you the parity bit.
U5A generate the reset signal, when have a 11 clock impulse. The impuls will be generate on the rising age after last clock impuls. To do this, U7B use invert cloc from U6A.
U4C generate signal to :
1 - stop the parrity bit calculation, Q' going to Low level.
2 - to allow parrity counter output to data line, U7C.
U4B make reset impulse

RS_PS2.pdf

Link to comment
Share on other sites

Hi Tony,

i am impressed with the schematic you managed to draw up at such short span of time.

Have you tested the circuit on a computer simulation software by sending in 9600bps?

Q1: Will you mind explaining in words,a summary of how the whole circuit functions, so that it will be easier for me to follow? i will not mind spelling errors:)

Q2: Will you mind explaining abit further on how each of the counter works and the rationale for connecting one counter to another,esp the connection which involves R1 and C1 to set up a time delay? how can it be achieved?

Q3: For the ceramic capacitors,you asked me to connect them to each chip..Do you mean connecting them to the Vcc pin or GND pin etc?

thanks alot

junwei

Link to comment
Share on other sites

Hi,
today i have a long flight, i think will find some time to make explain more in details, but this will be later.

Edit.
OK, i make the simulation on 19200 bps, you talk a keyboard rate around 20 Khz. In this circuit i not store data, i transfer it on every bit, and output bt rate is connect to the input bit rate, if you use 9600, the PS2 bit rate must be 9600 too.
I think i try to explein how this work, now i will get answer to your questions :
Q1 : When you recive the start byte ths byte set triger U1A. This triger enable the U4A gate, and clock signal is transfer to the clock output.
On the every clock signal the U3A is increment. This is 4 bit binary counter. On the output of the counter i have connected several gates, U5A, U4B, U4C. I use this gates to detect different numbers on the conter outputs. This is the NAND gates. The state diagrm for nand is :
A 1 0 0 1 input
B 1 0 1 0 input
C 0 1 1 1 output
How you can see the output going to low level only to of the input is 1, in all other case the output is to high level. This i to same for 2 and 3 input NAND.
Ok, when the bit A,B,D is hight the output of U5A is low. This low level i use to generate the Reset signal. If i use directly this output the reset cygnal will generate several nanoseconds after the edge of the clock, this will close gate U4A, and the keyboard contoller may be can not detect valid clock. To prevent this I use U7B. This is OR gate. The state diagram for OR gate is :
A 1 0 0 1
B 1 0 1 0
C 1 0 1 1
The output of this element is low only two inputs is low. The seccond inputs on U7B i connect to the invert clock signal. The counter incement on the fallow adge, then when counter is increment to 11, the clock will be low. The invert clock will be high and output on U7B will be high. When clock go to hig level, on the all input on U7B will have a low level, then autput will be low too, this is the reset. All device in the circuit diagram have a low level reset.
Ok, when i have a reset, this reset the U1A, and gate U4A will be closed. This is th end of the transmision.
Way 11, becouse you have 1 start, 8 data, 1 parity and 1 stop, the sum of this is 11.
The other two gates generate the signal for the party bit and stop bit.
How works the parity. What is the paritym the parity is counting how bit on each type you have. You have two tye of parity even, and odd, one count the logic 1, another logic 0.

RS_PS2.pdf

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...