PSTWO controller emulation
computer guy
Posts: 1,113
Hi everyone,
I need to get the propeller to emulate a keyboard and a PS2 controller("guitar hero" guitar).
Obviously not at the same time but I want it to be changed via a switch.
What is involved in getting this to happen?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Building Blocks To The Propeller Chip A web site designed to help people who are new to the propeller chip.
Guitar Hero controller using the prop (WIP) --> HERE
Post Edited (computer guy) : 1/18/2009 8:28:49 AM GMT
I need to get the propeller to emulate a keyboard and a PS2 controller("guitar hero" guitar).
Obviously not at the same time but I want it to be changed via a switch.
What is involved in getting this to happen?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Building Blocks To The Propeller Chip A web site designed to help people who are new to the propeller chip.
Guitar Hero controller using the prop (WIP) --> HERE
Post Edited (computer guy) : 1/18/2009 8:28:49 AM GMT
Comments
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
I didn't think that it couldn't be done.
The software side I am assuming is as easy as outputting the key codes. e.g 0x27 for the letter "A".
The hardware should be as simple as some pull up resistors and perhaps some transistors to get the 5v required for the PC.
Is this correct?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
I think this was a thread about a usb keyboard emulation - probably not what you are looking for, but cool anyway.
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
so for PS/2 keyboard.
Just realised that the host does a lot of pre configuration.
Would someone be interested in writing an obex object for "keyboard" and "PS2 controller" emulation.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Post Edited (computer guy) : 6/30/2008 6:05:49 AM GMT
Some good information can be found here.
www.curiousinventor.com/guides/ps2#mappings
I am more interested in the Guitar Hero controller emulation.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Graham
However as someone who has never fully understood any communication protocol and knows little if any ASM I don't even know where to start.
Steven I will search the forums and see what I can find.
There is already objects for a keyboard and a PS2 Controller all that needs to be done is to reverse the functions.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Post Edited (computer guy) : 7/1/2008 12:27:05 PM GMT
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
So, basically, you're looking for a PS/2 Keyboard "Replacement" -- instead of the Propeller clocking bits OUT of a keyboard (which we already have code for), some external device will be clocking bits OUT of the Propeller. You'll need some level-shifting in there from the 5-volt Keyboard clock to the 3.3 volt Propeller levels, too.
I wasn't saying it would be easy just that there is a starting point.
I was planning on using 2n2222 (or similar) transistors for the 3.3v to 5v level shifting.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
I found an article on the net of a VB.net program that does this. Shouldn't be to hard to convert to spin.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Post Edited (computer guy) : 7/2/2008 8:10:19 AM GMT
However I may need some help from time to time as I have never coded in PASM before.
I will basically be reversing all commands in the keyboard driver so that it writes rather than reads.
Wish me luck.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Or do I have to do something else in between? Also does the receive command store the received data in the 'data' variable?
The propeller quick reference guide has helped me understand allot of the PASM functions.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
The prop now has to generate the clock signal rather than detect it and it has to initiate most communication.
If someone could at least get a starting point that I could perhaps work on that would be great.
Its the init code that is hard. Getting the prop to identify its self as a keyboard. Once that is done it is just a matter of sending scan codes.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
[noparse]:)[/noparse]
But seriously, If for some reason you don't or can't understand how the PS2 interface works, why not grab some code (and there is bucketloads of it around) for another processor (pic, avr, hc11). Read it, understand it, port it to the Propeller.
As Calvins dad would say. "It builds character" [noparse]:)[/noparse]
I don't even own a machine with a PS2 input anymore, it's all USB here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Pull my finger!
as i read on the website Mike mentioned
www.computer-engineering.org/ps2protocol/
the communication between PC and keyboard is not symmetrical.
As you have difficulties to find a starting point. I think this caused by the idea just to reverse everything.
But "reversing" is not as easy as multipling with minus one
I think it will be easier to start the whole thing new from the basic up
If the Prop should send scancodes this is the case "Communication: Device-to-Host"
so this could be a starting point:
programming a loop that is generating the clock signal and waiting for
the dataline to become low as the signal Prop can start datatransmission
next step:
calculating the parity bit
adding startbit (always 0) 8 databits, paritybit and stopbit (always 1) to a long and shiftout the eleven bits
then adding the check for: host takes dataline high as a signal comm. inhibited by the host
etc. etc.
another website with infos about the protocol
www.beyondlogic.org/keyboard/keybrd.htm
best regards
Stefan
You'll have to make sure you passthrough everything that the keyboard is giving you but it should eliminate most of the init stuff. Check the sparkfun tutorial for some of their experience with this (the used avr but most of their information will still be useful to you)
www.sparkfun.com/commerce/present.php?p=Key-Counter
If the host wants to send data, it must first inhibit communication from the device by pulling Clock low. "
If the prop is generating a clock signal on the clk line how can the host pull the line low?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
first of all - if you don't want to be tricky by switching the IO-Mode of data and clock all the time between Input and Outputmode
you have to use FOUR PINs if the propeller should act as a keyboard emulator.
You can find out this by carefully reading the website
www.computer-engineering.org/ps2protocol/
Maybe i ask how good is your knowledge about electronics?
Take a look at the circuit
if the microcontroller-PIN "C" is low the transistor is "locked"=very high resistance - no current flowing from +5V through the Pull-Up-resistor down to ground
then on microcontroller-PIN "B" there is high-level because of the pull-up-resistor. The circuit +5V-Pull-Up-Transistor-Ground is "openend"
If the microcontroller-PIN "C" is high the transistor is "switched through" low resistance now a current is flowing from +5V through the Pull-Up-resistor down to ground
then on microcontroller-PIN "B" there is low-level because all the voltage drops down "in" the pull-up-resistor
By switching the PIN "C" the clock signal is generated
The clockline is high as long as PIN "C" is low. If - on the other end the HOST connects the clockline to ground
(and closes the circuit) then there will be PIN "B" low WITHOUT PIN "C" beeing high
and the microcontroller (the keyboard-device) has to check for this combination.
By this tricky way of circuitry the host - IN FACT - CAN pulldown the clockline by closing the circuit by himself.
best regards
Stefan
So the code needs to check if "pin C" is low and if it is check if "pin B" is low if they both are low for 100us then the host is pulling the clock line low.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Also if I was to use 2n2222 transistors wouldn't a 100ohm resistor be needed between the prop and base pin.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
yes a resistor between Prop-PIN and base of the transistor makes extremly sense.
100 Ohms is a little bit low. each transistorTYPE has its own current-amplifyingfactor
most of them in the range 50-150. If the pull-up-resistor is 10kOhms. You have a current of 5V / 10000 Ohm = 0,5mA
So the collector-emitter-current should be 0,5mA. The base-emitter-current steers the collector-emitter-current
let's assume the currentamp-factor is 100: then the base-emitter-current has to be 0,5mA = 500mikroA / 100 = 5 mikroA
The base-resistor has to have a maximumvalue of 3,3V / 0,5 mikroA = 660kOhm
For switching-purposes it's usual to use a 4,7kOhm resistor.
3,3V / 4700 Ohm = 700 mikroA. The collector-emitter-current provided is 70 mA wich is pretty much and sufficient for
digitical logic devices (usually 0,1-10 mA)
i have to make an additional remark
The schematic in the previous posting has a +5V supply and the PC-keyboardinterface works on 5V too.
The propeller runs on max 3,3V. To avoid damage to the propeller you need 1kOhm current-limiting-resistors in serial to PIN A and PIN B
in schematic above
if you are not familiar to the basics of transistorelectronics search for a EASY to understand tutorial
What i found at the english wikipedia is HARD to understand and does not cover the basic things
about base-emitter and collector-emitter current.
My experience searching with google in about 15 Minutes is:
an EASY to understand tutorial could'NT be quickly found
here is a link to a german website with two pictures
showing an analogon with water
leifi.physik.uni-muenchen.de/web_ph10/grundwissen/15trans_eff/trans_eff.htm
small base-current small collector-emitter-current
bigger base-current bigger collector-emitter-current
the different with of the waterchannels represents the amplifying-factor for the current
the small base-channel drives the big collector-emitter-channel
best regards
Stefan
Post Edited (StefanL38) : 7/8/2008 8:08:31 AM GMT
It's at svn.navi.cx/misc/trunk/unicone2/psx-base/, as well as on the object exchange.
Guitar Hero controllers are basically just analog PS2 controllers (not Dual Shock- Guitar Hero will work with a Dual Shock emulator, but GH2 doesn't) with the left d-pad button held down. I've tested this emulator object successfully with Guitar Hero and Guitar Hero 2. You just have to be sure to use CONTROLLER_ANALOG mode instead of CONTROLLER_DUAL_SHOCK.
The PS2 GH emulator is more important than the keyboard.
I didn't think of the 1kohm resistor but now that you mention it I remember the need for it.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
I have always compared to a transistor as an electronic tap.
The more current that is applied or the more you turn the valve the more current passes from emitter to collector or the more water is allowed to flow.
That has always worked for me.
I just remember that in a previous project a resistor of some value was needed between prop and base pin to prevent the prop from doing damage to the transistor.
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
I have had a look at your emulator and am not sure how to use it.
Could you please write some short code to configure it to emulate an Analog Controller and then send out that the "Square" button has been pushed.
This should be enough to give me a general idea of how to use it.
Also do you have a copy of the schematic for connecting the prop to the PS2?
Thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my robot using the propeller RECONAUTOR
If you like my avatar then check this out Propeller Domed Stickers for sale
Building Blocks To The Propeller Chip
Post Edited (computer guy) : 7/8/2008 12:48:03 PM GMT