| View previous topic :: View next topic |
| Author |
Message |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Sat Apr 21, 2012 1:40 pm Post subject: PIC sending PS/2 keyboard signals? |
|
|
As PETSCII seems dead (awaiting account approval since a couple of days) I continue asking here instead.
Would it be possible to make a PIC send PS/2 signals to a DTV?
I was thinking of adding 5 buttons to a DTV mod, 4 would be the F keys and 1 for switching between odd and even numbers, like Shift on a C64.
If this would work, can anyone help me write a program for that?
I have a PIC programmer but no programming skills. _________________ Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
Immortal Grandmaster of C64

Joined: 13 Oct 2004 Posts: 4792
|
Posted: Sat Apr 21, 2012 1:44 pm Post subject: |
|
|
would be easily doable actually. _________________ |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Sat Apr 21, 2012 4:44 pm Post subject: |
|
|
That sounds nice
Would a 16F84 be enough?
I already have some of these at home.
The problem is I donīt know anything about electronics or programming PIC.
Do I need other components too ? _________________ Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
C64 Enthusiast

Joined: 20 Jun 2004 Posts: 776
|
Posted: Sun Apr 22, 2012 5:49 am Post subject: |
|
|
It's not PIC, but:
http://www.go4retro.com/products/ckey/
The link at the bottom has source code and a schematic. It will do both directions, and I added DTV specific key combos.
Jim |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Mon Apr 23, 2012 3:06 pm Post subject: |
|
|
Thatīs a little moore advanced than I need I guess.
This is what I need:
(Button=B)
When pressed:
B2 - send F1
B3 - send F3
B4 - send F5
B5 - send F7
B1+B2 - send F2 etc.
I realized that in Bombmania thereīs another key that I need so i thought
that:
B2+B3 - send "s" to start the game.
Maybe there would be room in the PIC for other combinations too if I find other keys that are needed to start or interact with some games.
And all signals must be sent as PS/2 protocol, but F7 must be sent as another code than original PS/2 because a fault in the DTV. _________________ Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
Groupie in Training

Joined: 21 Oct 2006 Posts: 50
|
Posted: Tue Apr 24, 2012 7:08 pm Post subject: |
|
|
| Bombus wrote: | B2 - send F1
B5 - send F7 |
You are aware that the DTV buttons A and R do this already?
| Bombus wrote: | | Maybe there would be room in the PIC for other combinations too if I find other keys that are needed to start or interact with some games. |
Depending on how well versed one is in 6510 & PIC ASM (and soldering), it might be a lot easier to modify the game to use the DTV buttons instead.
| Bombus wrote: | | And all signals must be sent as PS/2 protocol, but F7 must be sent as another code than original PS/2 because a fault in the DTV. |
This is a related project that may give some hints. Such as using AVR hardware.
For a simple button -> DTV project you seek, the requirements are quite relaxed. The DTV PS/2 implementation is unidirectional so the trickiest parts of PS/2 (host-to-device) can be completely ignored. If I remember correctly, the timing doesn't need to be nearly as accurate as the PS/2 specs state, and I wouldn't be too surprised if the DTV ignored the parity bit.
With all that said:
| Bombus wrote: | | If this would work, can anyone help me write a program for that? | Writing software for nonexisting hardware based on unspecified microcontroller for the fun of it? I'd guess "no".
For a no-programming-required solution, grab the PCB from a PS/2 keyboard and wire the new buttons to the correct contacts. Hopefully the PCB fits into whatever case you're planning to use. C=Key seems like a nice option if you don't have a pile of keyboards in a closet. |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Tue Apr 24, 2012 8:10 pm Post subject: |
|
|
| nojoopa wrote: | Bombus skrev:
B2 - send F1
B5 - send F7
You are aware that the DTV buttons A and R do this already? |
No, unfortunately I didnīt
| nojoopa wrote: | | This is a related project that may give some hints. Such as using AVR hardware. Wink |
I have been looking at that and itīs interessting. Iīm planing to build that for my little project. I have bought a Arduino Duemilanove, for flashing DTV, but realized it can flash ATTiny too.
| nojoopa wrote: | Bombus skrev:
If this would work, can anyone help me write a program for that?
Writing software for nonexisting hardware based on unspecified microcontroller for the fun of it? I'd guess "no". |
I donīt understand the "nonexisting hardware"
The microcontroller would be PIC16F84, if possible, as i wrote earlier.
| nojoopa wrote: | | For a no-programming-required solution, grab the PCB from a PS/2 keyboard and wire the new buttons to the correct contacts. Hopefully the PCB fits into whatever case you're planning to use. |
I have been looking at that too, doable, the PCB will fit with no problem.
The only thing is that I might need a lot more buttons than I want too to get all keys needed.
| nojoopa wrote: | | C=Key seems like a nice option if you don't have a pile of keyboards in a closet. |
The point is that I want my mod to be as near portable the original DTV as possible, I donīt want to bring a keyboard.
My plan is to bring it with me when staying at hotels and be able to play with my companions. _________________
Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
C64 Enthusiast

Joined: 20 Jun 2004 Posts: 776
|
Posted: Wed Apr 25, 2012 4:48 am Post subject: |
|
|
Well, note that I didn't mean using C=Key as is. You can strip it down and put the code in a Mega48 or something similar, which would fit in a DTV easy. I know the PS/2 code compiles on a M48, because the same library is used for PS2Encoder.
PIC is fine, but it's a bear to program, in my opinion, and I'm in no hurry to work with it again.
Jim |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Wed Apr 25, 2012 7:58 am Post subject: |
|
|
| nojoopa wrote: | | Depending on how well versed one is in 6510 & PIC ASM (and soldering), it might be a lot easier to modify the game to use the DTV buttons instead. |
Nothing is easy for me as I donīt know anything.
I donīt know programming or electronics...
The only things I can do is solder and flash PIC and maybe ATmega/ATTiny.
Iīm hoping to find help somewhere with developing the program that I need and maybe a schematic if there are more components needed. _________________
Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Wed Apr 25, 2012 8:22 am Post subject: |
|
|
| brain wrote: | Well, note that I didn't mean using C=Key as is. You can strip it down and put the code in a Mega48 or something similar, which would fit in a DTV easy. I know the PS/2 code compiles on a M48, because the same library is used for PS2Encoder.
PIC is fine, but it's a bear to program, in my opinion, and I'm in no hurry to work with it again.
Jim |
Iīm sorry for beeing a bit stupid, but I donīt understand how this would make it easier.
Donīt I still need a keyboard for this?
I have a picture here showing how I was thinking.
The front is cut out of a piece of cardboard, I donīt know if the DTV will support 4 joystick ports, lets hope...
The joy ports will ofcourse be male all of them.
Green circle=led
Red circle=button
Blue circle="shift"
I will centrate the uIEC and PS/2 better on the real frontplate.
 _________________
Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
C64 Enthusiast

Joined: 20 Jun 2004 Posts: 776
|
Posted: Wed Apr 25, 2012 6:15 pm Post subject: |
|
|
| Bombus wrote: | Iīm sorry for being a bit stupid, but I donīt understand how this would make it easier.
Donīt I still need a keyboard for this?
|
No. The code would scan a few buttons, and output PS/2 data on the PS/2 port (that you have hooked to the DTV PS/2 port).
I assume that's what you wanted.
Jim |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Wed Apr 25, 2012 7:17 pm Post subject: |
|
|
Oh yes indeed, thats what I want!
But how do I make it scan B1 as "shift" so it then scans B2 as F2?
Well I will look at it a bit moore when the modding is done.
Not that it makes any difference as I donīt know how things work.
As mentioned - I donīt know electronics or programing.
I got a few more components today so I will go on fiting the parts in the new case, when that is done Iīm ready for solving the PS/2 business. _________________ Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
C64 Enthusiast

Joined: 20 Jun 2004 Posts: 776
|
Posted: Wed Apr 25, 2012 9:46 pm Post subject: |
|
|
| Bombus wrote: | But how do I make it scan B1 as "shift" so it then scans B2 as F2?
Well I will look at it a bit moore when the modding is done.
Not that it makes any difference as I donīt know how things work.
As mentioned - I donīt know electronics or programing.
|
It's all in the firmware. You would scan for B1, and if it is down, you set an internal flag called "shift". Then, when you see B2, you check "shift". if set, you send F2, else send F1. rinse, lather, repeat.
You can actually do part of this on a garden variety C=Key. You grab a copy of the C64 keyboard matrix diagram and you will see that right shift is pin 8 and pin 14. So, you wire a switch across those two pins. F1 is pin 2 and 8, etc. Then, you wire up the C=Key PS/2 port to the DTV, and there's F1-F8
Obviously, doing B2 + B3 = s is harder (when the person depresses B2 and B3, they never do so at exactly the same time. One will be pressed first. The firmware will have trouble deciding if that is a B2 and then B3, or a B2+B3). It is possible, but it requires checking for the delay between two buttons being pressed. As this is a small project and your first one, I'd recommend putting a specific button for 'S' and the other important ones. Later, you can always modify the firmware to suit your needs.
Obviously, a C=Key will not fit in a DTV case, but it might fit in your little enclosure.
Otherwise, you can modify the code to fit into a smaller uC and a smaller PCB. Up to 16 switches in a 4x4 matrix would be easy for most little PICs or AVRs.
Jim |
|
| Back to top |
|
 |
Newbie
Joined: 14 Apr 2012 Posts: 5 Location: Sweden
|
Posted: Fri Apr 27, 2012 6:43 am Post subject: |
|
|
I just took a look at whatīs needed to start Bombmania and the version I have needs a lot of keys.
First it needs Space to go from introscreen, then you need to press:
(P)al or (N)tsc
C or G or W to choose 4 joystick controller
Y or N to confirm
S to start the game
I guess I will buy the smallest PS/2 keyboard that I can find on ebay
and skip the buttons on the top for now.
I will build the KeyboardTwister to fix the PS/2 problems. _________________ Be patient, Iīm from Sweden and my English is no good. |
|
| Back to top |
|
 |
|