geekhack

geekhack Projects => Making Stuff Together! => DIY Discussions ARCHIVE => Topic started by: Mnemonix on Fri, 08 January 2010, 10:55:19

Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 08 January 2010, 10:55:19
[SIZE=+1]How to build a USB controller for your keyboard.[/SIZE]

Some time ago I've noticed that my IBM Personal System/2 Space Saving Keyboard (or just my "Mini") had a little problem: the controller would heat up during operation (http://geekhack.org/showthread.php?t=7689), and I feared it could fail some time. So I replaced the original controller with a homebrew USB controller running my custom Keyboard Upgrade firmware. I've done this before for another M, but this time I took some pictures of the progress and documented how I have built the controller.

Even though I only needed the controller for a Model M Mini (i.e., no LEDs), I thought it would be a good idea to build one that could also be used in a full-size 1391401, and hence make these instructions more useful for more people. I tested the controller in a 1391403 (which is a 1391401 with the annoying German layout) to make sure it would really fit in there and work as it should--which it does.

Since I didn't want to handle chemicals and also wasn't ready to spend serious money on a professionally etched PCB, I used stripboard for making the controller. Unfortunately, stripboards are a mess, so most of this post describes how I treated a stripboard to recreate the design found on this page (http://www.schatenseite.de/dulcimer.html). Scroll all way down to the end of this post for some notes on "real", etched PCBs.

Meanwhile, my industrial gray Model M Mini has arrived, which I am using now instead of my other Mini. I moved the USB controller over to the gray Mini, and this is what it looks like:

(http://geekhack.org/attachment.php?attachmentid=7127&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7128&stc=1)

Must be the most modern industrial Mini in the world! :D


[SIZE=+1]Materials and tools[/SIZE]

Materials used:


Tools used:
(And yes, I am ignoring medieval ways for specifying lengths. This world is metric. Get used to it. ;) )


[SIZE=+1]Build![/SIZE]

So, here are the instructions for building a cheap IBM Model M USB controller... Please read the instructions in full length before attempting to build your own.
The resolution of some of the pictures below may not be high enough to show all the necessary details. Therefore, I have attached larger versions here (http://geekhack.org/attachment.php?attachmentid=7217) and here (http://geekhack.org/attachment.php?attachmentid=7218).

First, cut the stripboard into pieces as illustrated on the following picture using a Dremel or a cutter knife (which is harder). It is OK for the bigger pieces to be a tad larger than shown on the picture since the size of the USB board is not as critical. The main board should not be smaller than shown on the picture. If done correctly, you'll end up with four pieces that could actually be used to make two controllers: two bigger pieces with 39x20 holes, and two smaller 19x20 ones.

(http://geekhack.org/attachment.php?attachmentid=7129&stc=1)

File down one of the long sides of the main board until it fits easily into the tray where the old controller was (don't force it in!), right next to the two poles that hold the controller in its place.
Drill the USB board as shown on the next picture. The smaller holes will pick up the USB connector. The bigger holes should fit over the two poles at the gap for the SDL connector so that the board is held in its place just like the old controller was (later, we will attach the USB board to the main board so that they appear as a single board). Make sure to remove enough copper surrounding the big holes so that it cannot eat into or otherwise damage the plastic poles. Again: don't force anything here and make use of your tools!

Now as the boards are correctly sized and drilled, cut the copper strips in the red-marked areas as shown below. I used a Dremel for the coarse cuts, and a cutter knife to rework some improperly cut strips. Double-check for shorts with a multimeter.

(http://geekhack.org/attachment.php?attachmentid=7131&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7204&stc=1)

We'll be running wires from underneath the IC socket, so you'll need to make sure that there is enough room to route some wires below the short sides of the socket. (Scroll down a bit and look at one of the pictures with the IC socket soldered in to see what I mean.) My socket had some ridges on both sides standing in the way which I had to remove with a cutter knife like this:

(http://geekhack.org/attachment.php?attachmentid=7132&stc=1)

That's it for the mechanical work, you may stow away your Dremel now. Heat up your soldering iron and start soldering some wires onto the stripboard as shown on the next two pictures. There are direct connections between neighboring copper strips in the two green marked areas; these are intended and no mistakes.

(http://geekhack.org/attachment.php?attachmentid=7209&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7207&stc=1)

What follows is a list of the wire connections seen on the pictures.
Holes are identified using the coordinate system displayed on the pictures; e.g., coordinate 4/9 means row 4, column (or copper strip) 9.
Code: [Select]
Blue               White             Red            Direct
 4/ 9 -  5/12       5/20 -  5/27     17/12 - 17/24   6/28 -  6/29
 4/10 -  5/13       6/24 -  6/28     18/10 - 18/23   6/29 -  6/30
 4/11 -  5/14       9/15 -  9/29                    17/11 - 17/12
 4/12 -  5/15       9/17 -  9/30                    (9/27 -  9/28)
 4/13 -  5/16       9/27 -  9/28 [2]
 4/14 -  5/17      13/23 - 13/37
 4/15 -  5/18      14/ 2 - 14/13 [3]
 4/16 -  5/19      14/ 4 - 14/12 [3]
10/18 - 10/39 [1]
10/19 - 11/38 [1]
10/20 - 11/36 [1]

[1] End points are not connected in these pictures yet. See below.
[2] Can be replaced by a "green" direct connection, but I didn't think of this at the time...
[3] Bend wires, do not make a straight connection. See below.


I kept the three long blue wires rather long and loose on one end because I didn't know how long they should really be at that point. You may just take a look at one of the later pictures to get their lengths right in the first place. :)
The two white wires 14/2-14/13 and 14/4-14/12 need to run around the programming connector that is soldered in later. Hold the 6-pin jumper header at 14/6-14/11 and route the wires around it to get them right; also check out the pictures below. I didn't solder the header in at that point, however, because it would have stood in the way all the time.

Next come 8 wires that you'll need to make long enough to "flow around" the IC socket (look at one of the next pictures to get an idea). Hold the socket into its later place--rows 6 and 12 and starting in column 1--to get the lengths right (I didn't really measure their lengths). I've actually made the four "inner" wires a bit too short for this controller, which is why they are sitting rather tight around the socket...

(http://geekhack.org/attachment.php?attachmentid=7210&stc=1)

Connections:
Code: [Select]
10/1 - 4/23  10/5 - 4/27
10/2 - 4/24  10/6 - 4/28
10/3 - 4/25  10/7 - 4/29
10/4 - 4/26  10/8 - 4/30


This is how your controller should look like after putting in the IC socket, dual row jumper header, and soldering the three loose ends mentioned before:

(http://geekhack.org/attachment.php?attachmentid=7211&stc=1)

This is a good time to double-check all connections. Are there any shorts? Do the connections work? Any weak solder joints? This is really important--do yourself a favor and don't skip this step.

We'll carry on by soldering in the components. I've added the 8 resistors and 3 capacitors for the next picture. No new wires here.

(http://geekhack.org/attachment.php?attachmentid=7212&stc=1)

Components:
Code: [Select]
Resistors                 Capacitors
 4/36 -  9/36 (470 Ohm)   13/11 - 13/12 (22 pF)
 4/38 -  9/38 (470 Ohm)   16/10 - 16/11 (100 nF)
 4/39 -  9/39 (470 Ohm)   16/12 - 16/13 (22 pF)
10/22 - 10/24 (4.7 kOhm)
11/22 - 11/23 (2.2 kOhm)
13/14 - 13/22 (68 Ohm)
14/16 - 14/21 (68 Ohm)
16/ 9 - 16/23 (10 kOhm)


Then, add the 2 Z-diodes, crystal oscillator, programming header, and the FFC connctors for the keyboard matrix. My version of this controller lacks the connector for the LEDs because I didn't have a spare one, so instead I've marked the place in the picture where the 4-pin connector should go. It should face in the same direction as the neighboring 8-pin connector, with the four legs soldered in the green marked area (row 3). Pay attention to the correct orientation of the FFC connectors (all of them!).

(http://geekhack.org/attachment.php?attachmentid=7213&stc=1)

Components:
Code: [Select]
Z-diodes       Crystal
12/21 - 12/24  16/2 - 16/4
15/22 - 14/24

16-pin connector   :  2/ 1 -  2/16
8-pin connector    :  3/23 -  3/30
4-pin connector    :  3/36 -  3/39
6-pin jumper header: 14/ 6 - 14/11


The diodes are the only components in this circuit where polarity matters, so take care to solder them in in the correct orientation. The black rings mark the cathodes and go to holes 12/21 and 15/22, respectively.

Note that the 6-pin header for hooking up the AVR programmer is not exactly "the standard way to do it"; commonly, 6- or 10-pin IDC sockets are used for this. The six pins on this design, however, connect straight to pins 6 through 11 on the AVR, which is much more convinient on stripboard. Another reason to go with this solution is space: there is not enough room for an IDC socket in this location when putting the controller into a Mini.

If you are planning to use your controller in a Space Saving keyboard, then you still must cut the header pins to a shorter length so that they don't make contact with the metal plate of the keyboard assembly! There is really much less vertical space in a Mini than in a full-size Model M. Your best bet is to put the board into the keyboard case and take a good look if the pins are touching the plate when putting in the assembly; cut the pins accordingly while keeping them long enough to make contact with a programming connector. Make sure that the keyboard assembly is really in its place when doing this, i.e., it must be fully inserted and held in its place by the rectangular plastic poles at its top, and not "hang" or be otherwise misaligned.

So, most of your controller is ready by now. Solder the USB connector to the USB board, and add four long wires to the copper strips that run to the pins on the connector. The wires will provide the electrical connection between the smaller USB board and the larger main board. Their names are "GND", "+5V", "D-", and "D+", corresponding to the pins on the USB connector. Again, I didn't really measure the lengths of the wires...
Also add the thick grounding wire now that will go to the keyboard assembly--I forgot it at first, but added it later. Depending on the type of cable that you are using for this, you may need to drill the hole for the grounding wire a bit larger.

(http://geekhack.org/attachment.php?attachmentid=7140&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7214&stc=1)

Connections:
Code: [Select]
Blue        Red         White       Direct
16/10 (D+)  16/8 (+5V)  16/7 (GND)  3/7 - 3/ 8
16/ 9 (D-)                          3/9 - 3/10

Grounding wire: 10/7

USB connector: pins at 4/8, 4/9, 5/8, and 5/9


We are still missing the mechanical connection between the two boards in order to get "one" controller board. As seen already on the previous picture, I used some junk wire that I've cut off from the resistors to tie them together (do not forget to remove the copper from the area around the holes when using wire!). The connection is flexible and not overly stable, a bit like a hinge, but that's more than we need. Here is a close-up of the two "wire hinges" marked by green circles:

(http://geekhack.org/attachment.php?attachmentid=7144&stc=1)

Alright, here is the last step: connect the four wires to the main board. This picture also shows the grounding wire that I have added a bit too late (at hole 10/7):

(http://geekhack.org/attachment.php?attachmentid=7216&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7215&stc=1)

Connections:
Code: [Select]
Blue        Red          White
19/21 (D+)  19/10 (+5V)  19/11 (GND)
19/22 (D-)


Check again all solder joints, at least visually. Take good care that there are no connections between neighboring copper traces where there should be none. Sometimes these accidental connections are hard to spot, so take a good final look.


Well done!

The hardware is ready to be programmed now.

(http://geekhack.org/attachment.php?attachmentid=7205&stc=1)


Here is the pinout of the programming header on the controller. Your AVR programmer will likely have a 6-pin or a 10-pin IDC socket, or both. Build an adapter cable according to one of the following pinouts in order to program the AVR on the controller. Do not plug the controller into your computer's USB plug when attaching the programmer to the programming header!

Code: [Select]
6-pin at   | header pin on    10-pin at  | header pin on
 programmer | controller       programmer | controller
------------+---------------  ------------+---------------
 1 (MISO)   | 2                1 (MOSI)   | 1
 2 (+5V)    | 5                2 (+5V)    | 5
 3 (SCK)    | 3                3 (NC)     | -
 4 (MOSI)   | 1                4 (GND)    | 6
 5 (nRESET) | 4                5 (nRESET) | 4
 6 (GND)    | 6                6 (GND)    | 6
                               7 (SCK)    | 3
                               8 (GND)    | 6
                               9 (MISO)   | 2
                              10 (GND)    | 6


(http://geekhack.org/attachment.php?attachmentid=7274&stc=1)

(http://geekhack.org/attachment.php?attachmentid=7275&stc=1)

This is my cable:

(http://geekhack.org/attachment.php?attachmentid=7276&stc=1)

A bit rough--I know you can make a nicer one! :)

If you don't want to make an adapter cable, see here (http://www.evilmadscientist.com/article.php/avrtargetboards) for a "quick how-to guide on making ultra-simple development boards for programming AVR microcontrollers". Really simple, and saves you from building a custom cable.
Note: you should probably add a 12 MHz crystal oscillator and two 22 pF capacitors to the board (in the same places as on the keyboard controller) so that the AVR would still work after programming its fuses to actually make use of an external crystal oscillator...


[SIZE=+1]Jumpers[/SIZE]

There are three jumpers on the controller, in columns 28, 29, and 30. For normal operation, all of these should be left open.

(http://geekhack.org/attachment.php?attachmentid=7308&stc=1)

Only one of the jumpers is used by the firmware at the moment, called KM0 (for Key Map 0), located in column 28. Closing KM0 forces the controller to use its built-in QWERTY key map. Use this in case you have activated a broken key map and cannot switch back to a good one anymore.


[SIZE=+1]Programming the boot loader and firmware[/SIZE]

The AVR needs, to the very least, a boot loader so that the main firmware can be programmed from your computer via USB. Firmware and boot loader images can be downloaded from http://sourceforge.net/projects/kbupgrade/files/Firmware (http://sourceforge.net/projects/kbupgrade/files/Firmware), sorted by keyboard model and AVR type. Choose the 1391401 version for a 1391401, and the 1392934 version for the Mini; the latter simply lacks LED and numpad support.

There is a file called file_id.diz in the zip archives that documents which values your AVR's fuses must be programmed to for the particular firmware. After programming the low and high fuses, write the boot.hex image to your AVR. You need to do this only once and not again for later updates. Then, program the main.hex image to the AVR, and lock the boot loader by programming the lock fuse to the value given in the file_id.diz file.

Note that for updating the firmware or uploading alternative key maps via USB you'll still need to build the corresponding tools from the sources for now. I do not have pre-compiled binaries of the required tools right now (too much extra work to keep them up-to-date for multiple operating systems and package management systems). Maybe I can build them for you on demand.

If you prefer to build the firmware (and tools) from scratch, you can download source tarballs from http://sourceforge.net/projects/kbupgrade/files/Source (http://sourceforge.net/projects/kbupgrade/files/Source) or pull the latest sources from GitHub at http://github.com/rhomann/kbupgrade (http://github.com/rhomann/kbupgrade). Follow the instructions given in the INSTALL (http://github.com/rhomann/kbupgrade/blob/master/INSTALL) file.

That's all. Put your new controller into your keyboard and stow away or sell the original controller. :)
Plug in, and it should be recognized as a generic USB keyboard. For more documentation, read the INSTALL (http://github.com/rhomann/kbupgrade/blob/master/INSTALL) file from the firmware sources (yes, the docs should be split somehow).

Have fun!


[SIZE=+1]But wait! Look at all those wires! I don't wanna mess with stripboards![/SIZE]

If you prefer an etched PCB and are able to produce one by yourself, you may want to take a look at either Dulcimer (http://www.schatenseite.de/dulcimer.html) or RUMP (http://mg8.org/rump/). The relevant files are also found in my source tree (http://github.com/rhomann/kbupgrade/tree/master/circuits/IBM_Model_M).

Both of the designs are compatible with my firmware, but only the Dulcimer design incorporates a connector for the LEDs.

Note that both designs were made with a full-size 1391401 Model M in mind, which has significantly more spare space than a Mini, especially in vertical direction. If you are planning to build a controller for your Mini using one of these designs, then double-check that it will fit into the keyboard and that no component will touch the metal plate!

Programming works just like with the stripboard version, of course.
Title: Making a cheap Model M USB controller
Post by: itlnstln on Fri, 08 January 2010, 11:01:18
Strong work.  That's pretty sweet. Congrats.
Title: Making a cheap Model M USB controller
Post by: msiegel on Fri, 08 January 2010, 11:20:22
beautiful
:D :D :D
Title: Making a cheap Model M USB controller
Post by: keyb_gr on Fri, 08 January 2010, 11:23:05
:Cry:


EDIT: Stylish to the rescue - here's a hotfix for overly wide images in the Wiki. Scrolling over them is painfully sluggish but at least I can read the text now. Grmbl.
Code: [Select]
@-moz-document url-prefix("http://geekhack.org/showwiki.php?") {
  img {
    max-width: 1160px;
    }
}

EDIT^2: Nice tutorial, well done!
Title: Making a cheap Model M USB controller
Post by: itlnstln on Fri, 08 January 2010, 11:25:46
I wonder why the Wikis don't resize pics/wrap text as well as the rest of the forum.  The dark theme isn't quite as bad, though.  At least it's readable.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 08 January 2010, 11:29:04
Quote from: keyb_gr;149184
:Cry:


Hm... I thought the forum's automatic image resizer would take care of the wide pictures, but apparently it does not in this case. ;(

I could reduce the image sizes, but I'm afraid that some important details will become invisible then. Suggestions?
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Fri, 08 January 2010, 12:15:15
Yesss....

very nice project.

Well done!

Spec57
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 08 January 2010, 12:18:03
This looks fantastic...I wonder how adaptable this would be to 122-key terminal keyboards?

Would just need to compensate for the larger and different matrix (easier said than done I'm sure).
Title: Making a cheap Model M USB controller
Post by: keyb_gr on Fri, 08 January 2010, 12:54:19
Quote from: Mnemonix;149187
Hm... I thought the forum's automatic image resizer would take care of the wide pictures, but apparently it does not in this case. ;(

This has been on the "things to bug iMav with" list for a while...
Quote
I could reduce the image sizes, but I'm afraid that some important details will become invisible then. Suggestions?

Here's the worst offender in terms of width, brought to half size in XnView with the tried and true Lanczos algorithm:

Anything missing?
Quote from: ripster;149189
Leave it the way it is.  Bigger pics are more important that minor scrolling issues.  There is a light background option too at Geekhack.  Of course if his monitor was CALIBRATED it wouldn't even have that issue.

Content is King.

:mmph:

If it takes enhanced geek wizardry to REDUCE the original problem of 1/3 unreadable text to a minor scrolling issue mainly noticeable on slower machines like mine, I would consider it anything but negligible. That, and I don't see why I would have to apologize for using a "mere" SXGA monitor. Ridiculous. And of course I'm using the light theme, but that one still has a dark border.

Sometimes I enjoy smartass comments as much as the plague.
Title: Making a cheap Model M USB controller
Post by: itlnstln on Fri, 08 January 2010, 13:27:20
You're swine, ripster.
Title: Making a cheap Model M USB controller
Post by: itlnstln on Fri, 08 January 2010, 13:40:09
I wonder if you could use this to build controllers for other keyboards, say, f*cked up Fukkas.
Title: Making a cheap Model M USB controller
Post by: msiegel on Fri, 08 January 2010, 14:06:01
Quote from: ripster;149243
How come Stupid Americans haven't built this before???


i believe that's the non-usb version, suitable for PS/2. and you'd also need to build or buy a programmer...
Title: Making a cheap Model M USB controller
Post by: roadblock2thesun on Fri, 08 January 2010, 20:55:14
Excellent post... I had been reading through the other thread ripster mentioned and thinking "I wish someone would post a tutorial."

Thank you again
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 09 January 2010, 13:16:38
Quote from: keyb_gr;149224
Anything missing?


It really sucks reading this on my tiny 1024x768 laptop screen. I've down-scaled all pictures to a width of 800 pixels, and attached two zip files containing the full-size versions of the pictures. The page is more readable now, and if someone needs the bigger pictures they are still there.

Quote from: ripster;149243
How come Stupid Americans haven't built this before???


The American version is called RUMP, linked from the article. :) The hardware is very similar to Dulcimer.

Quote from: itlnstln;149247
I wonder if you could use this to build controllers for other keyboards, say, f*cked up Fukkas.


Well, the software is designed to be easily adaptable for other keyboards, but it is not fully generic as AIKON. Each keyboard model needs a specific firmware that has the keyboard matrix hard-coded, but most of this code is generated from a matrix definition file. The software is really the most complicated thing in this project.

The hardware described in the article is specific to the Model M: the board size and placement and types of the connectors are made so that the controller can be used as a drop-in replacement for the original controller. Other than that, it could also be used for other keyboards. It's just a matter of adapting the software.
Title: Making a cheap Model M USB controller
Post by: kishy on Sat, 09 January 2010, 13:23:40
Quote from: ripster;149533
How about my programming the controller question.  Do you need special HW or can this be done somehow with a simple USB to PC connecton to load the bootloader?

This. Want know.

Brain shutting down. Ebay seller responses killing cells. Self protection time.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 09 January 2010, 13:37:13
Quote from: ripster;149533
How about my programming the controller question.  Do you need special HW or can this be done somehow with a simple USB to PC connecton to load the bootloader?


Ah, you'll need a programmer for AVR microcontrollers. There are lots of different models available, you can even build them yourself. I've bought a kit for ~15 Euros off from EBay: PCB, components, and pre-programmed microcontroller for this (http://www.fischl.de/usbasp/).

Hm, maybe I can write more about this tomorrow, no time left now. :)
Title: Making a cheap Model M USB controller
Post by: msiegel on Sat, 09 January 2010, 13:50:21
this is why i got a teensy... it has usb, and can program *itself*. uses the arduino software.

at $20, this was easier on my simple-minded brain :)  the $24 one has way more i/o pins if needed.

otherwise... AVR programmers @ adafruit (http://www.adafruit.com/index.php?main_page=index&cPath=16)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 10 January 2010, 12:35:07
Quote from: ripster;149544
Would this work?


Both would work, I think, even if the descriptions do not list the MCU types they can program.
That assembly kit is really cheap and should be good enough. My kit looked similar and took maybe an hour to make.

This (http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=160319528563) and this (http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=170418592872) should be OK, too. The USBtinyISP at adafruit is also fine and comes with a case.

The question is which software you will be using to speak with the programmer. All of the devices mentioned so far are supported by AVRDUDE (http://www.nongnu.org/avrdude/), an open source tool which I am using all the time. There are also pre-compiled binaries for Windows available somewhere.
There is also a whole IDE offered by Atmel (AVR Studio) which can be used to program their MCUs, but I never took a closer look at that one. Hence, I don't know which programmer types it would support.

In any case, you'll need a "non-standard" cable to attach the programmer to the controller board via the single-row 6-pin header. I'll add the pinout to the article later.

Note that once the AVR has been programmed with the boot loader image, the main firmware image can be uploaded and upgraded through a direct USB connection without the help of a programming device. You'll need a tool called BootloadHID (http://www.obdev.at/products/vusb/bootloadhid.html) for this, which is also included in my source tree. There are also pre-compiled binaries for Windows available, I think.

Quote from: msiegel;149543
this is why i got a teensy... it has usb, and can program *itself*. uses the arduino software.


The teensy comes with an AVR with a pre-programmed boot loader so that no additional programming devices are required. Very convenient, and also a good way to get hand on the AVRs with USB support in hardware.

It might be a bit harder to make a drop-in replacement controller board since teensy is a complete development board, not only a chip. The keyboard controller will also be more expensive when based on the teensy (if you are ignoring the extra cost for the AVR programmer that would be required without a teensy, that is).

msiegel: are you using the hardware USB feature of the ATMEGA32U4 in the firmware?
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 10 January 2010, 12:46:51
Quote from: kishy;149211
This looks fantastic...I wonder how adaptable this would be to 122-key terminal keyboards?


As long as we are not talking about capacitive switches (Model F), it should not be too hard.

Quote from: kishy;149211
Would just need to compensate for the larger and different matrix (easier said than done I'm sure).


Figuring out the matrix can be a bit tedious, but that's pretty much all that needs to be done to get the firmware working. Then you'll need to design the controller board, which is most likely a matter of figuring out the controller board dimensions and placing the connectors onto it.

If you know the keyboard matrix already, I can add it to the firmware sources and make firmware images for it.
Title: Making a cheap Model M USB controller
Post by: exia on Sun, 10 January 2010, 12:49:39
looks like a huge waste of time, you couldn't just slap a small heatsink on the old controller?
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 10 January 2010, 12:57:30
Quote from: Mnemonix;149812
As long as we are not talking about capacitive switches (Model F), it should not be too hard.



Figuring out the matrix can be a bit tedious, but that's pretty much all that needs to be done to get the firmware working. Then you'll need to design the controller board, which is most likely a matter of figuring out the controller board dimensions and placing the connectors onto it.

If you know the keyboard matrix already, I can add it to the firmware sources and make firmware images for it.

I don't know it. Has anyone cracked one open for a bolt mod or anything?

I've got a 1986 122-key model m for sale. Price drop is in order for someone who publicly promises to provide the matrix info to Mnemonix since that will, at least eventually, help me get a new controller made for one or both of my two.

Edit:
Unless of course I can just go at it with a multimeter without fully disassembling the membrane assembly...in which case I'll get on that for you but I'm not sure how.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 10 January 2010, 14:05:22
Quote from: exia;149813
looks like a huge waste of time, you couldn't just slap a small heatsink on the old controller?


A heat sink won't get me USB connectivity and Colemak in hardware.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 10 January 2010, 14:08:42
Quote from: kishy;149820
Edit:
Unless of course I can just go at it with a multimeter without fully disassembling the membrane assembly...in which case I'll get on that for you but I'm not sure how.


If you can find the time to do it, that would be great. Is there a picture of the original controller somewhere on the net? Are the connectors similar to those on the M controller?
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 10 January 2010, 14:18:58
Quote from: Mnemonix;149845
If you can find the time to do it, that would be great. Is there a picture of the original controller somewhere on the net? Are the connectors similar to those on the M controller?


There should be photos in my giant thread (see signature). In the meantime I'll try to get clearer shots.

Connectors are the same type as a normal M but one or both is longer.
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 10 January 2010, 14:28:59
And here's the 1386887 controller. A concern: the connectors will be routed somewhat differently from the Boscom. This probably wouldn't involve any changes to the actual matrix except routing, right?

(http://geekhack.org/attachment.php?attachmentid=7240&stc=1&d=1263155326)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 10 January 2010, 15:42:03
That's a 20x8 matrix then. And it's a good thing that the keyboard doesn't have LEDs, because there are not enough I/O pins for the matrix AND the LEDs. Otherwise we would need an additional shift register and 8 diodes to free up some I/O pins--cheap, but somewhat annoying.

Are there variations of the 1386887 with LEDs?

Quote from: ripster;149853
Here's the matrix.


The pictures of the Boscom matrix are helpful for tracing the matrix with the multimeter quickly. Perhaps they are even good enough for tracing it visually.

Quote from: kishy;149857
And here's the 1386887 controller.


Wow, what are all those jumpers on the controller for? Configuring the terminal type? (Maybe I should read your thread...)

Quote from: kishy;149857
A concern: the connectors will be routed somewhat differently from the Boscom. This probably wouldn't involve any changes to the actual matrix except routing, right?


You mean the matrix sheets have their connectors in other locations? That's not a problem if the matrices are the same, from a software point of view. The controller boards for IBM and Boscom keyboards would be based on the same circuit diagram, but the physical layouts would have to be designed separately to fit into the keyboard.
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 10 January 2010, 16:13:23
Quote from: Mnemonix;149874
That's a 20x8 matrix then. And it's a good thing that the keyboard doesn't have LEDs, because there are not enough I/O pins for the matrix AND the LEDs. Otherwise we would need an additional shift register and 8 diodes to free up some I/O pins--cheap, but somewhat annoying.

Are there variations of the 1386887 with LEDs?


Yeah, no LEDs. Would be nice to implement though, it's one of my hopes in having a new controller (which is why the AIKON looks so tasty I think).

The original terminal boards will not have LEDs (for the most part, I think there were 101 key versions almost exactly like a normal M that did have them), but later ones do, and terminal emulator ones do (such as ripster's former Boscom...pretty sure that had LEDs).

Quote from: Mnemonix;149874
The pictures of the Boscom matrix are helpful for tracing the matrix with the multimeter quickly. Perhaps they are even good enough for tracing it visually.


I am concerned that for whatever reason the matrix may be different. I don't see why it would be but it's a concern we need to be prepared to address.

Quote from: Mnemonix;149874
Wow, what are all those jumpers on the controller for? Configuring the terminal type? (Maybe I should read your thread...)


The jumpers take the place of DIP switches on certain models. They set the keyboard ID and on some keyboards are labeled as "KBDID A" and "KBDID B" in two segments.

I forget what ID is what, but the configuration shown there *should* be for a normal 101-key.

Quote from: Mnemonix;149874
You mean the matrix sheets have their connectors in other locations? That's not a problem if the matrices are the same, from a software point of view. The controller boards for IBM and Boscom keyboards would be based on the same circuit diagram, but the physical layouts would have to be designed separately to fit into the keyboard.


Yeah, I know it makes no difference electrically, but that's what my concern is...possibly a different actual matrix on account of the different position of the connectors. I don't see why it would be though, it's still on the top edge. Again, just something to be ready for in case it happens to be the case.
Title: 122 key terminal keyboard - the matrix
Post by: Specter_57 on Sun, 10 January 2010, 21:48:56
That photo of the 122-key controller, the second-largest IC is a 4-16 line MUX, and so there are actually spare unused I/O lines, based on a schematic I have seen for this item, courtesy of Keyboard Babel.

And I have mapped out the matrix of my IBM 1390702 122-key terminal keyboards.


Anyway, I have attached to this posting a photo of the keyboard matrix row/columns assignments.

Maybe of use to someone here.

Hopefully my image and notes are clear enough.
(http://geekhack.org/attachment.php?attachmentid=7266&d=1263181593)



Enjoy

Spec57
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 11 January 2010, 04:26:31
Quote from: Specter_57;149921
That photo of the 122-key controller, the second-largest IC is a 4-16 line MUX, and so there are actually spare unused I/O lines, based on a schematic I have seen for this item, courtesy of Keyboard Babel.

And I have mapped out the matrix of my IBM 1390702 122-key terminal keyboards.


Anyway, I have attached to this posting a photo of the keyboard matrix row/columns assignments.

Maybe of use to someone here.

Hopefully my image and notes are clear enough.

Enjoy

Spec57

3197 - yes, that helps, thanks! That's a real terminal keyboard and is scancode-compatible with my big 1986 ones, so surely the matrix is the same.

Not to say the Boscom isn't...there's just no way to be 100% sure without checking. Since that 1390702 is for a 3197 and 3197s are one of the interchangeable terminal types (with regards to keyboard compatibility) it's gotta be the same.
Title: Making a cheap Model M USB controller
Post by: DreymaR on Mon, 11 January 2010, 04:54:24
Wow, this is some awesome work! It might be the thing for getting a Colemak board on my PS3, even. Then it'd have to support some cheap sacrificeable keyboard that I have lying around...

Just downloaded and started browsing your code. One thing: It's 'Tarmak', not 'Tarpak' and its full name is 'Tarmak (transitional Colemak)'... I think. The idea is that like a tarmac it's paving the way!  :)  I'm quite proud of it, to be honest, and honored if you'll want to implement it.

The code would be as follows; tarmak1.map (Phase 1 - LUI only):
Code: [Select]
KEY_U KEY_L
KEY_I KEY_U
KEY_L KEY_I


tarmak2.map (Phase 2 - right hand remapped apart from 'P'):
Code: [Select]
KEY_E KEY_smcol
KEY_Y KEY_J
KEY_U KEY_L
KEY_I KEY_U
KEY_O KEY_Y
KEY_J KEY_N
KEY_K KEY_E
KEY_L KEY_I
KEY_smcol KEY_O
KEY_N KEY_K


What's the VK_102 key called, by the way; is that the 'KEY_Euro'? I'd like to do the ZXCVB< ergonomic shift while I'm at it. Would be wonderful if that could be done independently from the QWERTY/Colemak/Tarmak remaps since it can be used in any of those layouts (albeit not in Dvorak obviously... that I've heard of at least; some Dvorak users might want to do it there too maybe?).

Code: [Select]
KEY_Euro KEY_Z
KEY_Z KEY_X
KEY_X KEY_C
KEY_C KEY_V
KEY_V KEY_B
KEY_B KEY_Euro
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 10:26:25
Quote from: kishy;149876
Yeah, no LEDs. Would be nice to implement though, it's one of my hopes in having a new controller (which is why the AIKON looks so tasty I think).


OK, with LED support then. :)

Quote from: kishy;149876
I am concerned that for whatever reason the matrix may be different. I don't see why it would be but it's a concern we need to be prepared to address.


I guess you'll need to check this with a multimeter. It's probably enough to check just for 3 or 4 different keys if they are on the same rows and columns as given in Spec's picture. You'll need to find out which pin is "pin 1" on the two connectors first. Left Control is on row 1, column 1, so your multimeter should show 0 Ohm (or beep) when holding the probes to the correct pins and pushing the Control key. If there are more keys in the expected location, just assume that your matrix is the same. We can always adapt it later.

Quote from: Specter_57;149921
That photo of the 122-key controller, the second-largest IC is a 4-16 line MUX, and so there are actually spare unused I/O lines, based on a schematic I have seen for this item, courtesy of Keyboard Babel.


So they are using the chip to drive 16 of the 20 matrix rows? We could do the same for the replacement controller instead of using a shift register, depending on the total cost and availability of the parts.

Quote from: Specter_57;149921
And I have mapped out the matrix of my IBM 1390702 122-key terminal keyboards.


Cool! I've created the matrix file based on your picture--seems to work out well. My script generates the same matrix that you have drawn with O's and X's (albeit transposed).

As a reference for the key labels I have used the picture from this post (http://geekhack.org/showwiki.php?title=Island:7358).
There are only a few keys that I couldn't find USB equivalents for: "PA1/Dup", "Attn", "ErEOF", and the two blank keys on the far left in the bottom row. What is the purpose of these keys?

Quote from: DreymaR;149975
Wow, this is some awesome work! It might be the thing for getting a Colemak board on my PS3, even. Then it'd have to support some cheap sacrificeable keyboard that I have lying around...


Thanks a lot! :)
If you are planning to mod some cheap keyboard, make sure that you can attach the replacement controller to the matrix sheets somehow. The connectors are likely to have much finer pitch than the 2.54 mm on the old IBMs. Otherwise I'll happily help adding support for it to the firmware.

Quote from: DreymaR;149975
Just downloaded and started browsing your code. One thing: It's 'Tarmak', not 'Tarpak' and its full name is 'Tarmak (transitional Colemak)'... I think. The idea is that like a tarmac it's paving the way!  :)  I'm quite proud of it, to be honest, and honored if you'll want to implement it.


Oops, a typo; but that was only in the TODO file.
Thanks for writing down the key map files, now I can remove that item from the TODO file. :) I'll add them to my source tree.

Quote from: DreymaR;149975
What's the VK_102 key called, by the way; is that the 'KEY_Euro'? I'd like to do the ZXCVB< ergonomic shift while I'm at it. Would be wonderful if that could be done independently from the QWERTY/Colemak/Tarmak remaps since it can be used in any of those layouts (albeit not in Dvorak obviously... that I've heard of at least; some Dvorak users might want to do it there too maybe?).


Yes, it's called KEY_Euro for some weird reason. Maybe I should check the USB HID specs in order to find a better name based on the name it has been given there.
Is that mapping complete? I can add it to the source tree then.

The shift mapping can be applied independently already since the script that processes the matrix definitions and key mappings can handle multiple map files. At least with Colemak it will work because the affected keys are not part of the Colemak mapping.
It doesn't work for Dvorak at the moment because the script simply assumes that all mappings are independent (otherwise the order in which the map files are passed to the script would become important). I'll think about a good solution.
Title: Making a cheap Model M USB controller
Post by: DreymaR on Mon, 11 January 2010, 11:28:10
Quote from: Mnemonix;150054
Yes, it's called KEY_Euro for some weird reason. Maybe I should check the USB HID specs in order to find a better name based on the name it has been given there.

Is that mapping complete? I can add it to the source tree then.

The shift mapping can be applied independently already since the script that processes the matrix definitions and key mappings can handle multiple map files. At least with Colemak it will work because the affected keys are not part of the Colemak mapping.
It doesn't work for Dvorak at the moment because the script simply assumes that all mappings are independent (otherwise the order in which the map files are passed to the script would become important). I'll think about a good solution.


- I think I saw it called KEY_Euro2 in a USB spec? Even worse name, haha.

- Yes, the ZXCVB shift mapping is complete; it's a small but nice trick that 'anyone can use'.

- I don't need it to work for Dvorak and I doubt any Dvorak users are all that interested at the moment. If QWERTY and Colemak users can use it, I'm happy.

Much wants more as they say: Could there be an on-the-fly-remapping/extending possibility like the HHKB2's Fn key ('Extend' mode in PKL)? E.g., I press CapsLock and now the UNEI keys become bona fide arrow keys (and much more! - hopefully including making some keys into modifier keys!). Or, I press Ctrl+CapsLock and now the UNEI keys will send 5 arrow key presses per click until I release CapsLock again. Or, I press Alt+CapsLock and now the LUYNEIKM,. keys become the NumPad... etc etc.
Title: Making a cheap Model M USB controller
Post by: Shawn Stanford on Mon, 11 January 2010, 11:41:22
Quote
There are only a few keys that I couldn't find USB equivalents for: "PA1/Dup", "Attn", "ErEOF", and the two blank keys on the far left in the bottom row. What is the purpose of these keys?

PA1 is an interrupt key
Dup copies the character from the previous line to the current line
Attn is an interrupt key
ErEOF erases from the cursor positon to the end of the current unprotected area

Awesome thread, BTW.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Mon, 11 January 2010, 11:48:39
Hello all.

Glad someone here is finding my tracing of the keyboard matrix of interest.

Pay close attention to how I numbered the illustrations of the cct connectors, ie number 1-end on the top, and 0-end on the bottom.

I see microcontroller circuits listing '0' as the first numeral, and on the cct board itself, '1' as the first numeral.  That is why I labelled them as I did..

In previous postings here on GH I attached pics of my cct board for the '0702.

See here:
My keyboard CCT board:

http://geekhack.org/attachment.php?attachmentid=2313&d=1240204836

http://geekhack.org/attachment.php?attachmentid=2312&d=1240204827

http://geekhack.org/attachment.php?attachmentid=2314&d=1240204843

and the schematic of that cct board, less the driver IC and Jumpers contacts at the top center of the schematic...otherwise it is identical (courtesy of Keyboard Babel):

the schematic:  http://www.kbdbabel.org/schematic/kbdbabel_doc_ibm3197_kbd.pdf

A pic of my particular keyboard is attached below.
.....

Ripster, thanks for the pics of the membranes for your keyboard.
I never took my keyboards down far enough to see the membranes themselves.

.....
Shift registers are a reasonable way to expand both inputs and outputs...look at this:

http://homepages.which.net/~paul.hills/Software/ShiftRegister/ShiftRegister.html

looks like all inputs and outputs could be handled with three lines...not to say that other problems could arise if that was done...

...and several other possibilites come to mind as well.

...

And since there is talk of Colmak and DVorak here...look at 'XPert Keyboard':  http://www.xpertkeyboard.com/index.htm

...

Enough for now.

Spec57
............
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 13:36:36
Quote from: DreymaR;150064
- I think I saw it called KEY_Euro2 in a USB spec? Even worse name, haha.


No Euro2, but Int1, Int2, ..., Int9, Lang1, Lang2, ..., Lang9. I think they are called like that in the specs. The Euro key might have a better name, though.

Quote from: DreymaR;150064
- Yes, the ZXCVB shift mapping is complete; it's a small but nice trick that 'anyone can use'.


OK, added.

Quote from: DreymaR;150064
Much wants more as they say: Could there be an on-the-fly-remapping/extending possibility like the HHKB2's Fn key ('Extend' mode in PKL)? E.g., I press CapsLock and now the UNEI keys become bona fide arrow keys (and much more! - hopefully including making some keys into modifier keys!). Or, I press Ctrl+CapsLock and now the UNEI keys will send 5 arrow key presses per click until I release CapsLock again. Or, I press Alt+CapsLock and now the LUYNEIKM,. keys become the NumPad... etc etc.


"Simple" function keys that switch between alternative layouts should be possible and easy to implement; in fact, I planned to implement numpad emulation that way. Arrow keys on the main cluster would be exactly the same.

You can do this already with the current firmware by programming an alternative layout into some slot and activating it by hitting Scroll Lock followed by the number of your alternative key map. When you are done using the other key map, switch back to your main map. That would be clumsy, so a function key, as I have planned it, would act as a temporary, quick switch between the current and some alternative map. Of course, multiple function keys and combinations thereof could be supported.

I thought about on-the-fly remapping, but thought it would not be worth the trouble (because I could map everything "offline"). Technically, it would not be too difficult, I think, but I'm sure there are some pitfalls.

The Ctrl+CapsLock thing is more complicated, because it would involve some kind of macro playback which isn't planned at all at the moment. This is something for the future or the GeeKey controller (should it really be made some day).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 13:47:01
Quote from: ripster;150067
Plus, it supports AVRdude - which I saw as a sign of good karma for me since I have no idea what I am doing.


No problem, I didn't have a clue a few months ago, too. :lol:
It all becomes obvious once you have it all in front of you.

That Aussie device was available here, too, but the kit I've bought won just because it was cheaper then.

Quote from: ripster;150067

Thanks for the suggestion Mnemonix.  This one also appears to have excellent documentation.  PDF users manual link (http://www.protostack.com/download/Users%20Guide%20%28AC-PG-USBASP-UG-V1.1%29.pdf).


Nice docs. Man, so many instructions just to get the thing working on Windows... ;)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 14:02:20
Quote from: Shawn Stanford;150068
PA1 is an interrupt key
Dup copies the character from the previous line to the current line
Attn is an interrupt key
ErEOF erases from the cursor positon to the end of the current unprotected area


I cannot find USB key codes matching any of those. There are codes for other funny keys like "Help", "Menu", "Select", "Oper", and some more, but no interrupt keys. We could make them media keys, though...

I wonder which codes a USB converter would send when seeing the scan codes for these keys.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 14:20:49
Quote from: Specter_57;150070
Pay close attention to how I numbered the illustrations of the cct connectors, ie number 1-end on the top, and 0-end on the bottom.

I see microcontroller circuits listing '0' as the first numeral, and on the cct board itself, '1' as the first numeral.  That is why I labelled them as I did..


Computer vs. human thinking. :)
I didn't notice that (only starred at the row/column assignments all the time), thank you.

Quote from: Specter_57;150070
looks like all inputs and outputs could be handled with three lines...not to say that other problems could arise if that was done...


Two lines are enough even since CLEAR can be emulated by shifting a number of zeros into the register. Slower, but only required at initialization time and saves a line.

Quote from: Specter_57;150070

...and several other possibilites come to mind as well.


If they are better than shift registers (i.e., cheaper and working reasonably well), feel free to post them. :)

Quote from: Specter_57;150070
And since there is talk of Colmak and DVorak here...look at 'XPert Keyboard':  http://www.xpertkeyboard.com/index.htm


That looks... awkward? Don't know. Two E keys. :lol:
Did anyone ever try that layout?
Title: Making a cheap Model M USB controller
Post by: Shawn Stanford on Mon, 11 January 2010, 14:56:01
Quote from: Mnemonix;150082
I cannot find USB key codes matching any of those. There are codes for other funny keys like "Help", "Menu", "Select", "Oper", and some more, but no interrupt keys. We could make them media keys, though... I wonder which codes a USB converter would send when seeing the scan codes for these keys.

Well, the rough equivalent to PA1 would probably be Ctrl-Break, and Attn would probably be SysReq. ErEOF equates to the key sequence '++, ', and there is nothing like the Dup key (also known as 'CopyUp').
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 11 January 2010, 16:43:38
Quote from: Shawn Stanford;150089
Well, the rough equivalent to PA1 would probably be Ctrl-Break, and Attn would probably be SysReq. ErEOF equates to the key sequence '++, ', and there is nothing like the Dup key (also known as 'CopyUp').


OK, I'll map Attn to SysReq then.

PA1 is currently mapped to Insert because of its location, so there are two Insert keys now... Probably not a popular choice.
ErEOF is "Execute" (whatever that is) and the two blank keys are Int1 and Int2 for now ("International" 1 and 2, according to the specs).
Title: Making a cheap Model M USB controller
Post by: DreymaR on Tue, 12 January 2010, 07:32:00
QUOTE=Mnemonix]I thought about on-the-fly remapping, but thought it would not be worth the trouble (because I could map everything "offline"). Technically, it would not be too difficult, I think, but I'm sure there are some pitfalls.[/QUOTE]

Oh, sorry: I didn't actually mean on-the-fly remapping, just the ability to switch to some layouts temporarily through the use of 'extend'/'Fn' key(s) so that navigation/NumPad/Multimedia/what-have-you keys can be made readily available on the main key block.

Quote from: Specter_57;150070
And since there is talk of Col[e]mak and DVorak here...look at 'XPert Keyboard':  http://www.xpertkeyboard.com/index.htm


You know, mapping Q and K to the home row and then taking money for it loses my respect. (I know, they thought the pinkies are weak but they aren't when they don't have to perform awkward stretches - at least, mine certainly aren't!) And duplicating the 'e' key loses the ';' key which seems more of a confusing sacrifice to me than it's worth. They fail to fix the awkward position of the common letter 't' (and others). And why the hell did they move the 'x' for instance - just so they could spell a slogan?!

Does anyone know anyone who actually uses that?

If you look at the Colemak site's list of alternative layouts (http://colemak.com/Alternative_layouts) you'll see that Shai Coleman rates it among the worst options so I think he'll agree with my sentiments for what that's worth. The whole thing strikes me as very odd indeed - and they claim to have loads and loads of downloads and happy customers?
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Tue, 12 January 2010, 08:22:19
Hey...I'm NOT promoting them (xpert keyboard layout...) in any way.

Just thought it was interesting....but I do not think it's worth paying for.

As was mentioned above, it was noticed there were two 'e' keys.
That is not so silly as it may at first seem...the letter 'e' is the most common letter in the English language.

Sam Morse figured that out when he was designing his code. I read somewhere a long time ago that he apparantly counted lettters from several different newspapers and did a frequency analysis of the letter usage...and so common letters had the shortest 'dit-dah' sequence, and uncommon ones longer sequences.

http://en.wikipedia.org/wiki/Morse_code
and for fun:
http://morsecode.scphillips.com/jtranslator.html

Dvorak...Colmak...or some combination of the better features of the two (a 'Col-vorak?  a Dvor-mak..keyboard.?) is something I've been thinking about for some time, off and on.

A controller board as is being discussed here and in other threads lends itself to remaps, among other things, obviously.

And...i'll examine that link shortly, thank you for posting it.

..........

And in a previous post, where I was talking about shift-register I/O expansion, and I mentioned there are more possibilities...

Basically I was thinking of various combinations of master/slave controllers to take care of pin shortages...but that (for me anyway) assumes DIP devices at 2.54mm (0.1") centers, not surface mount.
Being old-school, I use those devices on perf-board, and sometimes wire-wrap.

If SMD and other packages are acceptable, then simply get a device with the appropriate number of I/O pins and be done with it...no fooling around.

....

Also, and again NOT promoting this, only mention it for general reading interest...take a look at the keyboard encoder chips on this page:

Sprintek:
http://www.sprintek.com/

......
Spec57
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 12 January 2010, 10:56:28
Quote from: Specter_57;150279
And in a previous post, where I was talking about shift-register I/O expansion, and I mentioned there are more possibilities...

Basically I was thinking of various combinations of master/slave controllers to take care of pin shortages...but that (for me anyway) assumes DIP devices at 2.54mm (0.1") centers, not surface mount.
Being old-school, I use those devices on perf-board, and sometimes wire-wrap.

Ah, a co-processor for handling matrix I/O. :)

Quote from: Specter_57;150279
If SMD and other packages are acceptable, then simply get a device with the appropriate number of I/O pins and be done with it...no fooling around.

I wouldn't mind if someone were up to build a controller with SMD parts on it, or to come up with completely new designs for keyboards that I don't have. It would simply mean that I couldn't build one myself at the moment, but I could still help with the software.
I'm focusing on DIP devices because that's what's easiest for me to handle.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Tue, 12 January 2010, 14:35:23
Mnemonix:
You said: "I'm focusing on DIP devices because that's what's easiest for me to handle. "

Exactly.  I agree.
The DIP devices and 2.54mm grid are what I prefer myself...and as mentioned...I have used perf board (and a couple of times corrugated cardboard) for assembled projects and breadboards for testing out circuits.and short-term projects.
But a circuit board is to be preferred, one that can be made at home that is...using these DIP devices.

In my opinion, like you, I feel these devices and format are all around easier to use.
And if someone is using some of the older keyboards then space inside and absolute compactness of the controller board isn't that much of an issue.

Not hard to stuff a lot of stuff into one of these older keyboards we all seem to have such affection for, is it?  :-)

....

I do believe that ATMega devices can be connected to each other via I2C bus...?

and here also is an interesting idea, concept, for use with a breadboard.

http://www.ladyada.net/make/pshield/index.html


..............
Spec57
Title: Making a cheap Model M USB controller
Post by: spolia optima on Wed, 13 January 2010, 00:33:32
I just want to say that this mod (and thread) is killer. A lot of it is still over my head, but I've learned quite a bit in these 2 pages.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 13 January 2010, 02:48:24
Quote from: Specter_57;150367
(and a couple of times corrugated cardboard)

That's wild! :)

Quote from: Specter_57;150367
But a circuit board is to be preferred, one that can be made at home that is...using these DIP devices.

I'd love to be able to make my own circuit boards, but I don't have the equipment and don't want to worry about disposal of chemicals. Cutting wires and soldering them, however, might consume at least at much time as required to etch a PCB...
I think I'll try the toner transfer method (http://thomaspfeifer.net/direct_toner_pcb.htm) one day since there's no developer solution involved. Only some acid to take care off.

Quote from: Specter_57;150367
I do believe that ATMega devices can be connected to each other via I2C bus...?

Yes, I think there is some support for I2C built in, but I haven't used it yet. I've only used the RS232 interface, but not for the keyboard controller.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 13 January 2010, 07:58:14
Mnemonix

I like that etching method you linked to.

Because most of my electronics projects have been one-off or only a few pieces, never got into making circuit boards much...but have helped others doing so.

So, if you are only interested in a couple or three pieces...you have to decide which method is suitable to your situation.  But that's always the case.
Always a balancing act, a compromise...and part of what makes a project fun.

And don't forget, as you likely already know...anything you have to dispose of acidic is easily neutralized by Sodium Bicarbonate (that's baking soda...  :-)  )

Acid + Base => Salt + Water.

...........

spolia optima

If you want to be overwhelmed by technical information from time to time...you are in the right place.  :-)

If you look around GH you will see a lot more of these sorts of discussion threads and postings.  Believe me...this isn't the only one.

I'm certainly no expert...some of this stuff is above my head, for sure.

...........

Spec57
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 13 January 2010, 08:10:40
Quote from: Specter_57;150492
Acid + Base => Salt + Water.


Yes, I know that. Problem is that there will still be copper residues left in the neutralized solution, so, being a heavy metal, it should not be disposed through the toilet. AFAIK, it would be illegal to do this where I live (bad for sewage treatment plants).
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 13 January 2010, 08:24:09
Yes.

You do not want to casually flush chemicals down the toilet or sewers.
Wrong morally as well as legally.

Spec57
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 13 January 2010, 12:14:46
EDIT: Schematics are outdated and not supported by the firmware anymore. See post #105 (http://geekhack.org/showpost.php?p=155620&postcount=105) or the project source tree (http://github.com/rhomann/kbupgrade/tree/master/circuits/) for updated schematics.

Here are two circuit diagrams for 122-key terminal keyboards: one with LED support, and one without. I can provide firmwares for both of them.

The connections are made so that wiring is simple in practice (hopefully), but I cannot try it myself because I don't have one of these monster keyboards. If one of you terminal keyboard owners would like to give one of them a try, please let me know if there is something that needs to be changed.
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 13 January 2010, 13:52:55
Wow, that was quick...thanks!

I'm not immediately in a position to build one (no programmer, parts not on-hand) but I'll be sure to try this out as soon as I have the supplies handy (don't hold your breath though, I'm now back in school and already exhausted).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 13 January 2010, 14:48:40
Quote from: ripster;150604
That schematic reminds me - what do the jumpers do?   I thought at first they were LED headers but they're not.


Only one of the jumpers does something meaningful at the moment, the one that is labeled KM0 in the circuit. When closed, it forces the controller to use the default QWERTY key map that is hard-coded into the controller (not stored in EEPROM). Hence the name, Key Map 0 (zero). This comes handy if you have uploaded and activated a broken key map, which, if "broken enough", may prevent you from switching to a good key map, thus bricking the device in worst case.

Before I had the software-based key map switching implemented, the key map had to be configured via the jumpers, that's why there are so many of them. Now they are just connections to unused I/O pins and should be left open. Who knows, maybe they will be of use in the future. For instance, one of them could activate the boot loader (now activated by holding down Escape on power up), clear the EEPROM, drive an LED, or something like that.

Jumper KM0 is the one closest to the microcontroller on my Model M controller. Thanks for asking, I'll add that info to the article.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Wed, 13 January 2010, 18:36:37
While I am just sourcing parts at the moment, could you by any chance do a map for a 1391406? I'm not sure I understand just how to map it myself.

I've wanted to play around with the ATMega's anyway, so making a programmer isn't too big a hassle, and will get other uses. (I plan to make a rotating platform for a Directional 2.4Ghz antenna, based on stepper motors).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 13 January 2010, 18:50:46
Quote from: InSanCen;150675
While I am just sourcing parts at the moment, could you by any chance do a map for a 1391406? I'm not sure I understand just how to map it myself.

The '406 should be the same as a '403, except for key caps, no?

The two "ISO keys" are recognized by the '401 firmware, and I have tested the controller with the '401 firmware inside a '403 and two US Minis. I think it would work with a '406, too.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 14 January 2010, 02:55:28
Quote from: ripster;150697
When I'm done I'll publish a Mouser parts list with parts for US Geekhackers.


Sorry, I forgot to include the FFC connectors on my parts list (now added). If Mouser sells these, make sure to include them on your list, too.
These tend to be hard to obtain, though. I was lucky to get mine from a nearby company as samples...

Quote from: ripster;150697
BTW - the Molex USB connectors are great - better than the cheap ones.


I only have the cheap ones (0.18 Euro), but they look similar to yours; maybe not as shiny. My electronic distributor (Reichelt) doesn't seem to have Molex connectors.
Title: Making a cheap Model M USB controller
Post by: Shawn Stanford on Thu, 14 January 2010, 09:06:15
Well, I've never done circuitry in my life (I'm a software guy), but I'm going to give this a shot. Of course: I'm going to wait a tad longer for the bolder types to beat down a path for me. Especially Kishy, who I know is going to smurf on a 122 key, which is what interests me.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Fri, 15 January 2010, 16:21:24
WRT the membrane connectors.

I suspect that using Card Edge connectors, and pushing the pins further out than normal should grip it nicely. If not, and the connections are only connected on one side, then maybe something to pad it out?

Quote from: Mnemonix;150679
The '406 should be the same as a '403, except for key caps, no?

The two "ISO keys" are recognized by the '401 firmware, and I have tested the controller with the '401 firmware inside a '403 and two US Minis. I think it would work with a '406, too.

Well, when I get a programmer together, we'll find out.
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 15 January 2010, 16:22:51
Quote from: InSanCen;151176
WRT the membrane connectors.

I suspect that using Card Edge connectors, and pushing the pins further out than normal should grip it nicely. If not, and the connections are only connected on one side, then maybe something to pad it out?


Sounds feasible to me, but spacing may be off. I think an 8-bit ISA slot would be the closest match.
Title: WRT connecters...
Post by: Specter_57 on Fri, 15 January 2010, 18:52:23
*Possibly*....

Old ribbon cables, ones with connectors for 5.25 floppy drives...force a piece of something or other in one side to wedge the membrane contacts against the metal ones...


Just a thought.

.

Spec57
Title: Making a cheap Model M USB controller
Post by: clee on Mon, 18 January 2010, 03:26:07
Whoa, this thread totally took me by surprise.

(I did the RUMP board/firmware.)

If you're looking for new-stock connectors for the keyboard matrix, these are some compatible MOLEX part numbers. I asked them for an engineering sample and they sent me 10x of each type for free, no questions asked.

0022023083 (eight pins)
0022023123 (twelve pins)
0022023163 (sixteen pins)

Unfortunately, Mouser doesn't stock them. I have verified first-hand that they're totally workable replacements for the originals, though. And actually it looks like these might be exactly the parts that the Unicomp circuit board is using.
Title: Making a cheap Model M USB controller
Post by: clee on Mon, 18 January 2010, 03:28:20
Whoa, this thread totally took me by surprise.

(I did the RUMP board/firmware.)

If you're looking for new-stock connectors for the keyboard matrix, these are some compatible MOLEX part numbers. I asked them for an engineering sample and they sent me 10x of each type for free, no questions asked.

0022023083 (eight pins)
0022023123 (twelve pins)
0022023163 (sixteen pins)

Unfortunately, Mouser doesn't stock them. I have verified first-hand that they're totally workable replacements for the originals, though. And actually it looks like these might be exactly the parts that the Unicomp circuit board is using.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 18 January 2010, 05:01:36
Quote from: clee;151713
Whoa, this thread totally took me by surprise.

(I did the RUMP board/firmware.)

Hey, nice to hear from you again (we've mailed last year)! :)

Quote from: clee;151713
0022023083 (eight pins)
0022023123 (twelve pins)
0022023163 (sixteen pins)

Do you have a number for a 4-pin connector, too (for the LEDs)?
Edit: And for a 20-pin connector for the terminal keyboards?
Then again, it should be possible to cut one of the longer connectors, and seal the open end with tape to get a 4 pin one.
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 18 January 2010, 07:28:37
Looks like 4 pin is 0022023043 (http://www.molex.com/molex/products/datasheet.jsp?part=active/0022023043_FFC_FPC_CONNECTORS.xml&channel=Products&Lang=en-US)

20 pin should be 0022023203 (http://www.molex.com/molex/products/datasheet.jsp?part=active/0022023203_FFC_FPC_CONNECTORS.xml&channel=Products&Lang=en-US)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 18 January 2010, 10:11:38
Quote from: kishy;151179
Sounds feasible to me, but spacing may be off. I think an 8-bit ISA slot would be the closest match.

I've read somewhere that someone has successfully used an ISA connector as an ersatz-connector for a 2.54 mm pitch flat cable. I cannot find that reference anymore, however.
An ISA connector is also rather big, so it might be challenging to use one on the controller, depending for which keyboard it would be used. And you'll have to get creative on how to keep the cable inside the connector and getting good contact. I would try to avoid applying too much force to the membrane connectors so not to rub off the traces, or even damage the foil.

Some people are reporting that they are soldering wires directly to the traces on the membrane, but I've never tried this (and won't).

This is what I did on my first prototype board (now sitting inside a 1391403) when I had no 4-pin connector:





These are two small pieces of stripboard tightly screwed together so that the contacts on the flat cable are pushed against the copper strips of one of the boards.
Only one of the stripboard pieces is making contact to the traces on the flat cable, the other piece could also be any piece of plastic or something (I think I've removed all copper from the top board seen in the second picture).
There is a small sheet of foam between the flat cable and the top piece of stripboard to help distributing the force evenly to the foil. Four wires are going from the four copper strips on the "sandwich connector" to the main board of the controller.

Note that you cannot insert or remove the flat cable on this connector without loosening the two screws and nuts (invisible below the electrical tape) that are pressing together the stripboard pieces.
This makes it a ZIF connector! :) (ZIF = zero insertion force)
Title: Connections to the membrane traces...
Post by: Specter_57 on Mon, 18 January 2010, 10:51:07
Mnemonix :

Ummm....Soldering...onto the membranes?

 I"d not think it possible...certainly risky as you said...and like you would never even consider that as do-able....

...but perhaps some sort of connection to the membrane traces using conductive ink or adhesive would work...maybe in combination with your method.

 Your method is certainly practical and effective..and proven

 Was thinking along the same lines myself...but you beat me to it, long ago it seems, and proven it"s worth.  :-)

Very Good work.  Imaginative.

..........

Spec57

.........
Title: Comment and a question or two...
Post by: Specter_57 on Wed, 20 January 2010, 12:50:44
Mnemonix:

In your revised schematic, for the 122 key terminal keyboard, post #64... I see that you implemented a shift-register to handle 8 of the column I/O lines, in imitation of the original IBM 4:16 multiplexer.

Just thinking...if you were to do that for the 8 row lines using the proper shift register and leaving the column lines direct connected...would that not have been maybe easier programming-wise as well as...well...conceptually, a "neater" design?

Also, I know your preference is USB for the interface...but would it be feasible to have this controller operate in PS/2?, perhaps mode-selectable by jumper?

BTW...This is NOT Criticism of your work in any way.

 A terrific project, and many thanks for sharing your information with us so freely.

...........

Spec 57
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 20 January 2010, 15:17:37
Quote from: specter_57;152341
Just thinking...if you were to do that for the 8 row lines using the proper shift register and leaving the column lines direct connected...would that not have been maybe easier programming-wise as well as...well...conceptually, a "neater" design?


We have different ideas of "rows" and "columns" as it seems. I've called the bunch of 20 lines the rows, and the other 8 lines the columns. No problem, just terminology.

But it's true, you could use a 74HC165 or similar to read out the 8 columns instead of driving 8 of the rows with a 74HC164 as done in the current design. Instead of the 8 diodes to protect the outputs of the 74HC164 from themselves, you'd have to use 8 pull-up resistors to pull the columns to a defined high level (the rows are driven in inverted logic, so that the active row is pulled to low level). Resistors and the 74HC165 are slightly more expensive than diodes and the 74HC164, respectively, at my electronics distributor; so I could use this as an excuse for the design decision. :wink:

The real reason, however, is that I have simply re-used my design (thus part of the firmware) for the IBM M4-1, which has 9 columns. I needed even more MCU I/O pins on that design for the trackpoint, so I've used 2 chained shift registers to drive 16 of the rows. It was the better choice for that design, but probably not for the terminal keyboard. I just didn't consider this alternative anymore.

I think we should change the design to use a 74HC165 for reading the columns. It's really nicer, also from the firmware's point of view. The matrix scan rate would suffer a bit, but that's most probably not a problem here.

Quote from: specter_57;152341
also, i know your preference is usb for the interface...but would it be feasible to have this controller operate in ps/2?, perhaps mode-selectable by jumper?


Hm, maybe it could be possible to incorporate the code from Inornate's ps2avr project. Don't know how hard this would be, though.

I'm bound to say, however, that support for PS/2 mode has very low priority for me. It's not that I dislike PS/2, but the industry will stop supporting it sooner or later, no matter what the gamers say (gamers are supposed to kick out their money for game consoles). So, it's unlikely that I will start work on that any time soon. PS/2 input is a different story, though...

If someone else is willing to add PS/2 support, then I will happily provide any help needed, of course.

Quote from: specter_57;152341
A terrific project, and many thanks for sharing your information with us so freely.


That's what's so cool about open source: you've noticed a problem, and because you could see the problem, it was possible for you to come up with a better solution, thus improving the project. Impossible with closed, proprietary stuff.
Title: Making a cheap Model M USB controller
Post by: M13 on Wed, 20 January 2010, 18:34:27
Ok, I've been following this discussion for a little while now, and I have a question about the idea of the SD card.. Will the said controller with SD card be recognized by any computer in ANY way as being a form of portable media or other data storage device? The reason I ask is only because some companies don't condone (or just all together banish) the use of flash or writeable media. Though a keyboard seems harmless, it could have repercussions if this was the case. I, for one, take my daily driver keyboard to work. I'm not suggesting that the SD card be removed, I just would like to know so I don't get the old "security escort to your exit interview" routine for hooking up the new controller at work. I know I could just take the safe route and not use a modded one at work, but what's the fun in that? Besides, it's become a conversation piece when work is slow "Hey, what mod are you going to do next? A coffee dispenser?" etc. *sigh* Some people just don't get it...
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 20 January 2010, 19:41:00
Actually took a look on Google for "ps2avr" and so the answer is a tentative "yes" to the PS\2 thing.  Of course it is possible to use that protocol.

.....
And...an amusing thought of taking the shift register thing to it"s silly extreme...ha ha...use a 74HC165 chained to three 74HC595, all of them 8-bit shift registers...the first one for the rows...and the 74HC595s for columns....for an 8x20 grid setup...you"d have four SR outputs free after taking all matrix I/O into account...and these four lines could be used for the three lock LEDs...and the last to perhaps drive an audio beeper...and all for the cost of two or three I/O lines on the MCU !!

.....
Mnemonix:

I look at the physical keyboard and assume in my mind...8 rows, 20 columns, as it gives the same sort of horizontal layout.

You and I have our row-column definitions reversed ...haha  you"re in portrait mode, me in landscape mode.
Perhaps it's a matter of European thinking vs North American thinking.

:smile:


----
Spec57

...end
Title: Making a cheap Model M USB controller
Post by: clee on Thu, 21 January 2010, 02:08:07
I'm excited to see what kinds of things you guys can do with the shift registers. I'm a lazy bastard, and so I've moved on to MCUs with more GPIO pins and USB in hardware (I reimplemented the RUMP design on the PIC18F4450, and I'm seriously considering reimplementing everything AGAIN on a Cortex M3 because those have up to 51 GPIO pins).

I'll be way more blunt, though: Screw PS/2. USB is the way forward! Until the next hot input standard comes along...

Too bad bluetooth isn't more readily hackable and available. I'd love to have a Model M with native bluetooth built in.

(Also, a shout out to Mnemonix, who I didn't realize I already knew. About time you posted this stuff here! :)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 21 January 2010, 04:48:16
Quote from: M13;152502
Ok, I've been following this discussion for a little while now, and I have a question about the idea of the SD card.. Will the said controller with SD card be recognized by any computer in ANY way as being a form of portable media or other data storage device?


The SD card idea was mentioned for the GeeKey controller, which is, unfortunately, not much more than a wish list at the moment. I've not planned SD card support into my firmware and I find it unnecessary.

Therefore, all that is recognized by the computer is a regular USB keyboard, nothing more. Because that's what I want: a simple keyboard that works well. Feature creep (http://en.wikipedia.org/wiki/Feature_creep) can easily kill a project.

Quote from: M13;152502
...so I don't get the old "security escort to your exit interview" routine for hooking up the new controller at work.


Security escorts? What a nice place to work in. :wink:
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 21 January 2010, 05:04:45
Quote from: Specter_57;152520
And...an amusing thought of taking the shift register thing to it"s silly extreme...ha ha...use a 74HC165 chained to three 74HC595, all of them 8-bit shift registers...the first one for the rows...and the 74HC595s for columns....for an 8x20 grid setup...you"d have four SR outputs free after taking all matrix I/O into account...and these four lines could be used for the three lock LEDs...and the last to perhaps drive an audio beeper...and all for the cost of two or three I/O lines on the MCU !!

Wild ideas. :) This would slow down the scan rate even more, but a cheap ATMega8 or even some ATTiny might be sufficient with this crazy approach. Ha, who needs those big MCUs with dozens of I/O pins anyway? ;)

By the way, the 74HC595 is actually nicer than the 74HC164 that I am using, because of the pin assignment. All 8 outputs are on one side of the IC. Seems easier to integrate, and there seems to be no reason why it couldn't be used as a replacement.
Is there a parallel-in serial-out register with a similar pinout?
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 21 January 2010, 05:23:05
Quote from: clee;152586
I'm a lazy bastard, and so I've moved on to MCUs with more GPIO pins and USB in hardware (I reimplemented the RUMP design on the PIC18F4450, and I'm seriously considering reimplementing everything AGAIN on a Cortex M3 because those have up to 51 GPIO pins).


Hm, that PIC18F4450 looks nice, and they come in DIL-package, too. Maybe a little short on RAM, and no EEPROM. But an external serial EEPROM is not that expensive... Too bad that Atmel doesn't offer their USB MCUs in DIP.
Do you have a web site for that project, or is it all private for now?

And an ARM Cortex would rock for sure. :)

Quote from: clee;152586
Too bad bluetooth isn't more readily hackable and available. I'd love to have a Model M with native bluetooth built in.


Ditto. Seems like Bluetooth has been crippled by patents, NDAs, and whatnot. I really don't get the advantage of this legal plague.
Title: More commentary.........again!
Post by: Specter_57 on Thu, 21 January 2010, 08:39:38
..

I"m not suggesting seriously implementing the four shift registers for I/O, of course. As mentioned, it"s a silly extreme of what is possible, not necessarily practical.
And the last I"ll mention on shift registers...are you familiar with "Johnson Counters"?
A ring, or decade counter, 10 outputs per package.
A quick 'Googling' of 74HC4017 will fill you in.

I like to use the 2.54mm center DIP devices, as mentioned in previous postings, but I do acknowledge that there are other devices with up to 51 I/O pins, or more, and they make the programming aspects easier to deal with, but the physical aspects more difficult.

As always, there is a trade off. Me, I'm not overly concerned about minimum size or minimum number of components, within reason of course.

The shift register numbers I quoted are from another reference on I/O expansion I have. (Attached below). Different and more extensive than the one I linked to several postings back.

And the 'feature creep' thing...yes that is true too.
The Open Controller project and this one seem to have much in common, and a read of both threads is of course recommended, along with many others on GH.
Talk about informational 'buffer overloading' !!

I know USB is the latest greatest...and I still like the PS/2 for mice and keyboards, as it is universal and suits my purposes.
Everyone has their idea of what is desireable, or not. Human nature.

And the idea of using a PIC...well...it seems that this project can be implemented in many different ways, many different device choices and combos.

........
Spec57

...end
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 21 January 2010, 10:44:58
Quote from: Specter_57;152671
And the last I"ll mention on shift registers...are you familiar with "Johnson Counters"?

Looks useful, thanks. I should really take some time for looking around what other ICs are available.

Quote from: Specter_57;152671
The shift register numbers I quoted are from another reference on I/O expansion I have. (Attached below). Different and more extensive than the one I linked to several postings back.

Thanks once more! :)

Quote from: ripster;152690
What Crystal Oscillators am I looking for?  Any particular part numbers you recommend?

That Mouser catalog is huge...
Look for 12 MHz, radial. Part  815-ABL-12-B2 does the job. Part 815-AB-12-B2 should be OK, too, but is taller and could be problematic in a Mini. There are even cheaper ones, but they don't give the dimensions of the package.

Are you going to make the 122-key controller or the one for the 1391401? If it's the 122-key, then we should settle its design first. Or order all of the ICs mentioned in this thread so far to play around with. :)

Edit: oh, it's the original one. Never mind.
Title: Another parts source....
Post by: Specter_57 on Thu, 21 January 2010, 11:15:08
..
I haven"t seen mentioned here.


Avnet Express.

Huge, extensive selection..

Here:

http://avnetexpress.avnet.com/store/em/EMController?langId=-1&storeId=500201&catalogId=500201&action=home

......
Spec57
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Thu, 21 January 2010, 14:29:37
..

Ripster.

AvnetExpress does have them, but difficult to find.on the Avnet site....what I did do was use the part numbers quoted by Clee and Krishy in Google.

ie for the 20 pin connecter, Molex Part #0022023203
I Googled "Molex 0022023203  Avnet"
and the result is this:

https://avnetexpress.avnet.com/store/em/EMController/Interconnect/Connector-FFC-FPC/_/N-100338?action=products&cat=1&catalogId=500201&cutTape=&hwPrefPart=&hwPrefSup=&inStock=&langId=-1&proto=&rohs=&storeId=500201&topSellers=&No=175

Go to this page, and search the part number I used for the example.

I"m thinking, though...maybe not a elegant as a proper connecter...but the method shown us by Mnemonix is workable and practical....and cheaper too I think.

Furthermore...being able to get easy access to the membrane leads means that one could also make up a simple breadboard circuit with LEDs that would facilitate finding the matrix connections.

I tried that at first...but wasn"t able to get proper electrical contact using the methd I tried, so had to use a multimeter when I did that trace on my terminal board.


..........
Spec57


...end
Title: Making a cheap Model M USB controller
Post by: clee on Thu, 21 January 2010, 16:58:22
Quote from: Mnemonix;152615
Hm, that PIC18F4450 looks nice, and they come in DIL-package, too. Maybe a little short on RAM, and no EEPROM. But an external serial EEPROM is not that expensive... Too bad that Atmel doesn't offer their USB MCUs in DIP.
Do you have a web site for that project, or is it all private for now?


No web site yet; I still haven't been able to come to an agreement with Microchip about code licensing. I want to release all the firmware code open source—I don't particularly care about GPL vs LGPL vs BSD; I just want other people to be able to build off it like they can with the AVR-based code, but Microchip seems to be allergic to open source. Of course, you need Windows to build the code anyway, because their tools are Windows-only and kind of hostile to Mac and Linux environments.

Quote from: Mnemonix;152615
And an ARM Cortex would rock for sure. :)


Not only do the M3s have an overabundance of GPIO pins, but every single pin has individually-configurable pull-up/pull-down resistors. The PIC18 has pull-up resistors, but you can only enable or disable them for one set of GPIOs, and it's all-or-nothing on that set.

It was super-frustrating to get the PIC18 working properly, but it does a great job now, and it does have actual USB in hardware instead of the (fantastic) emulation that AVR-USB does. It seems like the Cortex chips might be as easy to work with as the AVRs, while still providing the same cheap prices and in-hardware USB features as the PIC18s.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 22 January 2010, 03:43:01
Quote from: Specter_57;152807
AvnetExpress does have them, but difficult to find.on the Avnet site....


The problem is that they are asking for a minimum quantity in the thousands. I mean, if I could buy 100 for an acceptable price, then I would probably do that. But thousands?

Quote from: clee;152844
No web site yet; I still haven't been able to come to an agreement with Microchip about code licensing. I want to release all the firmware code open source—I don't particularly care about GPL vs LGPL vs BSD; I just want other people to be able to build off it like they can with the AVR-based code, but Microchip seems to be allergic to open source. Of course, you need Windows to build the code anyway, because their tools are Windows-only and kind of hostile to Mac and Linux environments.


Ah yes, licensing problems. You've told me about those problems; sorry to hear they are still acting like a child. :(

Quote from: clee;152844
It was super-frustrating to get the PIC18 working properly, but it does a great job now, and it does have actual USB in hardware instead of the (fantastic) emulation that AVR-USB does. It seems like the Cortex chips might be as easy to work with as the AVRs, while still providing the same cheap prices and in-hardware USB features as the PIC18s.


I didn't know the Cortex chips were that cheap. Wow. This makes the PIC18s look even less attractive, despite their native USB support. Unfortunately SMD only.

I suppose that the problems with licensing and devtools are less severe or even non-existent with the Cortex chips, right?
Title: Making a cheap Model M USB controller
Post by: clee on Fri, 22 January 2010, 16:51:12
Quote from: Mnemonix;152917
Ah yes, licensing problems. You've told me about those problems; sorry to hear they are still acting like a child. :(


Yeah. I've got a new contact who might be able to help me sort it out. Fingers crossed!

Quote from: Mnemonix;152917
I didn't know the Cortex chips were that cheap. Wow. This makes the PIC18s look even less attractive, despite their native USB support. Unfortunately SMD only.

I suppose that the problems with licensing and devtools are less severe or even non-existent with the Cortex chips, right?


I was slightly exaggerating; they're in between the prices of the PIC18s and the AVRs, slightly closer to the AVR prices once you get into large enough orders. But they still have native USB in hardware, and I've been looking for an excuse to teach myself SMD soldering anyway. :)

Licensing-wise, I hear that things are much better on the M3, and devtools-wise, I can build the code using gcc (so pretty much anywhere) and in theory flash it to the MCU without a programmer. I'm pretty excited about that!

(On the LPC1343, the Cortex-M3 instance I'm currently looking into: if you wire it up right, it shows up as a USB Mass Storage device with a single file in the root folder named 'firmware.bin'; you can read the existing firmware simply by copying this file somewhere else, and you can overwrite it by copying something else over it.)
Title: You should sell these......
Post by: trievalot on Sun, 24 January 2010, 06:36:56
Ill buy one :) (or 4)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 25 January 2010, 04:12:29
Quote from: clee;153108
I was slightly exaggerating; they're in between the prices of the PIC18s and the AVRs, slightly closer to the AVR prices once you get into large enough orders.


I thought they were much more expensive than AVRs, but seems I was wrong. Even if they were a bit more expensive than an AVR, the fact that they have native USB, better architecture than PIC18, and are well-supported by open development tools would make them worth the money.

Quote from: clee;153108
Licensing-wise, I hear that things are much better on the M3, and devtools-wise, I can build the code using gcc (so pretty much anywhere) and in theory flash it to the MCU without a programmer. I'm pretty excited about that!

(On the LPC1343, the Cortex-M3 instance I'm currently looking into: if you wire it up right, it shows up as a USB Mass Storage device with a single file in the root folder named 'firmware.bin'; you can read the existing firmware simply by copying this file somewhere else, and you can overwrite it by copying something else over it.)


Cool, that's really convenient. So, there is no need for a boot loader at all because a fresh, unprepared LPC1343 can operate as mass storage device?
Now, if they could just make them DIP...

Quote from: trievalot;153381
Ill buy one :) (or 4)


:)

I can't sell them because the USB part of the firmware is only for free if not used commercially. As soon as I start selling them, I'd have to pay a license fee.
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 25 January 2010, 16:46:54
Just confirming, the Molex parts are a 100% proper fit and match.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 02 February 2010, 10:25:07
So, I've updated the 122-key Model M schematics (attached). The LED-version makes use of a 74HC165 shift register now, based on the suggestion by Specter_57. The corresponding firmware looks nicer with that.

I have also tested both, the simple non-LED version and the LED-enabled version, on breadboard, and found them working well. I was able to send keystrokes to my computer, to activate the boot loader by "holding down" the Escape key while plugging in, and to flash the firmware via USB.

Now it's the turn of you terminal keyboard owners! :)
It would be cool to see one of you building an actual controller.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 February 2010, 10:39:23
Well...I've got the Molex connectors.

Need...everything else and someone to program the bootloader onto the chip and mail it to me.

You can bet I'll do this (for a 122), maybe even twice (as I've got two of the boards) if I get all the parts together.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 02 February 2010, 11:09:33
Quote from: kishy;155624
You can bet I'll do this (for a 122), maybe even twice (as I've got two of the boards) if I get all the parts together.


That's great! :) And you have the hardest-to-obtain parts already: the connectors. The rest should be easy.
Did you get the connectors as samples from Molex?

Hint: for the 8 pull-up resistors (R9--R16) in the LED version you could use something like Mouser 71-CSC09A01-22K instead of 8 separate resistors (it doesn't really matter if it's 20k or 22k; I've also tried 10k and it worked). Compact and cheap enough.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 February 2010, 11:27:17
Quote from: Mnemonix;155628
That's great! :) And you have the hardest-to-obtain parts already: the connectors. The rest should be easy.
Did you get the connectors as samples from Molex?

Hint: for the 8 pull-up resistors (R9--R16) in the LED version you could use something like Mouser 71-CSC09A01-22K instead of 8 separate resistors (it doesn't really matter if it's 20k or 22k; I've also tried 10k and it worked). Compact and cheap enough.

Connectors - yes, Molex samples. Didn't want to outright claim that because a certain someone is likely to bastardize me for it.

Have test-fitted to the ribbons and they fit perfectly.

I'll have to review the whole article/thread, but everything has a part number provided right?

Can't wait to do this, but I'm in no rush quite yet. Should have two weeks off (not back-to-back though) in the next couple months so I'll make some progress then I'm sure.

Oh, and yes, since I've not the money to dedicate to a programmer, I'll be asking someone to please write the bootloader and write-protect it then ship the chip to me. Of course, I'll cover the costs associated with that (buying the uC, shipping it to me). Anyone willing/able to do this, please get in touch :) Thanks (I may consider going the route of getting a programmer and doing it myself but if someone offers to do it I'll go with that for obvious reasons)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 02 February 2010, 12:51:59
Quote from: kishy;155629
I'll have to review the whole article/thread, but everything has a part number provided right?


I'm afraid that Mouser is not so popular here in Germany, and our Reichelt is probably totally unknown outside of Germany. That's why I didn't write part numbers anywhere.
Ripster was going to make a Mouser parts list for the 1391401 controller, he said. The 122-key part list would be the same, plus a 74HC165 and the pull-up resistors. And with a 20-pin connector instead of 16-pin.

Quote from: kishy;155629
Oh, and yes, since I've not the money to dedicate to a programmer, I'll be asking someone to please write the bootloader and write-protect it then ship the chip to me.


Well, I could certainly do that, but it would probably be cheaper to have it shipped from your continent.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 February 2010, 13:12:50
Quote from: Mnemonix;155646
I'm afraid that Mouser is not so popular here in Germany, and our Reichelt is probably totally unknown outside of Germany. That's why I didn't write part numbers anywhere.
Ripster was going to make a Mouser parts list for the 1391401 controller, he said. The 122-key part list would be the same, plus a 74HC165 and the pull-up resistors. And with a 20-pin connector instead of 16-pin.



Well, I could certainly do that, but it would probably be cheaper to have it shipped from your continent.


Can't be more than maybe 5 Euros (for an envelope with two uCs), could it? Assuming the microcontroller is cheap (I haven't priced it out yet) this is something I could certainly accommodate (via PayPal).

Connectors are taken care of, except for a 4-pin for LEDs on the 1391401s which that applies to, but in this case it doesn't apply. With the LED system I had been planning I could directly solder the wires to the controller...it would be a largely permanent mod.

As for parts suppliers, prior to looking into this the only one that immediately came to mind was Digi Key but I don't know if they've got what we need (again, haven't looked into it yet). Once I do this I'll be happy to provide part numbers from a couple suppliers that look acceptable.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 February 2010, 13:25:22
Shift register 74HC165:

Digi-Key has two different ones, only difference seems to be operating temperature, and the better one seems to be cheaper.

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=MC74HC165ANGOS-ND

http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=MM74HC165N-ND



RS Electronics has one too, but it's a bit more pricey (but certainly not in a significant way)
http://www.rselectronics.com/Catalog/ViewPart.aspx?Part=NTE74HC165&MFG=NTE&h=Semiconductors+Digital+Integrated+Circuits-TTL+Shift+Registers+Nte


Mouser's site is a bit of a mess...I can't narrow it down by package so here's the search result for what's in stock only.
http://ca.mouser.com/Semiconductors/_/N-5gcbZscv7?Keyword=74HC165&FS=True




Edit:
And there's always this:
http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&item=260513509531
Someone let me know if this is suitable...I'll buy it if so. 'Lot of 3' being the key words.


Edit again:
Out of the following, which is most suitable (if any):
http://focus.ti.com/docs/prod/folders/print/cd74hc165.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165-q1.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165-ep.html
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 02 February 2010, 14:32:35
Quote from: kishy;155650
Can't be more than maybe 5 Euros (for an envelope with two uCs), could it? Assuming the microcontroller is cheap (I haven't priced it out yet) this is something I could certainly accommodate (via PayPal).


It's 6 Euros for an envelope because the envelope would be thicker than 1 cm (unless I would send the ICs totally unprotected inside a thin paper envelope).

The problem is that I have only a single ATMega32 here, which I need for myself. I could buy some from the local electronics store, but they are rather expensive there (don't know the exact price, but easily more than 5 Euros per unit).

Then, I have two spare ATmega16 which I have bought for 2.25 Euros each. They would work, too, but they have less RAM, Flash, and EEPROM. RAM and Flash are not a problem (yet), but you could only store 3 or 4 custom key maps in the small EEPROM.

Quote from: kishy;155654
Shift register 74HC165:

Digi-Key has two different ones, only difference seems to be operating temperature, and the better one seems to be cheaper.


Both are OK. I'd always opt for the cheapest. This one (http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=568-1410-5-ND) is even cheaper... but not available.

Quote from: kishy;155654
Mouser's site is a bit of a mess...I can't narrow it down by package so here's the search result for what's in stock only.
http://ca.mouser.com/Semiconductors/_/N-5gcbZscv7?Keyword=74HC165&FS=True


Sort by price, then choose the first 16 DIP: MC74HC165ANG. Cheaper than Digi-Key.

Quote from: kishy;155654
And there's always this:
http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&item=260513509531
Someone let me know if this is suitable...I'll buy it if so. 'Lot of 3' being the key words.


Should be fine, too. But you'd pay $2.50 for these. Buying all parts from one supplier could be cheaper in the end because this would save you shipping cost.

Quote from: kishy;155654
Edit again:
Out of the following, which is most suitable (if any):
http://focus.ti.com/docs/prod/folders/print/cd74hc165.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165-q1.html
http://focus.ti.com/docs/prod/folders/print/sn74hc165-ep.html


Hm... asking for samples, why not. ;)
Looking at the datasheets, I'd say any will do. I would ask for the SN74HC165 since it's the one that is not rated for special applications (thus probably making it the cheapest).
Title: Making a cheap Model M USB controller
Post by: InSanCen on Tue, 02 February 2010, 18:32:13
Which ATMega32 should I be looking at?

http://www.rapidonline.com/sku/Electronic-Components/Integrated-Circuits/Atmel-Microcontrollers/ATmega-8-bit-AVR-Microcontrollers/77086/73-4282
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 03 February 2010, 02:43:49
Quote from: InSanCen;155751
Which ATMega32 should I be looking at?

http://www.rapidonline.com/sku/Electronic-Components/Integrated-Circuits/Atmel-Microcontrollers/ATmega-8-bit-AVR-Microcontrollers/77086/73-4282


Yes, this one, the ATMEGA32-16PU.


A search for ATMEGA32 found three more devices:

The datasheet for the ATMEGA32A-PU doesn't show any significant difference to the ATMEGA32-16PU besides being able to operate at full speed at low voltages, so this one should work, too (but is more expensive in small quantities on that site).

The ATMEGA324P-20PU is a 20 MHz version with more features and may also work, but is also more expensive. I didn't take a closer look, but I guess it would either work out of the box just like a ATMEGA32-16PU, or it would require minor tweaking of the fuses to make it work.

The ATMEGA32L-8PU is the only one that would not work because it is limited to 8 MHz (the USB code needs 12 MHz).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 03 February 2010, 02:52:50
Quote from: ripster;155653
I'm making this simple 1 key circuit (http://blog.flipwork.nl/?x=entry:entry081009-142605:) first.  I'm no programmer so I figure if I start slow I can learn as I go.


If you'd like to learn lots and lots about AVRs, then http://www.avrfreaks.net/ (http://www.avrfreaks.net/) might be a good start.
There is also a helpful forum with tutorials on that site. It's probably most useful for programmers, however.
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 03 February 2010, 16:40:36
Now, I'm a relative n00b with low-level circuit design, so I'll ask a dumb question:

What's the wattage for the resistors?

Also, are there any more missing figures of questionable obviousness that are important when buying these supplies?

I imagine since this is USB that the voltage for everything is 5V...correct if wrong please.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 03 February 2010, 16:53:40
Mnemonix:

I looked at your revised schematic, based upon a suggestion I made.

Thank you for the mention... nice to know what I said did have some  positive result.

The schematic does look a bit neater and more logical...and you mentioned the code was cleaner too.  Good

I do fully intend to build one of these controllers...but unfortunately there are more pressing atters at this time.

And once again, Thank You for so freely sharing your work with the community here.....and a thank you as well to the others who have also so generously contributed their thoughts and opinions and expertise to this project.
 I certainly do appreciate it...and I have learned quite a few things along the way about these ATMega microcontrollers.

And theat website you mentioned, AVRFreaks.  interesting.

BTW...if you would like to include the info I provided on the row-column matrix connections on your information pages, I would not mind. Feel free.

Spec57
......


...end
Title: Making a cheap Model M USB controller
Post by: InSanCen on Wed, 03 February 2010, 18:21:57
Quote from: kishy;156032
Now, I'm a relative n00b with low-level circuit design, so I'll ask a dumb question:

What's the wattage for the resistors?

Also, are there any more missing figures of questionable obviousness that are important when buying these supplies?

I imagine since this is USB that the voltage for everything is 5V...correct if wrong please.


1/4W (More commonly, 0.6W) resistors should be fine. I can't see anything bigger looking at the photo's.

I may suck with MicroControllers (The programming puts me off every time. I will learn though), but I know my way round discrete components.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 03 February 2010, 18:43:26
Quote from: kishy;156032
What's the wattage for the resistors?


The common 1/4 Watt ones are sufficient. I am using metal film resistors instead of carbon because the metal film resistors have lower tolerances (usually 1% vs. 5%) at comparable prices.
Precision doesn't matter for the 8 pull-up resistors on the column lines. I believe anything between 10k and 50k would work well here.

Quote from: kishy;156032
Also, are there any more missing figures of questionable obviousness that are important when buying these supplies?


Hm, dunno. All chips should be 5V versions, not some low-power versions. The 22 pF capacitors are ceramic plate "class 1" capacitors with 2% tolerance, the 100 nF is a ceramic multilayer capacitor with 10% tolerance; I think all are rated for 100V or so. I didn't really choose them intentionally this way, they are just what I could get from my supplier. Don't know what to say about the other components.

Concerning the stripboard, you should really go with fiberglass. The cheap ones are too smelly for a keyboard (smells "like electronics"), whereas fiberglass doesn't smell at all.

Quote from: kishy;156032
I imagine since this is USB that the voltage for everything is 5V...correct if wrong please.


USB provides 5V for powering the devices, so everything runs on 5V, yes. VCC in the schematics always refers to the +5V from the USB plug.
The data lines are at lower voltages, however, but this is not really important. See here (http://www.beyondlogic.org/usbnutshell/usb2.htm#Electrical) if you are interested in the details.
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 03 February 2010, 21:12:38
Thanks, that definitely helps. I have a friend with a parent in the component industry so I may have a local source for at least a couple items on the list, potentially free, who knows? It's nice to not guess because that means their effort isn't wasted.

I'm definitely looking at doing this, no doubt about it lol. Most likely the last step in the process will be anything involving the uC...it's likely to be the last part I obtain as I hold out for the lowest possible cost on one (would go Mouser or Digikey or RS or something but I don't have a credit card). Doesn't look like Atmel samples out their uCs either lol (understandable, it's a higher value product than a simple connector).



Edit:
Bought some things and ordered some free samples of some things. Here is what I've already got or will be receiving soon:
-Programmer, one of the ones recommended in this thread (small red one)
-ATmega32-16PU (2)
-DIP-40 socket (2)
-DIP-16 socket (2)
(I'm going to use a socket for the shift register because I'm not the best with soldering and don't want to risk overheating the chip while setting it in place)
-6x2 pin header (2)
-6x1 pin header (2)
-USB 'B' jack (2)
-Two short FFC connectors - still need the two 20s, should be here any day
-Assorted wire (have a 20ft phone cord as a donor)
-Ring terminal for ground wire
-The 3.6V diodes (1N4729 in my case, hopefully they'll be suitable)
-Shift registers

As you can see I'm stocking up to build two. This is for two reasons:
1) I have one I can screw up on and still be able to build a functional second
2) If both are successful I have a controller for both my 122s

So that would mean what I still need, as I understand it, is:
-Stripboards
-Resistors
-Capacitors
-1N4148 Diodes
-Crystals

If I've left something out please tell me.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 05 February 2010, 11:37:49
Quote from: kishy;156096
Edit:


Oops, just discovered that edit...

Quote from: kishy;156096

Bought some things and ordered some free samples of some things. Here is what I've already got or will be receiving soon:
-Programmer, one of the ones recommended in this thread (small red one)


Wise decision. :)
An own programmer will pay off in the long run.

Quote from: kishy;156096
-6x1 pin header (2)


If there is enough space available, you could try using a dual row header for connecting the programmer. It's a bit harder to do on stripboard, but this is how everybody else is doing it (and your programmer may come with one of those commonly used cables).

Otherwise, see the article for how to make an adapter cable. You may need to add some connectors to your parts list.

Quote from: kishy;156096
-The 3.6V diodes (1N4729 in my case, hopefully they'll be suitable)


Yes, those are fine. Mine are 0.5W, yours are 1W, so they are probably a bit bigger than mine.

Quote from: kishy;156096

So that would mean what I still need, as I understand it, is:
-Stripboards
-Resistors
-Capacitors
-1N4148 Diodes
-Crystals


OK, but you don't need the 1N4148 diodes anymore. They were required for the old design (http://geekhack.org/showpost.php?p=150553&postcount=64). The new one (http://geekhack.org/showpost.php?p=155620&postcount=105) uses eight resistors instead (and a 74HC165 shift register instead of a 74HC164).

I think you have everything that's needed then.
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 05 February 2010, 11:55:21
What I may do for the wire header might be to use an old serial port header (with the connector suitable to plug directly into programmer itself) and solder the wires directly to the PCB wherever appropriate, eliminating the pins and need for an adapter...we'll see. Those wires are VERY fine and I'm not sure I can competently solder them without burning them.

RE: 1N4148, I had been looking at schematic.pdf (edit: apparently the old one) as provided earlier in the thread and saw those. That diagram does not include the resistors you mentioned.

Since I've already bought 74HC165s, I should probably keep it consistent with the newest version of the design and go with resistors? Which resistors might those be...I don't see them in the parts list. Edit: whoops, I'm dumb. 8x 20kOhm, I was looking at the wrong copy of schematic.pdf.

Thanks for the help and the patience :)

Edit: something just occurred to me...anyone building one for an old-style 122 is not actually going to need a USB jack, unless you mod the case quite a bit. You can directly solder the wires in place from a USB cable, or if you use a USB plug you can put it inside the case without the ability to unplug it.
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 05 February 2010, 14:56:42
Would 22 kilo ohm resistors work instead of 20?

If not, will the design still function properly using diodes as originally shown?
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Fri, 05 February 2010, 17:19:46
Kishy:
"Would 22 kilo ohm resistors work instead of 20?"

Yes they will.  There is no practical difference here...and values larger and smaller will work. If you already have them...use them.

You should be safe with 22K resistors

Edit.  For fun, take a look at your controller card.  The original IBM board used 20K and 30K pull-up and -down resistors for the keyboard matrix inputs.

..........
Spec57

....end
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 05 February 2010, 17:35:47
Hmmm...thing is, I have the option of buying either 22K resistors or the 1N4148 diodes...I have neither yet. From a purely price-based perspective the diodes look marginally better (being 1 cent cheaper each, lol), but for the sake of staying with the current schematic I'll get the resistors.

Good to know the 22s will work. Think I'll nab those (or at least add to cart).

Edit: info for those who are interested:

SDL connectors were an AMP/now Tyco product (why is this important? because it shows IBM favoured AMP for connectors)
While browsing around Tyco's site I'm seeing FFC connectors that look far more similar to the original IBM ones (the Molex ones are functionally equivalent but look different).

Check out Tyco P/N 7-520355-0. It's the 20-pin as seen in a 122-key.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 06 February 2010, 07:16:22
Quote from: kishy;156482
Edit: something just occurred to me...anyone building one for an old-style 122 is not actually going to need a USB jack, unless you mod the case quite a bit. You can directly solder the wires in place from a USB cable, or if you use a USB plug you can put it inside the case without the ability to unplug it.


So there is no big enough hole for a full-size USB jack? Bummer. Maybe a mini USB connector would be small enough.

You could also make a USB rat tail instead of a long fixed cable, i.e., a very short cable looking out of the case with some USB connector at its end. I wouldn't solder that cable directly to the controller, but connect it to 4 jumper pins (otherwise you couldn't remove the controller from the keyboard anymore).

Quote from: kishy;156556
Would 22 kilo ohm resistors work instead of 20?

If not, will the design still function properly using diodes as originally shown?


As Specter_57 mentioned already, it doesn't really matter whether they are 20k or 22k. I'll change them to 22k in the schematic because those are in the E12 series, thus more common. A compact part such as Mouser's 71-CSC09A01-22K would save you quite some space.

Please forget the old design with diodes and 74HC164 register. It requires a different firmware, which I have removed from the source tree already. I guess no one has ever built this circuit anyway, so there's no point to support it any longer.

Quote from: kishy;156632
Check out Tyco P/N 7-520355-0. It's the 20-pin as seen in a 122-key.


Interesting. Get these to stay true! ;)
Title: 122key, USB jack...a thought on this...
Post by: Specter_57 on Sat, 06 February 2010, 07:36:09
Kishy.

Your 122key terminal board...turn it over, look at the back.

On the right-hand side, toward the top of the board, you will see a small rectangular opening with (in my three boards) a plastic tab, which can easily be removed...or left in place and used to mount the connector.

You can mount your socket inside at this point...maybe have to do some small amount of mechanical work inside, but that is a possible location.
When the boards feet are up, should be no problem with angling issues.

Consider using "Shapelock" or "Friendly Plastic"  for the mechanical mounting work if not using that plug I mentioned above.

Just a thought.

.............
Spec 57




.end
Title: Making a cheap Model M USB controller
Post by: kishy on Sat, 06 February 2010, 09:14:15
Quote from: Mnemonix;156721
So there is no big enough hole for a full-size USB jack? Bummer. Maybe a mini USB connector would be small enough.

You could also make a USB rat tail instead of a long fixed cable, i.e., a very short cable looking out of the case with some USB connector at its end. I wouldn't solder that cable directly to the controller, but connect it to 4 jumper pins (otherwise you couldn't remove the controller from the keyboard anymore).


Yeah, the cord is not detachable on them, so there's no spot for a jack of any kind. Just a small round hole that the cord goes through.

(http://geekhack.org/attachment.php?attachmentid=7739&stc=1&d=1265484773)

Hole is 5mm wide, L-R as in this photo. It's approximately that in height also. Top is flat, remainder is rounded (like a 'U' with a line across the top).

A mini jack would presumably fit (if not, drilling out the hole wider would make it fit) but the layout in the case would make it kind of not so good. Good point about a pin header, though I would in fact still be able to remove it from the keyboard (the cord would just come with it).

Quote from: Mnemonix;156721
As Specter_57 mentioned already, it doesn't really matter whether they are 20k or 22k. I'll change them to 22k in the schematic because those are in the E12 series, thus more common. A compact part such as Mouser's 71-CSC09A01-22K would save you quite some space.

Please forget the old design with diodes and 74HC164 register. It requires a different firmware, which I have removed from the source tree already. I guess no one has ever built this circuit anyway, so there's no point to support it any longer.


With regards to the Mouser part you suggested, I don't actually know how to use one, nor can I visualize how to fit it into the circuit.

Alright, no diodes and no 74HC164 (I've already bought 74HC165s, just wasn't sure on the diodes, if they'd make a difference).

Quote from: Specter_57;156722
Kishy.

Your 122key terminal board...turn it over, look at the back.

On the right-hand side, toward the top of the board, you will see a small rectangular opening with (in my three boards) a plastic tab, which can easily be removed...or left in place and used to mount the connector.

You can mount your socket inside at this point...maybe have to do some small amount of mechanical work inside, but that is a possible location.
When the boards feet are up, should be no problem with angling issues.

Consider using "Shapelock" or "Friendly Plastic"  for the mechanical mounting work if not using that plug I mentioned above.

Just a thought.

.............
Spec 57

.end


Aha, but you see, there's no clearance under the keyboard to run a cord or have the connector sticking out. It's not physically possible to use the keyboard in the raised position (that is, with the feet lowered) because it makes it both a) not fit in my desk and b) very uncomfortable to use.

To show what you mean to people who don't know, it's the small pop-out panel visible here:

(http://geekhack.org/attachment.php?attachmentid=7740&stc=1&d=1265484773)

Good thinking of course, but not feasible here:

(http://geekhack.org/attachment.php?attachmentid=7741&stc=1&d=1265484773)

ShapeLock...website looks Unicompy, but wow, that's a neat concept!

I would, ultimately, be OK with having a normal 'B' socket on the controller board, connecting a normal 'B' cable to it, then closing up the keyboard with that inside...if anything, the presence of the molded plug on the cable would act as a strain relief against the case. Either that or some sort of pin connector, but I do already have the USB sockets on their way to me so I'll just do that I think.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Sat, 06 February 2010, 18:41:07
Ha. Talk about assumptions...

I have all the space I need on my desktop, and  will use the board with the feet extended.

And the "B" type plug you mentioned could be mounted at the cord opening, but would require some mounting work....quite minor it appears.

Me, not so concerned with keeping the board "stock" in appearance, mechanical modding is ok with me if necessary.

When I eventually get something built...I"ll actualy be using an RJ-45 plug and standard straight-through CAT5 or 5e cable. (I have my reasons...)
.........

And ever since I discovered Shapelock/Friendly Plastic, been toying with the idea of, to make a joke of another thread title...."Capping" myself (now...there's another thread possibility in itself....)....sighhh...so many project interests...so little time...

...........
Spec_57

......end
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 07 February 2010, 00:04:37
Alrighty...everything except the stripboard is either here or on its way. Stripboard is difficult...can't seem to find reasonable pricing or acceptable products online and I'm having no luck finding a local supplier for such a thing. Rather frustrating.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 07 February 2010, 12:15:20
Quote from: kishy;156728
Show Image
(http://geekhack.org/attachment.php?attachmentid=7739&stc=1&d=1265484773)


So the cord can be lifted from the hole when the case is open. No problem with fixed cables then. I imagined that the hole was a "closed" hole, requiring you to pull the cord through it in full length.

Quote from: kishy;156728
With regards to the Mouser part you suggested, I don't actually know how to use one, nor can I visualize how to fit it into the circuit.


The part contains 8 individual resistors in a single package. There are 9 pins. Pin 1 is a common connection to one of each resistor's terminals. The other pins go to the other terminal of the individual resistors.

Hm. Here's a crappy picture:

Code: [Select]

1 --------+
          |
2 ---R1---+
          |
3 ---R2---+
          |
4 ---R3---+
          |
5 ---R4---+
          |
6 ---R5---+
          |
7 ---R6---+
          |
8 ---R7---+
          |
9 ---R8---+


For the keyboard controller, you would connect pin 1 to VCC, thus connecting all resistors to VCC as shown in the schematic. Pins 2 through 9 would go to the column lines.

Quote from: kishy;156866
Alrighty...everything except the stripboard is either here or on its way. Stripboard is difficult...can't seem to find reasonable pricing or acceptable products online and I'm having no luck finding a local supplier for such a thing. Rather frustrating.


I've paid 3.90 Euros for a good 160x100 mm stripboard from a German supplier, if this is of any help for you. Local store is asking for 4.90 Euros, IIRC.

You can also try perfboard if it's cheaper, but personally I don't like working with that. Or use cardboard. :)
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 07 February 2010, 12:36:28
Argh, that would have been easier! Could have put it parallel to the 8-position FFC header.

Oh well.

Cardboard...interesting. Very interesting. Tempting even.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Sun, 07 February 2010, 15:33:05
If you decide to give in to temptation and use cardboard...I would suggest using some corrugated cardboard from an old box.

Works rather well...better than you might expect.

I know...I've built circuits with it before.

Not too pretty, but effective.

........
Spec_57


....end
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 07 February 2010, 15:57:45
Will certainly give consideration to it for future projects, but a very generous member has privately offered to send me the needed stripboards :D

Gotta love people around here.
Title: Making a cheap Model M USB controller
Post by: sethstorm on Sun, 07 February 2010, 23:10:15
Quote from: kishy;156482


Edit: something just occurred to me...anyone building one for an old-style 122 is not actually going to need a USB jack, unless you mod the case quite a bit. You can directly solder the wires in place from a USB cable, or if you use a USB plug you can put it inside the case without the ability to unplug it.


To bring up a concern in the appropriate thread about anyone attempting this on a Model F 122-key keyboard:
http://geekhack.org/showpost.php?p=148964&postcount=10 (http://geekhack.org/showpost.php?p=148964&postcount=10)
Quote from: sethstorm;148964
Quote from: microsoft windows;148962
How does the cable attach to the keyboard controller?

Soldered ribbon cable, or a more rigid version that was available in the 80s.  As soon as I saw that, I was not going to open it up any further.


If you want to do this to a Model F terminal keyboard, there is that issue since it is not merely a membrane, but a rigid ribbon between two circuit boards.
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 08 February 2010, 04:18:57
There's more to it than that, in fact...because the F design relies on a capacitive switch the controller is quite different if I'm to understand this stuff correctly. It's been mentioned here that this should only be expected to work for Model M type boards.
Title: Making a cheap Model M USB controller
Post by: trievalot on Mon, 08 February 2010, 06:01:18
Anyone here want to make these and sell in the classifieds section?
Im sure if we got a few out there, we would start seeing USB Model Ms on ebay ;)
Title: Making a cheap Model M USB controller
Post by: sethstorm on Tue, 09 February 2010, 03:20:00
Quote from: kishy;157010
There's more to it than that, in fact...because the F design relies on a capacitive switch the controller is quite different if I'm to understand this stuff correctly. It's been mentioned here that this should only be expected to work for Model M type boards.

But as I take it, the Model M ones are fine? Interesting if that's the case.  I already need to do a proper berg strip rework to the Model M one that I have -

The only downside is that you still have to either remap the layout or deal with the source code.  The question is then, can one do a multiple key-to-one map with it?
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 09 February 2010, 06:08:49
Quote from: trievalot;157014
Anyone here want to make these and sell in the classifieds section?
Im sure if we got a few out there, we would start seeing USB Model Ms on ebay ;)


I'd love to see professionally manufactured PCBs for the Model M controller, especially if they fit into both the 1391401 and the Mini. If anyone can do this, please go ahead!

The market for terminal keyboard controllers is probably too small, however, but who knows?

Concerning the V-USB license (http://www.obdev.at/products/vusb/license.html), it seems like they are only asking for a fee if their code is used in a closed source project--otherwise the terms of the GPL apply. Keyboard Upgrade is not and never will be closed source, so it seems possible to sell PCBs with pre-programmed AVRs with no license fees involved. If not, it is always possible to switch over to a USB-enabled AVR.

Quote from: sethstorm;157200
But as I take it, the Model M ones are fine? Interesting if that's the case.


Yes, any keyboard with conductive switches can, in theory, be supported. It's only a matter of figuring out the keyboard matrix to get the firmware going. Whether or not it would be easy to build the hardware, to fit it into the case, and to connect it to the keyboard matrix is a different question. In case of the 1391401 it's rather easy, but next to impossible in super-slim keyboards (unless you'd put the controller into an external case).

The Model F requires additional circuitry, but I haven't really looked into this yet. I got an XT Model F from meltie which I can do some experiments with, but unfortunately I don't have the time for this at the moment. :(

Quote from: sethstorm;157200
The only downside is that you still have to either remap the layout or deal with the source code.  The question is then, can one do a multiple key-to-one map with it?


Use the source, Luke. ;)
It is definitely possible to implement extended macro capabilities, but, just like PS/2 output support, I simply have no personal use for it. Macros are therefore low-priority for me (but surely higher than PS/2).

However, if anyone wants to implement this, I'd be happy to pick up contributed code and add it to the firmware. It would probably require some external EEPROM chip such as the AT24C512B because the AVR's internal EEPROM is rather small (and used for storing key maps and basic config).
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 09 February 2010, 07:46:47
Regarding running out of space, could we move up to a larger capacity 16MHz Atmel AVR (for example ATmega128)?

If it's the same except for the nonvolatile storage then we're looking at an easy upgrade path without additional hardware added or significant code changes (I think).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 09 February 2010, 08:24:10
Quote from: kishy;157239
Regarding running out of space, could we move up to a larger capacity 16MHz Atmel AVR (for example ATmega128)?

If it's the same except for the nonvolatile storage then we're looking at an easy upgrade path without additional hardware added or significant code changes (I think).

In principle, yes. The ATmega128 has 4 kB EEPROM instead of only 1 kB on the ATmega32 (both can operate at 16 MHz, however). I'm pretty sure that the code would compile for the ATmega128 with no changes needed. The extra 3 kB could then be used for storing macros. We could also use 0.5 kB for key maps and 0.5 kB for macros on the ATmega32, if that's enough.

The problem is that the ATmega128 (and ATmega64) is not available as DIP version, but only in TQFP and MLF package. You CAN solder TQFP chips, but it's more challenging than DIP and is probably best done on an etched PCB. So, for a professional version, why not? It's one option.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 09 February 2010, 10:02:22
MLF looks fairly similar to a PLCC...and I think you can find adapters between PLCC and DIP, or at least fabricate one. Presumably that would work if done correctly.
Title: Making a cheap Model M USB controller
Post by: sethstorm on Tue, 09 February 2010, 16:12:49
Further, looking at the schematics for the 122-key terminal board, it still has a usb jack as an endpoint.  While that might work for some boards, it might serve better to terminate that to a header.  Otherwise it doesn't look out of place.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Tue, 09 February 2010, 20:04:36
I have some contacts in the PCB design/manufacture industry in the UK. One in particular is a specialist in low-volume runs. No promises whatsoever (Cost is likely to be prohibitive, even at "mates rates"), but I'll certainly ask around. I assume someone can supply Gerber files if it looks feasible?
Title: Making a cheap Model M USB controller
Post by: DreymaR on Wed, 10 February 2010, 03:19:29
Quote from: Mnemonix;150054
The shift mapping can be applied independently already since the script that processes the matrix definitions and key mappings can handle multiple map files. At least with Colemak it will work because the affected keys are not part of the Colemak mapping.
It doesn't work for Dvorak at the moment because the script simply assumes that all mappings are independent (otherwise the order in which the map files are passed to the script would become important). I'll think about a good solution.


Hope you come up with one! Now I'm looking into ergonomic mods like moving some keys to the middle of the board for better hand separation (the 'Wide' mod) and if the mappings could be done in several layers you could do a smörgåsbord of ZXCVB, Wide and whatever ergonomic mod you fell for - and then the layout itself (QWERTY/Tarmak/Colemak/Dvorak/what-have-you) on top of those. Basically, some mappings like the ergonomic ones are inherently scancode-to-scancode mappings - whereas the layout mappings themselves are inherently more scancode-to-systemcode(vkey to be accurate but that's not coming from the keyboard).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 10 February 2010, 10:53:27
Quote from: InSanCen;157455
I have some contacts in the PCB design/manufacture industry in the UK. One in particular is a specialist in low-volume runs. No promises whatsoever (Cost is likely to be prohibitive, even at "mates rates"), but I'll certainly ask around. I assume someone can supply Gerber files if it looks feasible?

KiCad can produce Gerber files, but we need a PCB layout first. At the moment there's only the schematic, and maybe the Dulcimer PCB design as a starting point.

Are you thinking of just the PCB or fully assembled boards? I mean, if one of the manufacturers could fit the components for us, then it would make sense to design an SMD version, which is probably cheaper (smaller, fewer drill holes, cheaper components).

Quote from: DreymaR;157510
Hope you come up with one!

Well, I found a solution. It was simple and it works. Keys can be re-mapped multiple times now, so that Dvorak+ErgoShift yields a key map with the 6 bottom-left keys shifted. You can even apply the ergo-shift mapping several times, leading to a shift by multiple positions. :)
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 10 February 2010, 16:00:36
How many typical LEDs could be driven by this controller?

I ask because my backlight-to-represent-lock-status may involve as many as 4 LEDs per lock key depending on how this works out. If a single LED is already near the max amount available then I'd want to just keep it as one.
Title: LED drive...
Post by: Specter_57 on Wed, 10 February 2010, 17:29:16
Kishy...

Look for super-high efficiency LEDs...I got hold of one by mistake when I bought a bunch of ordinarry greens...this one is so bright that I had to use a *50K* limiting resistor on a 5v source! and it was still very bright.

Of course...you could simply use a transistor to increase the drive for the LEDs. Very simple and cheap.

.......
Spec_57


...end
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 10 February 2010, 17:33:31
Quote from: kishy;157643
How many typical LEDs could be driven by this controller?


Depends on the values of the series resistors which are limiting the current going through the LEDs.

The absolute maximum DC current per I/O port allowed is 40 mA, but that's not for regular operation. I can't find a clearly stated limit in the datasheet, but they mention 20 mA in a footnote ("Although each I/O port can sink more than the test conditions (20 mA at Vcc = 5V, 10 mA at Vcc = 3V)..."). They also say this about the PDIP package versions:
Quote

1] The sum of all IOL, for all ports, should not exceed 200 mA.
2] The sum of all IOL, for port A0 - A7, should not exceed 100 mA.
3] The sum of all IOL, for ports B0 - B7,C0 - C7, D0 - D7 and XTAL2, should not exceed 100 mA.


So, for 12 LEDs you'd need to use large enough resistors to limit the maximum total current so not to exceed these limits.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 10 February 2010, 17:35:04
Quote from: Specter_57;157651
Look for super-high efficiency LEDs...


Oh, right. Problem solved. :)
Title: Super-bright LEDs
Post by: Specter_57 on Sun, 14 February 2010, 07:23:27
..
Kishy, (and other interested parties) here is a Canadian source posted on EBay.ca.

http://cgi.ebay.ca/50-pcs-3mm-Green-LED-T1-Super-Bright-40mA-2-6V-140mW_W0QQitemZ290341657725QQcmdZViewItemQQptZLH_DefaultDomain_210?hash=item4399b61c7d

50 pieces - 3mm super-bright green LEDs.- T-1
BIN $2.06  Shipping $3.11 both in Cdn peseos

or if you prefer "hyper-bright" Orange, same prices same quantity available too.

Just casually surfing for super-bright LEDs...no connection to the vendor.

..........
Spec_57



..........end
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 14 February 2010, 09:47:20
The idea would be LED backlighting for the lock keys (creating a red outline around the area of the key) while the lock was enabled...so basically the exact same functionality as normal lock LEDs, just positioned differently.

My eventual, down-the-road goal for the keyboard as a whole would be a black case with silver trim/highlights, perhaps with blue backlighting on the whole board with red backlighting for the lock keys. I'm content with only accomplishing the last one though, since it's easy.
Title: Making a cheap Model M USB controller
Post by: Xuan on Mon, 15 February 2010, 01:11:12
IMO you're wasting your time thinking about lock leds, no one uses caps or scroll locks.
And num lock should always be turned on, that's the purpose of the numpad, to punch numbers, you've proper navi keys two inches to the left.
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 15 February 2010, 01:59:27
Speak for yourself...I use them both regularly (yes, even scroll, though not for its original purpose).

Keep in mind the keyboard in question is exclusively used on a computer that's used exclusively for gaming. In that environment, keys used for toggling assorted things are best accompanied by a visual indicator.

Haven't used scroll for anything yet since switching to this kb on account of there being no LED to indicate its status, so there's been no point in figuring out what I mapped it to.
Title: Making a cheap Model M USB controller
Post by: DreymaR on Mon, 15 February 2010, 04:09:09
The lock states are indeed in use and useful - even if their original use may have abandoned them in some cases. So I'm for them too.
Title: Making a cheap Model M USB controller
Post by: kishy on Thu, 18 February 2010, 13:27:34
Though not particularly useful for this project, it should be noted that Tyco P/N 1-1761185-2 is a suitable replacement SDL socket for Model M controllers.

Dumb idea to use one for this particular controller because you could connect a PS/2 cable and blow it up...

(http://geekhack.org/attachment.php?attachmentid=7949&stc=1&d=1266521170)

(http://geekhack.org/attachment.php?attachmentid=7950&stc=1&d=1266521170)

(http://geekhack.org/attachment.php?attachmentid=7951&stc=1&d=1266521170)

Oh, and about half of my needed parts have arrived. Getting closer...
Title: Making a cheap Model M USB controller
Post by: InSanCen on Mon, 01 March 2010, 19:17:32
Quote from: Mnemonix;157587
KiCad can produce Gerber files, but we need a PCB layout first. At the moment there's only the schematic, and maybe the Dulcimer PCB design as a starting point.

Are you thinking of just the PCB or fully assembled boards? I mean, if one of the manufacturers could fit the components for us, then it would make sense to design an SMD version, which is probably cheaper (smaller, fewer drill holes, cheaper components).


Ok, having had a word, it's a "suck it and see".

I am owed a favour or two from the Low Volume specialist (Built his servers at a low cost), and he's agreed to do a small (10pcs) run to see how things pan out. He can do SMD component placement and from having a look at the schematic, says's it's not a problem apart from cost. It get's much more acceptable at >100 pcs. I have no firm figures yet, but when we get something sorted out I will yell. I suspect we would need to coordinate a "Group Buy" to get some decent prices.

In the meantime, my order is in at RS for a Crystal's and ATMega32's. I have four boards sitting here just gagging for this mod.
Title: Making a cheap Model M USB controller
Post by: clee on Mon, 01 March 2010, 19:22:30
That would rule! I would be down for at least 5 boards myself.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Mon, 01 March 2010, 19:22:47
..

I will eventually get around to building this thing for my 122key Terminal "M"s, as part of what will likely be a "multi-mod" affair when all is said and done...and for me I know it will be standard PDIP devices, either on my own made circuit board (most likely...)...or maybe perf-board and wirewrap..

InSanCen -- But would still be interested in the circuit boards you mentioned, I am curious as to what the final cost of one would be.
..........
Spec57
Title: Making a cheap Model M USB controller
Post by: sethstorm on Mon, 01 March 2010, 19:37:11
Quote from: InSanCen;161396
Ok, having had a word, it's a "suck it and see".

I am owed a favour or two from the Low Volume specialist (Built his servers at a low cost), and he's agreed to do a small (10pcs) run to see how things pan out. He can do SMD component placement and from having a look at the schematic, says's it's not a problem apart from cost. It get's much more acceptable at >100 pcs. I have no firm figures yet, but when we get something sorted out I will yell. I suspect we would need to coordinate a "Group Buy" to get some decent prices.

In the meantime, my order is in at RS for a Crystal's and ATMega32's. I have four boards sitting here just gagging for this mod.


If you were on the US side of the pond, I'd have confirmed for 2 of the 122-key ones(unless shipping to the US is reasonable).
Title: Making a cheap Model M USB controller
Post by: clee on Mon, 01 March 2010, 19:46:10
Oh, hrm. I'm in California. If Americans can't chip in, then count me out. :/
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 March 2010, 04:09:04
Shipping from there to here is not much more than between US-Canada depending on packaging and service used. The cost of the part itself would be substantially higher...probably approximately $35+ each on an order of 100? Obviously that's a guess, you'd be best to wait for a quote from the guy who'd be doing it.

I've got my programmer, AVRs, crystals, FFC connectors, 68 ohm resistors, USB jacks, and pin headers...everything else is presently shipping. Looks like I'll have the parts in time for March break so there'll be a week of uninterrupted electronics geek time.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Tue, 02 March 2010, 05:47:28
I've had another chat this morning.

He would be marketing these himself, and to GH member's only, at a cost price until the first run is used up. He will get an idea if this is a marketable, if niche, product. I suspect that the initial run (~100) will be the bulk of the orders.

It's not going to happen for a while, as he is Flat-out with work at the moment (considering the economy sucks balls, that is a rarity, and his paid work will naturally take priority). He will give me a heads-up and contact details. He will confirm pricing at the same time.

He's going to have a look at my finished product, along with an original controller board. He's not sure if SMD or Manual placement will work out cheaper (Doint things the SMD route will interrupt his line, and require programming of the line for this board, he doesn't do too much with MicroProcessors despite having the capability to handle even heavy duty stuff). I've said as long as it fits and works, it's all good, though a drop-in replacement for the original would be great. Given the above, and the fact that they will need manual finishing even if done SMD (Berg and Membrane connector, LED's), the Manual route looks likely at the moment.

WRT import/export to other countries, that's fine. All the parts and processes used are ROHS compliant, and he's happy to ship overseas at cost. This would be done in batches though, he doesn't want to have to package up stuff every 5 minutes or so.

Any other Questions as he will be contactable for the rest of the day before dissapearing to warmer climate(s) for a week or so.
Title: Making a cheap Model M USB controller
Post by: sethstorm on Tue, 02 March 2010, 13:25:59
Quote from: kishy;161426
Shipping from there to here is not much more than between US-Canada depending on packaging and service used. The cost of the part itself would be substantially higher...probably approximately $35+ each on an order of 100? Obviously that's a guess, you'd be best to wait for a quote from the guy who'd be doing it.

Then it should be fine.  It'd make my Terminal M board a bit easier to justify using.  If it's the LED version, it just means I'd be making provisions for the lights on the case, as there is room to do it on the right side.

Quote from: InSanCen;161436
He would be marketing these himself, and to GH member's only, at a cost price until the first run is used up. He will get an idea if this is a marketable, if niche, product. I suspect that the initial run (~100) will be the bulk of the orders.

It's not going to happen for a while, as he is Flat-out with work at the moment (considering the economy sucks balls, that is a rarity, and his paid work will naturally take priority). He will give me a heads-up and contact details. He will confirm pricing at the same time.

He's going to have a look at my finished product, along with an original controller board. He's not sure if SMD or Manual placement will work out cheaper (Doint things the SMD route will interrupt his line, and require programming of the line for this board, he doesn't do too much with MicroProcessors despite having the capability to handle even heavy duty stuff). I've said as long as it fits and works, it's all good, though a drop-in replacement for the original would be great. Given the above, and the fact that they will need manual finishing even if done SMD (Berg and Membrane connector, LED's), the Manual route looks likely at the moment.

WRT import/export to other countries, that's fine. All the parts and processes used are ROHS compliant, and he's happy to ship overseas at cost. This would be done in batches though, he doesn't want to have to package up stuff every 5 minutes or so.

No problem with that.  Given that this is probably going to be the GH's AIKON, I'm fine with waiting for batches.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 March 2010, 14:01:31
Whoa, AIKON, forgot about that.

insancen, fancy asking your connection about throwing together AIKONs too? That's another open source project as I understand it so all needed docs are floating around online.

sethstorm, keep in mind you can build your own if so equipped and inclined...I will be. I'd actually be willing to assemble them for other people if mine end up being successful (but not if insancen can get us professional assembly, total cost after shipping stuff wouldn't make sense)

Relevant side note: I probably wouldn't be in on one of the professionally assembled ones since I am building two already.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Tue, 02 March 2010, 16:09:46
I would ask, but my favors are dried up now :-(

I'm not sure if this would work with a Terminal M, unless you flashed another keymap onto it, due to the extra keys. It will be flashed with US ANSI QWERTY (Decision based on numbers in use, I actually prefer ISO). You can flash your own as intended as it will still have the relevant pins on the board (A few pennies cost difference in the batch size we are talking about).

As I have said, I will need to provide Gerber files, though he will run a Manual check over the finished (working) article that I make for comparison purposes. I will get  these done, but time is a constraint on my end, so if someone has them, or fancies doing them, then feel free. It doesn't need to be done *now* but they do need to be ready for when he can run these boards off.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 02 March 2010, 16:58:35
Oh that's right, the 122s need a slightly different design. I keep forgetting the controller is by default for 'normal' Model Ms...for me they only apply to the 122s so that's all I focus on when I talk about them.

So yeah, sethstorm, you'd be building your own for a 122 regardless of what insancen can arrange.
Title: Making a cheap Model M USB controller
Post by: sethstorm on Tue, 02 March 2010, 19:16:29
Quote from: kishy;161549
Oh that's right, the 122s need a slightly different design. I keep forgetting the controller is by default for 'normal' Model Ms...for me they only apply to the 122s so that's all I focus on when I talk about them.

So yeah, sethstorm, you'd be building your own for a 122 regardless of what insancen can arrange.

Hmm. So much for a properly done board.  While I be able to put the parts together, the programmer bits are what would be the stumbling block.

What page had the parts list for it?  I figure they're slightly different, just enough that the parts for the 122 board are different than the Model M ones are.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Wed, 03 March 2010, 01:31:36
Quote from: sethstorm;161589
Hmm. So much for a properly done board.  While I be able to put the parts together, the programmer bits are what would be the stumbling block.

What page had the parts list for it?  I figure they're slightly different, just enough that the parts for the 122 board are different than the Model M ones are.


Your matrix may (Likely) be different too. I haven't got a Terminal board to pull apart and look, sorry.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 03 March 2010, 06:27:29
Quote from: InSanCen;161436
He would be marketing these himself, and to GH member's only, at a cost price until the first run is used up. He will get an idea if this is a marketable, if niche, product. I suspect that the initial run (~100) will be the bulk of the orders.

That's brilliant! :happy:
I'd even buy one or more (depending on price) just to get a professional PCB.

Quote from: InSanCen;161436
He's not sure if SMD or Manual placement will work out cheaper (Doint things the SMD route will interrupt his line, and require programming of the line for this board, he doesn't do too much with MicroProcessors despite having the capability to handle even heavy duty stuff). I've said as long as it fits and works, it's all good, though a drop-in replacement for the original would be great. Given the above, and the fact that they will need manual finishing even if done SMD (Berg and Membrane connector, LED's), the Manual route looks likely at the moment.

Manual finishing doesn't sound bad at all, as long as all drill holes are prepared. I think the most important thing would be to program the MCU--at least with a boot loader--before shipping since most people won't have a suitable programmer at hand. Soldering a few connectors should be easy enough for most people, or they could ask someone else to do the soldering for them.

Quote from: kishy;161505
insancen, fancy asking your connection about throwing together AIKONs too? That's another open source project as I understand it so all needed docs are floating around online.

AIKON's not exactly open source. The circuits are available, and firmware images too, but the source code for firmware and user land tools are closed source. The controller can only be configured on Windows and there's no way to change this, which is rendering it, regrettably, useless for me.

On the other hand, making AIKON clones could be more lucrative because AIKON is older, thus better known, than the controller discussed here (which doesn't even have a real name yet :wink:), and its firmware is not limited to be used in a 1391401 (but also couldn't support the 20x8 terminal keyboard matrix).

FWIW, I would prefer a proper 1391401 replacement controller that also fits into a Mini, including all connectors, rather than an AIKON clone. ;)

Quote from: sethstorm;161589
What page had the parts list for it?  I figure they're slightly different, just enough that the parts for the 122 board are different than the Model M ones are.

There is no complete list yet. It's not much different from the Model M list for the simple version w/o LEDs, though: just use a 20-pin connector instead of the 16-pin, and omit the three 470 Ohm resistors and the 4-pin connector. For the LED version, replace the 16-pin connector with a 20-pin, and add one 74HC165 IC and eight 22k resistors.

Maybe I should extend the main article so to mention terminal keyboards and to include the relevant parts lists...
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 03 March 2010, 07:22:09
..

InSenCen  you said, in reference to 122key terminal boards:
"Your matrix may (Likely) be different too. I haven't got a Terminal board to pull apart and look, sorry."

To jog your memory...I have traced out the row-column matrix of my 1390702 122key terminal boards, and Ripster has photos of a Boscom 122key membranes.

This thread, page 3, post #36 (Ripster) #40 (Me).

(http://geekhack.org/attachment.php?attachmentid=7266&d=1263181593)
:brick:

.......
Spec57
Title: Making a cheap Model M USB controller
Post by: InSanCen on Wed, 03 March 2010, 15:23:52
Sounds good. It should be just a different Keymap for a 122key then?

The boards will have a complete firmware on them, including a US ANSI map. It's easy enough for him to flash then before placement apparently. I am assuming he has an automated doohickey to do it.

When I said Manual finishing, I meant at time of manufacture. The boards should be ready to plug in and go, assuming a US ANSI layout.
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 03 March 2010, 17:19:45
100% of my needed parts are here now.

I'll be playing with laying out parts on the board (the stripboard I have has the copper strips going the 'wrong' direction) and perhaps coming up with photos showing a decent layout for a 122.

Keep in mind that, at least with the original 122-key terminal M design, the controller doesn't mount into a spot on the case...it's screwed onto the metal backplate, so there's some flexibility afforded by that.
Title: Making a cheap Model M USB controller
Post by: sethstorm on Wed, 03 March 2010, 22:30:18
Quote from: kishy;161703
100% of my needed parts are here now.

I'll be playing with laying out parts on the board (the stripboard I have has the copper strips going the 'wrong' direction) and perhaps coming up with photos showing a decent layout for a 122.

Keep in mind that, at least with the original 122-key terminal M design, the controller doesn't mount into a spot on the case...it's screwed onto the metal backplate, so there's some flexibility afforded by that.

That's why I had reservations about going the stripboard route - it being too dependent on layout of the board as well as the wiring.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Thu, 04 March 2010, 01:07:38
It's just a matter of component placement. The "wires" still go the same way, the schematic hasn't changed. My controller will be significantly smaller than the Prototype (That is why we have prototype's, make it, see it works, improve it. Without the initial prrof-of-soncept, there isn't a 2nd or 3rd revision etc).
Title: Making a cheap Model M USB controller
Post by: sethstorm on Thu, 04 March 2010, 17:29:33
Quote from: InSanCen;161732
It's just a matter of component placement. The "wires" still go the same way, the schematic hasn't changed. My controller will be significantly smaller than the Prototype (That is why we have prototype's, make it, see it works, improve it. Without the initial prrof-of-soncept, there isn't a 2nd or 3rd revision etc).


Indeed.  I just dont like splitting up an already-fragile stripboard just for the alignment.  

Now if there was something a bit more reliable than compressed paper-board to solder onto, I'd be less likely to just skip to the finished boards.
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 05 March 2010, 14:32:55
Need insight from mnemonix...

When altering the firmware for 122-keys, did you take into account the fact that the ribbon connectors are backwards, with regards to physical connection?

(comparing the beginnings of mine to your finished product, the connectors are in backwards order and it seems to me that means the pins go "20 to 1" instead of "1 to 20" and "8 to 1" instead of "1 to 8")

The only possible fix would have to be in the firmware as it's not physically possible to arrange it any other way. Please investigate. I could be wrong here but before I go much further I want to make sure that's not going to be an issue.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Fri, 05 March 2010, 16:47:26
Quote from: sethstorm;161839
Indeed.  I just dont like splitting up an already-fragile stripboard just for the alignment.  

Now if there was something a bit more reliable than compressed paper-board to solder onto, I'd be less likely to just skip to the finished boards.


Fibreglass board.

If Kishy would be so kind as to post a picture...

It's much more substantial than the normal Veroboard. It also doesn't smell.

I'm fine with standard stuff. I built an Amp about 10 years ago on it, and it's still going strong. Hell, my Glass-density analyser for my A Level project (A looooong time ago) is still working perfectly on veroboard (The Final on PCB is still used in a factory today surprisingly enough!)
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 05 March 2010, 16:55:48
Quote from: InSanCen;162041
Fibreglass board.

If Kishy would be so kind as to post a picture...

It's much more substantial than the normal Veroboard. It also doesn't smell.

I'm fine with standard stuff. I built an Amp about 10 years ago on it, and it's still going strong. Hell, my Glass-density analyser for my A Level project (A looooong time ago) is still working perfectly on veroboard (The Final on PCB is still used in a factory today surprisingly enough!)

Yes, what he sent me is awesome stuff...it's almost like plastic in the sense that it's got no smell, texture is smooth, thickness uniform, all that stuff.

I'd be happy to post a photo but I've hacked it apart into two pieces for my two controllers. Had been hoping to clean up the rough edge before showing it off...and ideally also finish the board...but oh well, I will anyway, you can all lawl at my bad construction techniques. Decided to go with 'simple' design for the first, LED design for the second.

I gradually realized more and more that I'd have to run a little wire lead for ALL of the FFC connector pins regardless of what I did, so I just threw em on there with no regard for pin alignment with the AVR socket. I highly recommend nobody do it the same way I have, it's going to be very messy with 28 little jump wires in the finished item.

(http://geekhack.org/attachment.php?attachmentid=8202&stc=1&d=1267829735)
Title: Making a cheap Model M USB controller
Post by: sethstorm on Sat, 06 March 2010, 02:39:54
Quote from: kishy;162044
Yes, what he sent me is awesome stuff...it's almost like plastic in the sense that it's got no smell, texture is smooth, thickness uniform, all that stuff.

I'd be happy to post a photo but I've hacked it apart into two pieces for my two controllers. Had been hoping to clean up the rough edge before showing it off...and ideally also finish the board...but oh well, I will anyway, you can all lawl at my bad construction techniques. Decided to go with 'simple' design for the first, LED design for the second.

I gradually realized more and more that I'd have to run a little wire lead for ALL of the FFC connector pins regardless of what I did, so I just threw em on there with no regard for pin alignment with the AVR socket. I highly recommend nobody do it the same way I have, it's going to be very messy with 28 little jump wires in the finished item.

Show Image
(http://geekhack.org/attachment.php?attachmentid=8202&stc=1&d=1267829735)


Looking good.  Is there a way to position things so that you can use ribbon cables to wire up the 'cardedge connector' to the ATMEGA?  It would seem a bit easier that way to keep things together.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 06 March 2010, 08:56:40
Quote from: kishy;162015
Need insight from mnemonix...

When altering the firmware for 122-keys, did you take into account the fact that the ribbon connectors are backwards, with regards to physical connection?

(comparing the beginnings of mine to your finished product, the connectors are in backwards order and it seems to me that means the pins go "20 to 1" instead of "1 to 20" and "8 to 1" instead of "1 to 8")


I took the picture of your controller from #37 (http://geekhack.org/showpost.php?p=149857&postcount=37) and the matrix info posted by Specter_57 as a reference. I've seen that, like on the Model M, the connectors are mounted in opposite directions, but the pins are numbered 20...1, 8...1 from left to right (both, on the controller and on the matrix info). So I used the numbering scheme suggested by the numbers on the controller to write down the matrix definition file.

You can check whether or not I messed this bit up by making sure that Left Control is attached to the right-most contacts on the two connectors (corresponding to column 1, row 1) when plugging the matrix sheets to the controller. Similarly, the left-most contacts (column 8, row 20) should go to the Enter key on the numpad. If not, there is some problem...

By the way, I took a closer look a Ripster's Boscom matrix images, and it seems like the Boscom matrix is a bit different from the 1390702 one... (or I got confused by all those labyrinthine lines on the pictures)

Quote from: kishy;162044
The only possible fix would have to be in the firmware as it's not physically possible to arrange it any other way. Please investigate. I could be wrong here but before I go much further I want to make sure that's not going to be an issue.


I've chosen the chip-pin-to-connector assignment so that eight contacts of the 20-pin connector can be attached directly to the pins on the MCU (either rows 20...13 to MCU pins 40...33, or rows 12...5 to MCU pins 29...22). This may or may not be of any help, but at least there are no crossing wires this way.

In case the connections are wrong and need to be rearranged, it is easy to juggle rows and columns around in the firmware. The boot loader may need to be fixed separately then, though; but you have a programmer, so that's not a problem.
Title: Making a cheap Model M USB controller
Post by: kishy on Sat, 06 March 2010, 10:19:48
Quote from: sethstorm;162089
Looking good.  Is there a way to position things so that you can use ribbon cables to wire up the 'cardedge connector' to the ATMEGA?  It would seem a bit easier that way to keep things together.


Thanks...aside from the burn marks here and there, I think it's not TERRIBLE, just a little amateurish.

Yes, ribbon cables would be feasible, however in a couple segments. Carefully look at the schematics and you'll see not all of the pins are together in continuous blocks. On the overall it'd be possible and a cleaner way to do it, but since I've already prepared all the little jump wires I'll do this one that way. I'm learning from the first build so I can do the second one better.

Quote from: Mnemonix;162116
I took the picture of your controller from #37 (http://geekhack.org/showpost.php?p=149857&postcount=37) and the matrix info posted by Specter_57 as a reference. I've seen that, like on the Model M, the connectors are mounted in opposite directions, but the pins are numbered 20...1, 8...1 from left to right (both, on the controller and on the matrix info). So I used the numbering scheme suggested by the numbers on the controller to write down the matrix definition file.


Looked at original controller again...yes, the silkscreening suggests 20-1 and 8-1. Just gotta hope that means the obvious meaning.

Quote from: Mnemonix;162116
You can check whether or not I messed this bit up by making sure that Left Control is attached to the right-most contacts on the two connectors (corresponding to column 1, row 1) when plugging the matrix sheets to the controller. Similarly, the left-most contacts (column 8, row 20) should go to the Enter key on the numpad. If not, there is some problem...


Alright, so what I'll do is follow the schematic (the later version of simple.pdf) the way I have been to connect those four pins, get some firmware on the bugger and see what happens. Won't be connecting any other wires if those keys don't function right...if they do I may just finish the thing up entirely.

Quote from: Mnemonix;162116
By the way, I took a closer look a Ripster's Boscom matrix images, and it seems like the Boscom matrix is a bit different from the 1390702 one... (or I got confused by all those labyrinthine lines on the pictures)


That could be a problem...though it doesn't make sense why it would change, I did say numerous times we should be ready for possible differences...was really hoping that by saying it I'd eliminate the possibility of it happening though. We'll see what happens I guess.

Quote from: Mnemonix;162116
I've chosen the chip-pin-to-connector assignment so that eight contacts of the 20-pin connector can be attached directly to the pins on the MCU (either rows 20...13 to MCU pins 40...33, or rows 12...5 to MCU pins 29...22). This may or may not be of any help, but at least there are no crossing wires this way.


I had noticed that and thought "AWESOME" but then looked at the size of the stripboard I have and said "DAMNIT". Doing that would have resulted in the 8 pin connector floating in the air beside the stripboard.

BTW the reason the AVR socket is in the middle instead of off to the right is because there will be DIP switches to the right of the socket...DIP switches are 1337, jumpers are for...people who aren't DIPswitchy. Let's just say you can't trust me with the engineering sample order form.

Quote from: Mnemonix;162116
In case the connections are wrong and need to be rearranged, it is easy to juggle rows and columns around in the firmware. The boot loader may need to be fixed separately then, though; but you have a programmer, so that's not a problem.


If fixes are necessary, well, that's the nature of the project I suppose. I'll report back my findings and we can go from there.
Title: Making a cheap Model M USB controller
Post by: kishy on Sat, 06 March 2010, 11:17:55
Alright, so it's in a state I can program it in, but then I hit a roadblock. AVRDude isn't GUI?!?!

Need help understanding the switches. Windows port has following options:

Code: [Select]
C:\Documents and Settings\Kevin\Desktop\avrdude-5.4-win>avrdude.exe
Usage: avrdude.exe [options]
Options:
  -p <partno>                Required. Specify AVR device.
  -b <baudrate>              Override RS-232 baud rate.
  -B <bitclock>              Specify JTAG/STK500v2 bit clock period
  -C <config-file>           Specify location of configuration file
  -c <programmer>            Specify programmer type.
  -D                         Disable auto erase for flash memory
  -i <delay>                 ISP Clock Delay [in microseconds]
  -P <port>                  Specify connection port.
  -F                         Override invalid signature check.
  -e                         Perform a chip erase.
  -O                         Perform RC oscillator calibration (see
  -U <memtype>:r|w|v:<filename>[:format]
                             Memory operation specification.
                             Multiple -U options are allowed, each
                             is performed in the order specified.
  -n                         Do not write anything to the device.
  -V                         Do not verify.
  -u                         Disable safemode, default when running
t.
  -s                         Silent safemode operation, will not as
                             fuses should be changed back.
  -t                         Enter terminal mode.
  -E <exitspec>[,<exitspec>] List programmer exit specifications.
  -y                         Count # erase cycles in EEPROM.
  -Y <number>                Initialize erase cycle # in EEPROM.
  -v                         Verbose output. -v -v for more.
  -q                         Quell progress output. -q -q for less.
  -?                         Display this usage.

avrdude project: <URL:http://savannah.nongnu.org/projects/avrdude>

Programmer driver is installed and will be using the 1390702 no LEDs files for this. Would someone please give me the complete command (or set of them, I suppose) to go from "blank AVR" to "working 122-key AVR"? TIA!

Edit:
Obtained copy I have here: http://tinkerlog.com/2007/07/15/avrdude-54-for-windows/
If I should be looking elsewhere I'd appreciate the direction.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 07 March 2010, 08:14:37
Quote from: kishy;162154
Alright, so it's in a state I can program it in, but then I hit a roadblock. AVRDude isn't GUI?!?!

GUI? Fortunately not. How could you ever automate anything with a program that looks like a point-and-click adventure? :wink:

Anyway, here are the generated command lines for programming an ATMEGA32. The first command is used for programming the fuses (chip configuration), the second and third are used for writing the boot loader and main firmware, respectively, and the last command makes the boot loader section read-only.

Code: [Select]
$ avrdude -p atmega32 -c usbasp -U lfuse:w:0x1f:m -U hfuse:w:0xd2:m
$ avrdude -p atmega32 -c usbasp -U flash:w:boot.hex
$ avrdude -p atmega32 -c usbasp -U flash:w:main.hex
$ avrdude -p atmega32 -c usbasp -U lock:w:0x2f:m

Programming is a quite slow process, so I am usually omitting the third command and use bootloadHID (another command line tool) to flash the main.hex file over the keyboard controller's USB port. You'll need to attach the controller to the rest of the keyboard, however, in order to be able to hold down Escape to activate the boot loader... This is also the way to update the firmware later.

To read out the fuse settings (not required, just for checking if fuses are set up correctly), I use this one:

Code: [Select]
$ avrdude -p atmega32 -c usbasp -U lfuse:r:-:h -U hfuse:r:-:h -U lock:r:-:h
You may need to pass a different string with the -c option if your programmer is not USBasp compatible. The red stick-like programmer should work with exactly these commands.


I hope it works on Windows, too. I've only ever tested this on Linux. It is probably substantially easier to get everything working from scratch on Linux because the required software is either installed there by default or is just an apt-get away.

Note that it is definitely possible to make a working controller by programming the pre-compiled boot loader and firmware images to the MCU, but that there is no binary version of the kbuptool utility program for Windows at the moment. This means that there is no easy way to upload a key map to the controller on Windows, so only the standard QWERTY map will be usable. Someone will need to build the program for Windows to make the controller fully usable.
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 07 March 2010, 11:20:25
Alrighty, thanks. I'll toy around with this a bit later (will wire up the FFC connectors first). Yeah, the red stick programmer is usbasp compatible.

Reference to GUI was because I thought I had seen, somewhere in the vast expanses of the internet, a screenshot of a GUI program and a reference to AVRdude together, suggesting the screenshot was of AVRdude. Apparently not.

Oh, a note I should make somewhere, I'm using a segment of twisted pair ethernet cable to give me the wires I'm using in this. It's nice and thin and a quality solid core copper wire. Only problem is the insulation heats up and melts REALLY quickly so you've gotta be quick with the iron.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 07 March 2010, 14:56:53
Quote from: kishy;162306
Reference to GUI was because I thought I had seen, somewhere in the vast expanses of the internet, a screenshot of a GUI program and a reference to AVRdude together, suggesting the screenshot was of AVRdude. Apparently not.


It is very well possible that someone has written a graphical frontend for AVRdude, but I don't know of any.

OK, now I know of one: Google pointed me at avrdude-gui (http://sourceforge.net/projects/avrdude-gui/), but obviously I've never tried it.
Title: Making a cheap Model M USB controller
Post by: kishy on Sun, 07 March 2010, 15:03:42
First command worked like a charm. Second gave me an issue.

Code: [Select]

avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.



So I tried with the -F switch like it suggested (just to see what'd happen):

Code: [Select]
avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9500
avrdude: Expected signature for ATMEGA32 is 1E 95 02
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: reading input file "boot.hex"
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: writing flash (32632 bytes):

Writing | ################################################## | 100% 11.38s



avrdude: 32632 bytes of flash written
avrdude: verifying flash memory against boot.hex:
avrdude: load data flash data from input file boot.hex:
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: input file boot.hex contains 32632 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 9.69s



avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x00
avrdude: verification error; content mismatch

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


???
What would cause this?


Edit: oh yeah, no longer using the version of avrdude I indicated earlier. It said no libusb or something like that so I went looking for a more functional version. WinAVR (as a suite) is what I downloaded, newest version, in it you can find the version of avrdude i'm using now
Title: Making a cheap Model M USB controller
Post by: nowsharing on Sun, 07 March 2010, 23:08:44
When does mass production start? I'd like to pre-order a couple :)

BTW this thread is blatant discrimination against those of us who are neither hardware nor software savvy.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 08 March 2010, 04:35:28
Quote from: kishy;162331
First command worked like a charm. Second gave me an issue.

Code: [Select]
avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.



I get the same warning wrt. "sck period", but it doesn't cause problems here. The error could mean that you've wired up things incorrectly, but you wrote that the first command worked... When running the fifth command, does it report the fuse values that you've written with the first command? (The output is much too verbose, but it should mention the fuse values somewhere.)

Would it be possible that your USB port does not supply enough current? Usually my whole USB system goes down when I try to flash from one of my monitor's USB ports (even requires a reboot), but I've never had problems when using the mainboard's or card reader's USB ports.

Quote from: kishy;162331

Code: [Select]
avrdude: Device signature = 0x1e9500
avrdude: Expected signature for ATMEGA32 is 1E 95 02


This looks wrong. The device signature should match the expected value. Here (http://avr.fenceline.de/device_data.html) is a list of AVR device signatures, but 1E 95 00 is not listed. A faulty chip maybe, even if unlikely, or a faulty programmer (also very unlikely).

Quote from: kishy;162331

Code: [Select]
Writing | ################################################## | 100% 11.38s


And this is much too fast. It takes my programmer a few minutes to write 32 kB, and yours is basically the same as mine. It seems like the programmer is writing to nothingness because you've forced it.

Quote from: kishy;162331

Edit: oh yeah, no longer using the version of avrdude I indicated earlier. It said no libusb or something like that so I went looking for a more functional version. WinAVR (as a suite) is what I downloaded, newest version, in it you can find the version of avrdude i'm using now


Yes, upgrading to a more recent version of AVRdude may help, too. My version is 5.8.

I still suspect it's the power supply, though. Try a different USB port or a powered USB hub. If then you're still encountering problems, you could try attaching the AVR to a good, stabilized external power supply and switch the programmer to unpowered mode (there's a jumper on my device to cut the power supply from the programmer to the AVR).

Quote from: nowsharing;162443
When does mass production start? I'd like to pre-order a couple :)


Let's see what InSanCen can arrange. Seems like there is indeed a market for these controllers.

Quote from: nowsharing;162443
BTW this thread is blatant discrimination against those of us who are neither hardware nor software savvy.


Is this a request for better documentation? :)
Title: Making a cheap Model M USB controller
Post by: sethstorm on Tue, 09 March 2010, 12:07:16
Quote from: Mnemonix;162490

Let's see what InSanCen can arrange. Seems like there is indeed a market for these controllers.

Is this a request for better documentation? :)

Board layouts for the Terminal 122 would be fine enough, if only regular keyboard controllers are being pre-made.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 09 March 2010, 13:04:01
Thanks for the pointers, I'm letting my brain calm down for a couple days before I mess with it again. I do know the pinout I have is right, I checked it 3 times. Bad uC isn't impossible, it was a rather cheap eBay purchase. Haven't left feedback yet so I've still got my bargaining chip (heh, pun) for a replacement if needed.

I'll investigate late this week, maybe the weekend.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Thu, 11 March 2010, 14:30:03
Quote from: nowsharing;162443
When does mass production start? I'd like to pre-order a couple :)

BTW this thread is blatant discrimination against those of us who are neither hardware nor software savvy.


I am working on a PCB layout. Production will start when he get's a break in his orders. As this is a favour, I cannot ask him to break into profit-making production for this. As soon as they are available, you *will* know about it. I will guinea-pig my '89 board for testing. As an aside, he's loving the loaner M i let him have to evaluate the physical space we are working with. All we need is for him to make an account here... ;-P
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 12 March 2010, 03:06:56
Quote from: InSanCen;163225
I am working on a PCB layout.


Cool, thanks for spending your time on this project! :) Can't wait to see the result.

Quote from: InSanCen;163225
As an aside, he's loving the loaner M i let him have to evaluate the physical space we are working with. All we need is for him to make an account here... ;-P


Would you care taking the dimensions of the smaller Model M Mini into account, too? There's less space in vertical direction in a Mini, so you'd need to be careful placing big parts not too far from the back of the case. I could take pictures and measure the available space for you.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Fri, 12 March 2010, 04:26:48
Quote from: Mnemonix;163395
Cool, thanks for spending your time on this project! :) Can't wait to see the result.



Would you care taking the dimensions of the smaller Model M Mini into account, too? There's less space in vertical direction in a Mini, so you'd need to be careful placing big parts not too far from the back of the case. I could take pictures and measure the available space for you.



If you can get me some Dimensions, I will make sure it fits. I will attempt to make sure that regular M and Mini have ready-to-go mounting holes. I will need the Width and height of the available space, and where the mounting holes/posts are located.
Title: Making a cheap Model M USB controller
Post by: trievalot on Fri, 12 March 2010, 06:02:57
Thank you.....i want 2 please :)
(then i wont NEED 2 X SDL cables)
Title: Making a cheap Model M USB controller
Post by: InSanCen on Fri, 12 March 2010, 16:27:38
Quote from: ripster;163445
OOOOooooo.  Model M Mini PCB - sign me up!

Here's the dimensions.

...Good Pictures and Metric Numbers...

USB Mini Layout would be great for me!  Let me know if you need any other measurements or bigger pics.


Perfect! I can see the only measurement I needed that you didn't include (3rd pic down, centers on mounting posts).

I think we can accomodate that. As long as component placement and traces do not interfere, I should be able to make a drop-in board that will fit in both the M and the Mini. I just need to open an M and see if a board that size can be securely mounted. If it can, the finished product will be the size of the Mini's board. This is assuming that the controller is identical, and will just not use the rows and columns for the Numpad. If these can be left floating, then no additional work is needed. If they need to be tied low, than I think a switch could toggle between M and Mini modes.

I also had a quick chat with the guy who will be making these. Having looked into it, he think's it would be more feasable to do a PCB only run for .1 components. Just sounding out for interest, as he will have spare capacity on that line before he does on lines handling components. We also chatted about timescale. Bad news. Assuming no order cancellations, he's flat-out busy for at least 3 months (PCB only) and 5 months (Full board, assuming he finds a suitable connector for the Membrane to PCB). As I have said previously, the first run will be done at cost to GH members (and only "real" GH members, not someone registering just to get hold of it). Because of this, I will *not* let him break production, he is after all, a friend of mine.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 13 March 2010, 08:56:05
Quote from: ripster;163445
OOOOooooo.  Model M Mini PCB - sign me up!

Here's the dimensions.


Thank you Ripster. Here is something I'd like to add (I really can't compete with your pictures, but anyway):





You can see that the plastic part that supports the keyboard assembly is smaller and shorter in the Mini (top) than in the '401 (bottom), so that the metal plate sits significantly closer to the bottom of the case in a Mini.

There's only 6.5 mm between the plastic and the assembly at the inner-most edge, compared to more than 8.3 mm (maybe even more than 9 mm) in the '401. This leaves only about 4 mm or less for components in this area. The PCB is held in place by plastic clips in both keyboards; in the Mini, these clips are located right next to a plastic ridge, but in the '401 these clips are farther from that ridge, giving more than 8.3 mm in vertical direction:





Sorry for the dirty '401 case... ;)

Please also keep in mind that there is also some plastic from the rivets protruding into the case, further reducing the available space.

Otherwise, all other dimensions seem to be roughly the same in both keyboards. In fact, the PCB of the '401 does fit into the case of the Mini, but sits rather tightly. It would be perfect if the PCB was 0.5 mm shorter on the shorter side (so better make it 4.995 cm or 4.99 cm instead of 5.0 cm). I didn't check, however, if the keyboard assembly would fit without touching the PCB, but I guess it would.

Here is a picture of the two cases lying on top of each other (slightly misaligned), with the Mini case at the bottom of the picture lying on top of the '401.



Quote from: InSanCen;163481
If it can, the finished product will be the size of the Mini's board. This is assuming that the controller is identical, and will just not use the rows and columns for the Numpad. If these can be left floating, then no additional work is needed. If they need to be tied low, than I think a switch could toggle between M and Mini modes.


There is no switching required. The same controller can be used in both models, it's just a question of dimensions. My stripboard version can be used in both models, too, the membrane connectors are also in the correct locations in both models. And even though there is a special firmware for the Mini, a controller with the '401 firmware would also work in a Mini.

Quote from: InSanCen;163481
I also had a quick chat with the guy who will be making these. Having looked into it, he think's it would be more feasable to do a PCB only run for .1 components. Just sounding out for interest, as he will have spare capacity on that line before he does on lines handling components.


.1 components means 0.1 mm pitch? As long as the 2.54 mm pitch membrane connectors fit in there somehow, why not?

Quote from: InSanCen;163481
We also chatted about timescale. Bad news. Assuming no order cancellations, he's flat-out busy for at least 3 months (PCB only) and 5 months (Full board, assuming he finds a suitable connector for the Membrane to PCB).


Hm, better late than never. How many units would he want to produce?
Title: Making a cheap Model M USB controller
Post by: InSanCen on Sat, 13 March 2010, 09:37:00
Quote from: Mnemonix;163666
.1 components means 0.1 mm pitch? As long as the 2.54 mm pitch membrane connectors fit in there somehow, why not?


.1", or 2.54mm

Quote from: Mnemonix;163666
Hm, better late than never. How many units would he want to produce?


He is producing, regardless. this is me calling in favours. If viable, he will produce more afterwards. The initial run will be ~100 units.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sat, 13 March 2010, 10:03:39
Quote from: InSanCen;163674
.1", or 2.54mm

He is producing, regardless. this is me calling in favours. If viable, he will produce more afterwards. The initial run will be ~100 units.


Um, right. Thinking again, 0.1 mm would be some very fine pitch...

100 units sounds reasonable.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Sun, 14 March 2010, 15:35:03
I hate FPC/FFC connectors.

Can I find a UK source? Can I hell as like. Digikey's UK site carries them, but judging from the shipping total (VAT to be added afterwards too), they are in the US.

Farnell and RS do not carry them either (and I know Maplin do not, as I work there).

On the upside (and someone queried this a while ago but I forgot to check), Maplin do a lucky bag of switches. In them are cherry whites. All the bag's I have checked have 3, but YMMV, it is a lucky bag after all.
Title: Making a cheap Model M USB controller
Post by: nowsharing on Sun, 14 March 2010, 23:53:06
Once you guys get this working, would it be a big step to wireless bluetooth? I would guess that an internal AA battery or two could supply the current, and some kind of USB to Bluetooth keyboard adapter could also be built in? Those might not exist though, I really have no clue.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 15 March 2010, 05:50:09
Quote from: InSanCen;163980
I hate FPC/FFC connectors.

I feel your pain.

I've got my engineering samples from German W+P Products (http://wppro.com/content/en/products/zif-lif-connectors-flexible-flat-cable/254mm-pitch.html). They are asking for a minimum ordering quantity of ~100 per type, so if they are not charging too much for shipping, this could be an option. I don't know the price of the connectors, however, because they didn't tell me... Just sent me some free connectors that I needed.

Quote from: nowsharing;164097
Once you guys get this working, would it be a big step to wireless bluetooth? I would guess that an internal AA battery or two could supply the current, and some kind of USB to Bluetooth keyboard adapter could also be built in? Those might not exist though, I really have no clue.

I could imagine hacking a Bluetooth USB hub like this one (http://www.inspector-gadget.co.uk/blog_134.shtml), in the spirit of Ripster's Model M USB hack (http://geekhack.org/showwiki.php?title=Island:6872). Instead of using the Blue Cube to convert from PS/2 to USB, you would use the hub to convert from USB to Bluetooth (either by using the hub as intended, or by hacking it to fit into the keyboard case). Don't know about the power supply, though...

InSanCen, could you include four empty soldering pads to the USB lines on your design? This way one could connect the controller directly to some Bluetooth hub/converter without using USB plugs.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Mon, 15 March 2010, 15:01:30
Quote from: Mnemonix;164136
InSanCen, could you include four empty soldering pads to the USB lines on your design? This way one could connect the controller directly to some Bluetooth hub/converter without using USB plugs.


Yup. Four pads right behind the USB connector suitable, flylead them in?

i am going to get some cardedge connector in work, use some blank stripboard to pad out the membrane, and see what I can get with that. I refuse to pay £12 shipping, and VAT in top, on a £5 order. If it works, I will be sure to post.
Title: Making a cheap Model M USB controller
Post by: kishy on Tue, 16 March 2010, 17:59:02
This is VERY frustrating.

I checked my wiring, everything seems correct following the 'simple' schematic. I've retraced it 3 different times and find nothing different from the schematic. However I still get these weird errors.

Now I'm getting this on any command:

Code: [Select]

avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.


Considering that voltage supply may have been the issues, I tried without using the programmer jumper that supplies power. For voltage I tried using a powered USB hub, with no USB connection to computer, plugged into wall. Nothing changed at all regarding errors.

Tried with my second AVR, same crap.

Do we suspect faulty programmer, or what? I told eBay seller I suspected one or both chips may be faulty (to make sure they are aware of it before any deadlines come up) so they're waiting to hear from me if I think it's the chip(s) or not. I would like to know myself...
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 18 March 2010, 05:42:50
Quote from: kishy;164604
This is VERY frustrating.

I checked my wiring, everything seems correct following the 'simple' schematic. I've retraced it 3 different times and find nothing different from the schematic. However I still get these weird errors.


Did you check for bad solder joints? Sometimes they look good, but make only a bad connection.

Quote from: kishy;164604
Now I'm getting this on any command:


On any command, even when trying to program or read out the fuses? If you've successfully programmed the fuses to the values I've posted here before, then you'll have to make sure that the crystal is hooked up correctly, even for programming. This is because the fuse settings instruct the AVR to use an external oscillator for its clock. The "target doesn't answer" error seems reasonable if there's no clock.

Quote from: kishy;164604
Considering that voltage supply may have been the issues, I tried without using the programmer jumper that supplies power. For voltage I tried using a powered USB hub, with no USB connection to computer, plugged into wall. Nothing changed at all regarding errors.

Tried with my second AVR, same crap.


So probably not a power problem, but if you have other USB ports, you could give them a try, too.

Is the second AVR pristine, i.e., with the fuses still in factory settings? If so, it should respond even with no external oscillator attached. We could rule out a bad crystal then.

Quote from: kishy;164604
Do we suspect faulty programmer, or what? I told eBay seller I suspected one or both chips may be faulty (to make sure they are aware of it before any deadlines come up) so they're waiting to hear from me if I think it's the chip(s) or not. I would like to know myself...


Hard to say what's the real problem. Could still be a pure software problem. Did you upgrade to a new version of avrdude already? Also try running avrdude more verbosely (like -vvvvv) to see what's going on. The example in the manual for the programmer sets option "-P usb"; I've never needed that one, but it could be a Windows thing (OTOH, it seemed to work for you w/o -P before).

Did you try Linux instead of Windows? A live CD like the Ubuntu installer should be enough for testing. Avrdude can be installed while running the live Ubuntu system, without touching your harddisks.
No, I don't trust Windows. ;)

If you have a breadboard, try setting up a minimal circuit just consisting of the AVR, the crystal oscillator, the three capacitors, and the 10k resistor. Leave out all the USB-related stuff. Then hook up your programmer and try again. If the minimal circuit works, then your bigger circuit must be wrong. Without a breadboard, you could still try this with wires, even if it's crude.
Title: Making a cheap Model M USB controller
Post by: kishy on Thu, 18 March 2010, 10:40:56
Quote from: Mnemonix;165066
Did you check for bad solder joints? Sometimes they look good, but make only a bad connection.

Checked with multimeter, everything's got good continuity. Looking at the joints, many look 'cold jointed', but any that had continuity issues were reflowed immediately.

Quote from: Mnemonix;165066
On any command, even when trying to program or read out the fuses? If you've successfully programmed the fuses to the values I've posted here before, then you'll have to make sure that the crystal is hooked up correctly, even for programming. This is because the fuse settings instruct the AVR to use an external oscillator for its clock. The "target doesn't answer" error seems reasonable if there's no clock.

Yeah, any command...but only sometimes!

If I unplug the programmer from the computer I can get it to pretend to behave for one operation, then it starts acting dumb again. Whatever operation I can get it to do fails in some manner or another.

Crystal is hooked up in correct position. Dumb question: there is NO type of "polarity" on a crystal, correct?

At the advice of the seller of the programmer, I've started using -B # switch on the commands to slow it down. The device signature problems went away when I tried 0.1, and it appeared to successfully write the bootloader, but then the content didn't match when it was done. It took around 7-8 seconds to do it so it wasn't an "insta-fail".

Quote from: Mnemonix;165066
So probably not a power problem, but if you have other USB ports, you could give them a try, too.

Have tried the programmer on all 4 of my laptop's USB ports.

When getting alternate power for the ATmega32 being programmed, it's just connected to a powered hub with no USB connection out of the hub...just using it for power. Power at the hub ports is good.

Quote from: Mnemonix;165066
Is the second AVR pristine, i.e., with the fuses still in factory settings? If so, it should respond even with no external oscillator attached. We could rule out a bad crystal then.

Second one does not have fuses programmed.
Apparently, neither does the first. They keep changing themselves back to 0, as avrdude likes to inform me.

Quote from: Mnemonix;165066
Hard to say what's the real problem. Could still be a pure software problem. Did you upgrade to a new version of avrdude already? Also try running avrdude more verbosely (like -vvvvv) to see what's going on. The example in the manual for the programmer sets option "-P usb"; I've never needed that one, but it could be a Windows thing (OTOH, it seemed to work for you w/o -P before).

I can't upgrade to a newer version of avrdude because a newer version doesn't exist compiled and working and including USB support...for Windows.

Regarding -P, apparently "atmega32" is incorrect, BTW. It's "m32". I started making some progress after making that change, but it's back to how it was before. Will try -P usb (you're the second to mention it) on next attempt.

Verbose...if next attempt gives problems, I'll re-do it verbosely and throw the output here.

Quote from: Mnemonix;165066
Did you try Linux instead of Windows? A live CD like the Ubuntu installer should be enough for testing. Avrdude can be installed while running the live Ubuntu system, without touching your harddisks.
No, I don't trust Windows. ;)

Linux...do not want, but will try as a last resort. I don't believe the type of issues showing up here CAN result from an OS incompatibility...the inconsistent nature of the failures and the fact that they change somewhat from attempt to attempt tells me this. A pure OS incompatibility would hang up in the exact same way every time because the OS isn't allowing something to happen...

Quote from: Mnemonix;165066
If you have a breadboard, try setting up a minimal circuit just consisting of the AVR, the crystal oscillator, the three capacitors, and the 10k resistor. Leave out all the USB-related stuff. Then hook up your programmer and try again. If the minimal circuit works, then your bigger circuit must be wrong. Without a breadboard, you could still try this with wires, even if it's crude.

No breadboard, but setting up with wires should be doable. My patience is going out the window however.

There's a reason I dislike open source software such as avrdude. This is the reason.

Not that it doesn't work...that there's no phone number to call and give them a piece of my mind.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 18 March 2010, 11:52:26
Quote from: kishy;165133
Crystal is hooked up in correct position. Dumb question: there is NO type of "polarity" on a crystal, correct?


Yes, there's no polarity. Doesn't matter which orientation you're soldering it in.

Quote from: kishy;165133
At the advice of the seller of the programmer, I've started using -B # switch on the commands to slow it down. The device signature problems went away when I tried 0.1, and it appeared to successfully write the bootloader, but then the content didn't match when it was done. It took around 7-8 seconds to do it so it wasn't an "insta-fail".


Maybe that's the way to go. Like I wrote before, writing the boot loader takes a few minutes with my setup, so you should try slowing down even more.

Quote from: kishy;165133
I can't upgrade to a newer version of avrdude because a newer version doesn't exist compiled and working and including USB support...for Windows.


You could compile your own version, but this could be a painful experience.

Quote from: kishy;165133
Regarding -P, apparently "atmega32" is incorrect, BTW. It's "m32". I started making some progress after making that change, but it's back to how it was before. Will try -P usb (you're the second to mention it) on next attempt.


There's -p and -P. The first one is used to specify the AVR type (atmega32, or m32 if this is correct for your version), the second one to specify the connection port. So you could try -p m32 -P usb (or just leave out the -P usb part if it has no effect).

Quote from: kishy;165133
Verbose...if next attempt gives problems, I'll re-do it verbosely and throw the output here.


Good.

Quote from: kishy;165133
Linux...do not want, but will try as a last resort. I don't believe the type of issues showing up here CAN result from an OS incompatibility...the inconsistent nature of the failures and the fact that they change somewhat from attempt to attempt tells me this. A pure OS incompatibility would hang up in the exact same way every time because the OS isn't allowing something to happen...


Unless the OS in question is Windows, that is. Pretty much everything is messed up under Windows' shiny (or not so) hood. Threads? Fail. USB? Fail. Consistent APIs that behave as documented? Fail.

Enough ranting. It should be possible to run avrdude on Windows as it works for other people, too, but the fact that you need to install a driver and an outdated version of avrdude doesn't make this kind of setup look very stable to me.

Quote from: kishy;165133
There's a reason I dislike open source software such as avrdude. This is the reason.

Not that it doesn't work...that there's no phone number to call and give them a piece of my mind.


Well, there's the internet for instant, free help. I'm trying to help, too, no need for expensive phone calls.

Speaking of open source, I can assure you that the firmware for the controller that you are building right now would never have been written if free software such as avrdude, gcc, vim, etc. would not exist. :wave:
Title: Making a cheap Model M USB controller
Post by: kishy on Thu, 18 March 2010, 12:17:56
I decided to try an erase, since I've read that it's generally needed if you're going to be re-writing the contents of the flash (which didn't seem right, since the entire flash contents seem to be erased before a transfer if avrdude is to be believed, but whatever)

First, we see the non-verbose output:

Code: [Select]
C:\WinAVR-20100110\bin>avrdude -B 0.1 -p m32 -P usb -c usbasp -e

avrdude: set SCK frequency to 1500000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

Now, we see the verbose output:

Code: [Select]
C:\WinAVR-20100110\bin>avrdude -B 0.1 -p m32 -P usb -c usbasp -e -vvvv

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"


         Using Port                    : usb
         Using Programmer              : usbasp
         Setting bit clk period        : 0.1
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-
         AVR Part                      : ATMEGA32
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom         4    10    64    0 no       1024    4      0  9000  90
00 0xff 0xff
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           flash         33     6    64    0 yes     32768  128    256  4500  45
00 0xff 0xff
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           lfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           hfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           lock           0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00
                                  Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           calibration    0     0     0    0 no          4    0      0     0
 0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: try to set SCK period to 1e-007 s (= 10000000 Hz)
avrdude: set SCK frequency to 1500000 Hz
avrdude: warning: cannot set sck period. please check for usbasp firmware update
.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.

...and why is the SCK period going to 1500000 Hz if I'm REDUCING the number?!?! Shouldn't it be...you know...going down?
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 19 March 2010, 06:22:25
Quote from: kishy;165151
I decided to try an erase, since I've read that it's generally needed if you're going to be re-writing the contents of the flash (which didn't seem right, since the entire flash contents seem to be erased before a transfer if avrdude is to be believed, but whatever)


Yes, in general you need to erase flash memory before writing, but avrdude does this automatically.

Quote from: kishy;165151
First, we see the non-verbose output:


OK, I've compared my verbose output with yours using the same command. Here is the main diff ("-"-lines belong to your output, "+"-lines are mine):

Code: [Select]
-avrdude: try to set SCK period to 1e-007 s (= 10000000 Hz)
-avrdude: set SCK frequency to 1500000 Hz
-avrdude: warning: cannot set sck period. please check for usbasp firmware update
-.
-avrdude: error: programm enable: target doesn't answer. 1
-avrdude: initialization failed, rc=-1
-         Double check connections and try again, or use -F to override
-         this check.
-
+avrdude: try to set SCK period to 1e-07 s (= 10000 kHz)
+avrdude: set SCK frequency to 1500 kHz
+avrdude: warning: cannot set sck period. please check for usbasp firmware update.
+avrdude: AVR device initialized and ready to accept instructions


Your version of avrdude is 5.10, which seems to be the latest and greatest available (mine is still 5.8), so I think it's not a problem with outdated software.

Your programmer seems to be OK, too, otherwise you wouldn't see these lines:

Code: [Select]
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-


It's the AVR that refuses to talk to your programmer.

Quote from: kishy;165151

...and why is the SCK period going to 1500000 Hz if I'm REDUCING the number?!?! Shouldn't it be...you know...going down?


The -B option takes the clock period in microseconds. The shorter the period, the higher the frequency.

But it's not that easy for USBasp programmers as I've just found out reading this post (http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01499.html) from this thread (http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01333.html).
Could you try -B 4 or -B 8 or something like that?
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 19 March 2010, 06:39:26
I should add that I have released new firmware images and source tarballs on SourceForge (http://sourceforge.net/projects/kbupgrade/) yesterday, now at version 0.3.0.

It's possible to use two function keys now, allowing to quick-switch between the default key map and three alternative key maps.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Mon, 29 March 2010, 19:22:44
EDIT: Argh, sorry, hadn't read far enough through the gargantuan thread to find your own follow up to this! (http://geekhack.org/showwiki.php?title=Island:8406&do=comments&page=10)

Quote from: Mnemonix;153547
I can't sell them because the USB part of the firmware is only for free if not used commercially. As soon as I start selling them, I'd have to pay a license fee.

I thought you were using the V-USB firmware?  If it's licensed to you under the GPL then there's no legal reason you can't sell devices that use the code; if you wanted to close the code as part of your commercial operation it would perhaps be a somewhat different matter.  I'm not a lawyer but it's certainly considered acceptable to sell stuff based on GPL code in the normal case - you just have to figure out a circumstance in which people will buy the stuff from you!  If they were to add the restriction that you couldn't sell devices based on the code then that would be in conflict with the terms of the GPL, as I understand them.

From their website I see:

"Commercial Licenses for V-USB

If the terms and conditions of the GPL are unsuitable for you, e.g. because you don't want to publish the source code of your firmware"

Which seems to imply that they're assuming commercial use will generally be by people who don't want to use the GPL version.  But not that they're forbidding commercial use of the GPL code if you can find a business case for it.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Tue, 30 March 2010, 12:30:57
Quote from: InSanCen;163481

I also had a quick chat with the guy who will be making these. Having looked into it, he think's it would be more feasable to do a PCB only run for .1 components. Just sounding out for interest, as he will have spare capacity on that line before he does on lines handling components. We also chatted about timescale. Bad news. Assuming no order cancellations, he's flat-out busy for at least 3 months (PCB only) and 5 months (Full board, assuming he finds a suitable connector for the Membrane to PCB). As I have said previously, the first run will be done at cost to GH members (and only "real" GH members, not someone registering just to get hold of it). Because of this, I will *not* let him break production, he is after all, a friend of mine.


I don't think I necessarily qualify as a "real" GH member as I only just registered to take part in this thread (though not specifically to try to buy a PCB!).  But if there were one or two boards available too me at a reasonable price I'd be interested.  Just the PCB would be cool, an assembled board would also be of interest since I could concentrate on programming it.  If it had the bootloader so it could be flashed without a programmer that would be just fine by me!
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 30 March 2010, 14:12:46
Quote from: MarkWilliamson;167936
EDIT: Argh, sorry, hadn't read far enough through the gargantuan thread to find your own follow up to this! (http://geekhack.org/showwiki.php?title=Island:8406&do=comments&page=10)


Yes, after re-reading the licensing conditions back then, I came to the same conclusion as you, I think. Good to know I'm not the only one who's understanding the licensing conditions this way. :)

At first I thought they'd allow licensing under GPL only if there's no money involved at all (pure hobby projects). But as long as all code is GPL'ed, there seems to be no need to buy their commercial licenses, even if selling controllers for profit.
Title: Making a cheap Model M USB controller
Post by: InSanCen on Tue, 30 March 2010, 18:01:51
Quote from: MarkWilliamson;168080
I don't think I necessarily qualify as a "real" GH member as I only just registered to take part in this thread (though not specifically to try to buy a PCB!).  But if there were one or two boards available too me at a reasonable price I'd be interested.  Just the PCB would be cool, an assembled board would also be of interest since I could concentrate on programming it.  If it had the bootloader so it could be flashed without a programmer that would be just fine by me!

It will be a while before this materialises. In the meantime, Read, Participate and yeah, sure no problem. You will then be a "Real" GH member... lol.

That comment was meant to deter someone looking to post, get a board, then dissapear for ever more. If you make a contribution to this forum (and if you can program AVR's, to this thread), then you are just as valid as any other GH member.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Tue, 30 March 2010, 19:30:56
Quote from: InSanCen;163481
It will be a while before this materialises. In the meantime, Read, Participate and yeah, sure no problem. You will then be a "Real" GH member... lol.

That comment was meant to deter someone looking to post, get a board, then dissapear for ever more. If you make a contribution to this forum (and if you can program AVR's, to this thread), then you are just as valid as any other GH member.

Cool, thanks! :-)

I've not actually done AVR programming although I suspect I'll need to do some in the world of work at some stage in the (relatively) near future.  I'm a software guy anyhow so I may have opinions I can share if anyone's interested, plus I have a natural urge to obtain hardware I *could* program if I felt like it.

If I could get one built I think it would be cool to look at getting the controller to emulate other USB devices - most obviously an in-keyboard implementation of using the cursor keys to control the mouse pointer.  USB is quite happy to let a single physical device register as if it were several, so there should be no problem with the controller saying it's a keyboard and a mouse - or even multiple keyboards (and mice) if anyone could think of a sane usecase for that?

The only other input device I can currently think of that might be fun to "fake out" would be a USB game pad.  Maybe that would even be useful for something ...  Wikipedia says that alphanumeric display devices are also a valid kind of HID device, so maybe another fun thing would be an option to add a LCD text display to the keyboard?  However, hooking that up gets us into electronics which I'm not qualified to comment on ;-)

EDIT: I know some people have talked about some stuff like this before, e.g. the Geekey project requirements (http://geekey.org/forum/viewthread.php?thread_id=3&pid=31) mention emulated mouse control (which is a separate issue to supporting a built-in trackball or trackpoint).  It's probably mentioned in the associated Geekey / Open Source keyboard controller thread and maybe elsewhere in this one.  I just think it's cool so wanted to mention some possibilities I saw.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Tue, 30 March 2010, 19:34:44
From what I've read in this thread it should be possible to convert most membrane keyboards right?  As long as the membrane can be hooked up in some way ...  This has potential for me as I have piles of rubber dome membrane keyboards I never use.  I'm in the process of getting to grips with understanding how a keyboard works on the electronic level at the moment.  As I understand it, for a simple membrane keyboard, the microcontroller is basically multiplexing all the keys onto fewer inputs by scanning rapidly across them?  And all I need to worry about is hooking up the keyboard controller to the membrane, programming it with the row / column count and telling it where the keys are positioned within that grid?  Sounds "easy" in principle but I know how "simple" things tend to go, especially in the realm of real electronics :-S
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 31 March 2010, 13:37:57
Quote from: MarkWilliamson;168170
If I could get one built I think it would be cool to look at getting the controller to emulate other USB devices - most obviously an in-keyboard implementation of using the cursor keys to control the mouse pointer.


Hm, could be useful in some occasions.

I'd like to get my M4-1 trackpoint supported at some time, but didn't try a lot yet (no time). If mouse emulation over keyboard would be implemented, then some parts of the code could surely be reused for the trackpoint.

Quote from: MarkWilliamson;168173
From what I've read in this thread it should be possible to convert most membrane keyboards right? As long as the membrane can be hooked up in some way ...


Yes.

Many keyboards are IMHO not worth the trouble, though, unless you are modding them for educational purposes. ;)

Quote from: MarkWilliamson;168173
This has potential for me as I have piles of rubber dome membrane keyboards I never use.  I'm in the process of getting to grips with understanding how a keyboard works on the electronic level at the moment.  As I understand it, for a simple membrane keyboard, the microcontroller is basically multiplexing all the keys onto fewer inputs by scanning rapidly across them?


Yes. Instead of connecting each key switch directly to its own I/O pin on the MCU (so you'd need more than 100 I/O pins for a full-size keyboard), you're arranging them in an nxm matrix (requiring only n+m I/O pins, or fewer) and scan along one dimension. This saves I/O pins, but can introduce ghosting (http://www.dribin.org/dave/keyboard/one_html/) unless avoided in hardware (by adding diodes to the switches).

Quote from: MarkWilliamson;168173
And all I need to worry about is hooking up the keyboard controller to the membrane, programming it with the row / column count and telling it where the keys are positioned within that grid?  Sounds "easy" in principle but I know how "simple" things tend to go, especially in the realm of real electronics :-S


Yes, where extension of the firmware is the easy part. Tracing the matrix is not very hard, but can be time-consuming. Big matrices (like the 122-key IBM keyboards) require additional hardware.
Connecting your circuit to the membrane can be troublesome if the connection requires some nasty, hard to obtain connector or if there's no real connector at all (glued to the board).
It may also be hard to fit your circuit board into the keyboard case if it's a slim case.

All in all, it depends on the keyboard whether or not it's hard to mod. IBM keyboards are very mod-friendly as it seems. :)
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Wed, 31 March 2010, 14:40:21
Quote from: Mnemonix;168379
Hm, could be useful in some occasions.

I'd like to get my M4-1 trackpoint supported at some time, but didn't try a lot yet (no time). If mouse emulation over keyboard would be implemented, then some parts of the code could surely be reused for the trackpoint.


Yep, I reckon there'd be plenty of common code there.

I also got to thinking that a cool concept, if mouse support were available, would be to flip thing on their head - an open source mouse controller with optional keyboard emulation ;-)  I imagine that'd be easy for anything mechanical and tricky for anything optical, though.

Quote

Yes.

Many keyboards are IMHO not worth the trouble, though, unless you are modding them for educational purposes. ;)


In my case it might just be "not destroying a good keyboard" purposes, I think ;-)

Quote

Yes. Instead of connecting each key switch directly to its own I/O pin on the MCU (so you'd need more than 100 I/O pins for a full-size keyboard), you're arranging them in an nxm matrix (requiring only n+m I/O pins, or fewer) and scan along one dimension. This saves I/O pins, but can introduce ghosting (http://www.dribin.org/dave/keyboard/one_html/) unless avoided in hardware (by adding diodes to the switches).


Aha!  Thanks, that link has answered many of my remaining hazy points.  I wasn't sure how the diodes / resistors came into it before.  Now I feel much more equipped to understand this stuff...

Quote

Yes, where extension of the firmware is the easy part. Tracing the matrix is not very hard, but can be time-consuming. Big matrices (like the 122-key IBM keyboards) require additional hardware.
Connecting your circuit to the membrane can be troublesome if the connection requires some nasty, hard to obtain connector or if there's no real connector at all (glued to the board).
It may also be hard to fit your circuit board into the keyboard case if it's a slim case.

All in all, it depends on the keyboard whether or not it's hard to mod. IBM keyboards are very mod-friendly as it seems. :)


Does the current code support all of a full-size kb - numpad etc?  I'm not looking to look up crazy / cool IBM terminal keyboards just yet ;-)
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Wed, 31 March 2010, 15:58:49
..
A quote: "I'm not looking to look up crazy / cool IBM terminal keyboards just yet ;-) "

Because these terminal keyboards are crazy is what makes them cool...and interesting...

........

and as to getting your trackpoint working...if my understanding of the trackpoint is correct...it uses a controller separate from the keyboard...and so it may not be feasible to incorporate it into the ATmega device...and likely unnecessary...but I may be wrong here.


............
Spec_57
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 31 March 2010, 17:53:20
Quote from: MarkWilliamson;168396
I also got to thinking that a cool concept, if mouse support were available, would be to flip thing on their head - an open source mouse controller with optional keyboard emulation ;-)  I imagine that'd be easy for anything mechanical and tricky for anything optical, though.


Um, yes, that's a different point of view then. :)

Quote from: MarkWilliamson;168396
Does the current code support all of a full-size kb - numpad etc?  I'm not looking to look up crazy / cool IBM terminal keyboards just yet ;-)


Sure, it works with a full-size Model M already. In theory you could even build your own 200-key (or so) keyboard that has one key for each of the USB key codes, but I'm quite sure that no one would ever want such a beast.

Quote from: Specter_57;168429
and as to getting your trackpoint working...if my understanding of the trackpoint is correct...it uses a controller separate from the keyboard...and so it may not be feasible to incorporate it into the ATmega device...and likely unnecessary...but I may be wrong here.


The M4-1 trackpoint is just a stick with four strain gauges attached. There are four lines going to the strain gauges, and two coming back from them. The challenge now is to measure the resistances of the strain gauges accurately, which are changing slightly depending on the direction the stick is bent to. It should be possible to extend the firmware so to measure the strain gauges' resistances from time to time and derive a mouse movement from them.

Quite some time ago, I tried using the ATmega's analog inputs with their internal amplifiers for measuring the resistances, but found out, after lots of trying, that the internal  amps are broken on the DIP versions of the chip... ;( The data sheet indirectly mentions this, too. After disabling the amps, I could take some reasonable measurements, but signal amplification is absolutely necessary for a useful resolution. I'll look into this again when I have more spare time and will play around with some external opamps.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Wed, 31 March 2010, 18:08:17
Actually, following up my own comment about optical mice being difficult, various of the sites linked from here: http://opensourcemouse.org/wiki/Mouse_Hacks (for instance http://areciv.com/index.php?aid=18 or http://www.bidouille.org/hack/mousecam/index.en.php ) imply that modern optical mice tend to include a combined CCD and image processing chip that just outputs movement data (and optionally may provide dumps of the images seen by the camera).  So assuming one of these is used, getting an optical mouse working sounds easy too.

There's code for the Arduino for interfacing to at least some of these chips: http://www.martijnthe.nl/2009/07/interfacing-an-optical-mouse-sensor-to-your-arduino/

I realise mice might be a bit off topic here but thought it worth noting!  The http://opensourcemouse.org/ project is clearly of some relevance to things like the Geekey project, in principle.  In practice, though, I don't know how far that project has got.
Title: UK supplier for edge connectors
Post by: MarkWilliamson on Sat, 03 April 2010, 13:03:42
Leotronics looks promising but I don't know what quantities they sell in, I'll send an e-mail: http://www.leotronics.co.uk/template2.asp?id=19

These in particular look about right:
http://www.leotronics.co.uk/196_2604_SERIES..asp?id=19
Title: Making a cheap Model M USB controller
Post by: InSanCen on Sat, 03 April 2010, 14:53:44
Quote from: MarkWilliamson;169257
Leotronics looks promising but I don't know what quantities they sell in, I'll send an e-mail: http://www.leotronics.co.uk/template2.asp?id=19

These in particular look about right:
http://www.leotronics.co.uk/196_2604_SERIES..asp?id=19


I will be finding out on Tuesday.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Tue, 06 April 2010, 09:56:24
Quote from: InSanCen;169287
I will be finding out on Tuesday.


I got a nice response - but not what I wanted - from them:

"Many thanks for your enquiry.

I am sorry to say that our minimum order quantities on FFC connectors would
be in the region of 500 pcs.

Have you tried Farnell or CP electronics.."

So not particularly helpful - I think 500 is probably more than I need at this stage ;-)  Don't really want to destroy my old controller but maybe I'd have to; at least this implies that reasonably small production runs would be feasible in the future although it's possibly still more than your friend in manufacturing would want.

I think I'd looked up Farnell and not managed to find the part but I had not tried CP electronics so maybe I'll have more luck there ...
Title: Of possible interest...ATMega Product Guide
Post by: Specter_57 on Tue, 06 April 2010, 19:24:58
..

As we all know, this project uses an ATmega32 microcontroller, although it is possible to use others....

And so, in case you are considering using another related controller for reasons of cost, number of I/O pins, physical package, etc...this guide may be of interest to the readers here....

From the Atmel page, the "AVR and AVR32 - Quick Reference Guide"
  Introduction of the product range of AVR and AVR32 microcontrollers and application processors

A PDF file, 10MB downloaded

here:
           http://www.atmel.com/dyn/resources/prod_documents/doc4064.pdf

.

...and various adapters for non-parallel devices...

http://www.futurlec.com/SMD_Adapters.shtml


...and  I recently found a few pics of an Avant Steller over on ArsTechnica...and there is a pic of the contoller...it uses an Atmel AT89c52...interesting....


................
Spec_57
Title: Making a cheap Model M USB controller
Post by: kishy on Wed, 07 April 2010, 21:17:46
I've now dumped considerable time and money into this and nothing is working.

Changes since last time:

-Linux (Ubuntu 8.10, running everything with sudo of course. version is a necessity, it would literally take all day to download a current version, had to work with what i have available)
-Whatever version of avrdude was downloaded by apt-get install avrdude
-New programmer
-New AVRs
-Just the basics - connection from programmer, to adapter (pinout verified again), to pins soldered to an IC socket with the AVR in it. correct pins verified.
-Programmed fuses like instructed. Appeared to work, but went extremely fast. No errors given.

Everything beyond that is crap and won't work. Knowing that the fuse setting creates the requirement for an external XTAL, I attached one as needed to the IC socket. No change.

If my new AVR (have two new ones, only touched one) is bricked somehow, I'm going to be extremely annoyed...

Sorry for the tone, I'm just frustrated (hopefully understandably so).
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Thu, 08 April 2010, 05:55:39
Quote from: kishy;170508
I've now dumped considerable time and money into this and nothing is working.

Changes since last time:

...
-Programmed fuses like instructed. Appeared to work, but went extremely fast. No errors given.


OK, could you try flashing the firmware or boot loader image to a fresh AVR, i.e., without programming the fuses? In factory settings you should not need a crystal for programming, just the six wires on the AVR. Also try option -B 4 or -B 8 if it doesn't work without.

If this is working, but stops working after programming the fuses, I'd suspect a bad/wrong crystal and/or capacitors. You could try hooking up an oscilloscope to see if there's a clean clock signal; that is, if you have access to an oscilloscope.

Quote from: kishy;170508
If my new AVR (have two new ones, only touched one) is bricked somehow, I'm going to be extremely annoyed...

Sorry for the tone, I'm just frustrated (hopefully understandably so).


I understand your frustration, but stopping at this point won't help you, I'm afraid. :/
It's usually possible to de-brick AVRs with a programmer, so don't worry too much.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Thu, 08 April 2010, 06:18:52
..

Your tone is certainly understandable.  The frustration must be maddening...

I know if that was happening to me...I'd be jumping around and spinning up like this guy over it....and probably would look a lot like him too by now...

(http://geekhack.org/attachment.php?attachmentid=8986&stc=1&d=1270725491)

.
.
.
...............
Spec_57
.
.
Title: Making a cheap Model M USB controller
Post by: kishy on Thu, 08 April 2010, 21:23:05
Thank you mnemonix for putting my head back on straight.

[strike]Successful flashes using the new untouched AVR, without touching fuses. Are we suspecting bad XTALs then?[/strike] Maybe not, will update this when I'm sure.

k, got what appears to be a successful flash of boot.hex.

sudo avrdude -B 8 -p m32 -P usb -c usbasp -U flash:w:boot.hex

initialized, ready to accept

progress bar for reading, 100% in 0.01s
signature 0x1e9502
erases, reads file, detects as intel hex
writes flash (32632 bytes), 100% in 29.75s

verifies entirely properly.

now, when i switch the filename out for main.hex, I get something much less fun.

it detects the file as intel hex, but of 4198 bytes...I thought this file was supposed to contain substantially more stuff?

it writes it "100% in 3.00s", attempts to verify, finds an error. first mismatch at 0x0000. "0x0c != 0x00"

then i get warnings about the fuse values changing, apparently.

lfuse supposedly went from e1 to 0
hfuse supposedly went from 99 to 0

I answer no to these because nothing but grief came from answering yes to equivalent questions with the earlier AVRs...it just hangs if you say yes, and I'm playing it safe with this one.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 09 April 2010, 06:03:29
Quote from: kishy;170774
progress bar for reading, 100% in 0.01s
signature 0x1e9502
erases, reads file, detects as intel hex
writes flash (32632 bytes), 100% in 29.75s

verifies entirely properly.


Good news so far. :) ~30 seconds is really fast, though, compared with how long it takes with my programmer.

Quote from: kishy;170774
now, when i switch the filename out for main.hex, I get something much less fun.

it detects the file as intel hex, but of 4198 bytes...I thought this file was supposed to contain substantially more stuff?


No, that's OK. The boot loader is rather small, but it's located at the end of the flash memory. Programming is performed serially, starting at the beginning of the memory. So, when writing the boot loader, the whole flash memory must be "skipped" until the boot loader section is reached, and AVRdude reports nearly 32 kB for the size.

The main firmware, however, is located at the beginning of the flash memory, so it will be written more quickly, and AVRdude displays its real size.

Quote from: kishy;170774

it writes it "100% in 3.00s", attempts to verify, finds an error. first mismatch at 0x0000. "0x0c != 0x00"

then i get warnings about the fuse values changing, apparently.

lfuse supposedly went from e1 to 0
hfuse supposedly went from 99 to 0

I answer no to these because nothing but grief came from answering yes to equivalent questions with the earlier AVRs...it just hangs if you say yes, and I'm playing it safe with this one.


Alright, that's odd. Here (http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01499.html) is a list of other values you could try with option -B. For instance, you could try -B 1600 for some really slow timings. Try increasing the speed successively if writing main.hex with -B 1600 works.

And the fuses should never change just by writing to the flash memory... Strange.
Title: Making a cheap Model M USB controller
Post by: kishy on Sat, 10 April 2010, 14:41:21
Same results using value of 1600 for -B, but it did take longer (though it still claims 3.00s).

Same stuff about changing back the fuses. Still saying no to these.

Retrying with boot.hex, same results, but it took longer. Claimed 29.79s...

Why is it telling me it's taking the same time when it clearly isn't?

Without meaning to suggest any incompetence on your part mnemonix can you please 100% verify that the fuse values you provided are correct? I get that initialization failed, rc=-1 thing with the chips that I attempted to set the fuses on. I'm thinking either bad fuse settings or bad crystals or good crystals that don't correspond to the needs the fuse settings create.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Sun, 11 April 2010, 13:53:40
Quote from: kishy;171233
Same results using value of 1600 for -B, but it did take longer (though it still claims 3.00s).

Same stuff about changing back the fuses. Still saying no to these.

Retrying with boot.hex, same results, but it took longer. Claimed 29.79s...

Why is it telling me it's taking the same time when it clearly isn't?

Without meaning to suggest any incompetence on your part mnemonix can you please 100% verify that the fuse values you provided are correct? I get that initialization failed, rc=-1 thing with the chips that I attempted to set the fuses on. I'm thinking either bad fuse settings or bad crystals or good crystals that don't correspond to the needs the fuse settings create.


Checked it again...

This is the command that I am using to program the fuses on my test ATmega32 (followed by the output):
Code: [Select]
$ avrdude -p atmega32 -c usbasp -U lfuse:w:0x1f:m -U hfuse:w:0xd2:m
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9502
avrdude: reading input file &quot;0x1f&quot;
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0x1f:
avrdude: load data lfuse data from input file 0x1f:
avrdude: input file 0x1f contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file &quot;0xd2&quot;
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd2:
avrdude: load data hfuse data from input file 0xd2:
avrdude: input file 0xd2 contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


I can read back their values using this command:
Code: [Select]
$ avrdude -p atmega32 -c usbasp -U lfuse:r:-:h -U hfuse:r:-:h -U lock:r:-:h 2>/dev/null

Fuses after flashing boot.hex and main.hex:
Code: [Select]
lfuse 0x1f
hfuse 0xd2
lock  0x3f


Fuses after locking:
Code: [Select]
lfuse 0x1f
hfuse 0xd2
lock  0x2f


This is what I see when writing boot.hex:
Code: [Select]

$ avrdude -p atmega32 -c usbasp -U flash:w:boot.hex
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "boot.hex"
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: writing flash (32632 bytes):

Writing | ################################################## | 100% 249.62s

avrdude: 32632 bytes of flash written
avrdude: verifying flash memory against boot.hex:
avrdude: load data flash data from input file boot.hex:
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: input file boot.hex contains 32632 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 194.91s

avrdude: verifying ...
avrdude: 32632 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


And for main.hex:
Code: [Select]
$ avrdude -p atmega32 -c usbasp -U flash:w:main.hex
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (5196 bytes):

Writing | ################################################## | 100% 39.72s

avrdude: 5196 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 5196 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 31.07s

avrdude: verifying ...
avrdude: 5196 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


So everything is going rather slow. Playing around with option -B has no effect whatsoever, except for a message that the SCK frequency is being set (followed by a warning that this didn't succeed). It always takes the same time to write the images, no matter what values for -B I am setting. Time is displayed correctly, too.

Now, here is what I get when I'm trying to write to that ATmega32 with the crystal removed from the circuit:
Code: [Select]

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.


Fails because the AVR has been configured to use an external crystal. You know this message already, so a bad crystal or wrong/bad capacitors are possible.
Are you sure that you've received 22 pF capacitors (not 22 nF)?

Now trying with a fresh ATmega16, never touched before, and without a crystal. The circuit consists of the AVR, the programmer, and the six wires going from the AVR into my programmer, nothing else. Reading the fuses works:
Code: [Select]
$ avrdude -p atmega16 -c usbasp -U lfuse:r:-:h -U hfuse:r:-:h -U lock:r:-:h
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9403
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file ""
0xe1
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file ""
0x99
avrdude: reading lock memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file ""
0x3f

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


So, factory settings of an ATmega16 are
Code: [Select]
lfuse 0xe1
hfuse 0x99
lock  0x3f


Writing the boot loader and firmware images succeeds, too:
Code: [Select]
$ avrdude -p atmega16 -c usbasp -U flash:w:boot.hex
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9403
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "boot.hex"
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: writing flash (16248 bytes):

Writing | ################################################## | 100% 122.15s

avrdude: 16248 bytes of flash written
avrdude: verifying flash memory against boot.hex:
avrdude: load data flash data from input file boot.hex:
avrdude: input file boot.hex auto detected as Intel Hex
avrdude: input file boot.hex contains 16248 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 97.05s

avrdude: verifying ...
avrdude: 16248 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


Code: [Select]
$ avrdude -p atmega16 -c usbasp -U flash:w:main.hex
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9403
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (5196 bytes):

Writing | ################################################## | 100% 39.18s

avrdude: 5196 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 5196 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 31.09s

avrdude: verifying ...
avrdude: 5196 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.



I really can't see why your programmer fails to write the main.hex image to the AVR that still has its fuses in default settings. :(

I'd now try writing main.hex using different values for -B so to set the SCK frequency to the various values mentioned here (http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01499.html). Let's hope there is one that works for you.
Title: Making a cheap Model M USB controller
Post by: Hydron on Fri, 21 May 2010, 08:53:36
Thought I'd add to this discussion as my introductory post.

I found geekhack while searching for ideas for modding a Model M to bluetooth, and decided to have a go at making a USB version after seeing that someone had done all the hard work already (software isn't my specialty, though I get by).

Without further ado, here is my completed effort:
(http://geekhack.org/attachment.php?attachmentid=10191&stc=1&d=1274446952)

And if a crystal and some headers is a bit boring, here is a shot of the brains:
(http://geekhack.org/attachment.php?attachmentid=10192&stc=1&d=1274446952)

As you can see I've avoided through hole parts as much as possible - I hate perfboard, drilling holes and mucking about bending/cutting component leads, so SMD was the way to go.  The micro is actually a atmega162 as it was easier to get, and the A and C ports are swapped from the defaults to avoid crossing wires - this required some software changes which I'll get to later.

The PCB is my first ever effort at home etching - I'm pretty happy at how it turned out, even given the slight layer missalignment, fingerprints and soldering job done at 2am.  I used the toner transfer from photo paper method and ammonium persulphate etchant.  Probably the hardest thing was drilling holes well with a crappy drill - another reason for SMD where possible.

As for software, the first change was to the configure script to add the definition and correct fuses for the atmega162. The next thing was a changed bit name in the watchdog timer register - the name changes between the 16 and the 162 yet the function is essentially identical. The final and most irritating change was to the bootloadHID code in order to make it fit in the 162. For some reason the boot code compiles slightly larger on the 162 than the 16, just enough to tip it over the 2kB barrier and stop it from working. Thankfully there is an option in the bootloadHID code to shave a few bytes from the code by disabling use of the -r (auto reset) option on the HID programmer, and this took it under 2kB, albeit after a bit of cursing before i found the option.
When i get a chance I'll put these changes together and submit them back to the author so he/she can impliment them as they want.

As for the initial programmer, I'm using a very cheap and nasty cable which connects the programming pins to the parallel port via some protection resistors (these would have been on the board if i'd remembered). I've used this method a bit in the past and it seems to work fine, albeit slowly. Info here: http://www.bsdhome.com/avrdude/ (http://www.bsdhome.com/avrdude/). Programmer type for avrdude is "bsd".

I'm happy to share the design/code changes if anyone is interested in building this - the board is done in altium (protel) as this is what i use at work, but the artwork as a PDF is usable by anyone if they want to do the toner transfer thing.

A bit of background, I'm an electrical engineer in New Zealand and do a bit of PCB design in my day job, though normally of much more complicated boards and with the benefit of professional manufacture.
I've managed to acquire a few IBM boards cheaply via auction, namely:
3 good 1391401s
1 1391401 with missing keys
1 UK model M with missing keys (the same keys as the other one :( )
1 new-in-box fixed cord lexmark model m (this was my first and the only one i've payed more than $2-10 for)
1 model M2 (working, this is apparently rare)
and finally a model F i rescued from getting thrown out.

The 1391401s (one with keys from the lexmark) are the only ones that get used, UK layout is weird and the F drops too many keys. Alas, it seems impossible to find any m13 black boards down in this part of the world, which is what i really want.

And finally to whet some appetites, I'm working on a proper bluetooth model M, and am fairly confident I can make it work. This isnt a hack with usb -> bluetooth converters or anything (though hackish in other ways), and should be very low power, but it may take me a while as I'm quite busy at the moment.

Edit: just noticed in the photo that I missed a (non-vital) connection, can anyone see it?
Title: Making a cheap Model M USB controller
Post by: itlnstln on Fri, 21 May 2010, 08:59:57
Strong work.  Very well done.

BTW, welcome to Geekhack!
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Fri, 21 May 2010, 13:46:47
Quote from: Hydron;185290
Thought I'd add to this discussion as my introductory post.


Wow, that's cool! Beautiful board.

Quote from: Hydron;185290
The final and most irritating change was to the bootloadHID code in order to make it fit in the 162. For some reason the boot code compiles slightly larger on the 162 than the 16, just enough to tip it over the 2kB barrier and stop it from working.


Ah, those are the sort of problems that can ruin your whole day. I could add an option to the configure script that enables your workaround.

Quote from: Hydron;185290
When i get a chance I'll put these changes together and submit them back to the author so he/she can impliment them as they want.


I'll happily integrate your changes. :)

If you like, I can also put the PCB design and changed schematic into the source tree so that they are in some "standard place" where people can find them. PDFs would be great. Or just post them here.

Quote from: Hydron;185290
And finally to whet some appetites, I'm working on a proper bluetooth model M, and am fairly confident I can make it work. This isnt a hack with usb -> bluetooth converters or anything (though hackish in other ways), and should be very low power, but it may take me a while as I'm quite busy at the moment.


A Bluetooth Model M would be very cool indeed. I'm looking forward to see that one! Are you going to write the firmware from scratch or will you try to extend the Keyboard Upgrade sources?

And could you tell us which Bluetooth chip will you use? Just curious since I've been working on a Bluetooth project last month...
Title: Making a cheap Model M USB controller
Post by: Hydron on Fri, 21 May 2010, 19:15:31
Quote from: ripster;185310
I'm too much of a wimp to attempt SMT anything!


I actually find coarse pitch SMD (which this is, it gets MUCH finer) is easier and quicker to solder than through hole. The resistors/capacitors are really easy and you dont need to muck about with bending and cutting legs or anything. The micro is less so, but still took no longer than the DIP would have. One side of it I managed to do first time with no solder bridges between pins, the other sides i got bridges so I flooded them with solder and then sucked it off with solder wick (this is sort of the cheating way to do it - its REALLY easy for a chip like this). With a stereo microscope and a finer iron (which i have at work), i wouldn't have even had to use the wick.

Quote
Wow, that's cool! Beautiful board.


Not very beautiful compared to a professional board, but very beautiful compared to verroboard! (no offence to thread starter)

Quote
If you like, I can also put the PCB design and changed schematic into the source tree so that they are in some "standard place" where people can find them. PDFs would be great. Or just post them here.


I'll tidy them up a bit and do this. May not happen immediately. Might be able to find the digikey part numbers too, for those in the USA.

Quote
A Bluetooth Model M would be very cool indeed. I'm looking forward to see that one! Are you going to write the firmware from scratch or will you try to extend the Keyboard Upgrade sources?

And could you tell us which Bluetooth chip will you use? Just curious since I've been working on a Bluetooth project last month...


I managed to get hold of a keyboard with a BP20422 module locally, also available here: http://russnelson.com/bluetooth-keyboard-controller.html (http://russnelson.com/bluetooth-keyboard-controller.html)
Some info here: http://bluepacket.net/BluePacket/admin/file/BP20422-PB-003.pdf (http://bluepacket.net/BluePacket/admin/file/BP20422-PB-003.pdf) and here: http://www.bluepacket.net/doc/BP20422.PDF (http://www.bluepacket.net/doc/BP20422.PDF)
Problem with this module is the scan matrix is fixed - unless you made your own membrane to put into a model M you're out of luck. Mine has a different matrix than the original blue packet module, so it CAN be changed, but probably only by the manufacturer or with NDAs for the source or something.

My plan is to use a micro to scan the model M matrix and emulate the expected matrix to the bluetooth module when it scans itself. Pretty sure I'll be able to get it going, though it may be tricky with timing and stuff. I've picked a micro with 54 I/O pins and some very low power sleep modes, so hopefully that will work and will give reasonable battery life. Worst case I could grab a FPGA from work and brute force it with programmable logic, but that involves a bunch of work getting a board (the FPGA is 208 pins, you can hand solder one but a decent board is essential). So it is a hackish way of doing it, but short of trying to reverse engineer the EEPROM code on the BP20422 its the only way I can see working. Probably wont use much or any of the existing Keyboard Upgrade code, except maybe the anti ghosting stuff.

If I get one going it probably wont be that cheap, or buildable without an etched PCB. I would however consider building a couple and sending them out, maybe in exchange for black keycaps or something :P. Shipping to/from New Zealand can be damn expensive though :(.
Title: Making a cheap Model M USB controller
Post by: dfj on Sat, 05 June 2010, 19:16:49
So, I'm new here, so here is a 'practice' post about something simple you folks have mentioned in this thread a few times. I've had good success with ISA slots, so I'm going to try to describe how I do so in the same way I'm going to describe other, hopefully more useful, topics. :)

An ISA connector works well, though a spacer is needed. For home-brew solutions to this problem they are readily available, and cutting a spacer out of a piece of scrap board is no big deal. Now, fer bulk production, that spacer is a pain - it wants to be a hair thinner than 1/16", (the mylar membrane is doubled at the connector with carbon over the trace as well.)
  I just hacked (hacksaw) an edge connector off an old ISA board, then cleaned it up with a file, testing it repeatedly while thinning it (also with a file) until it went, but still giving a decent firm hold.
  While still at the debugging prototyping stage, the ISA card can be stuffed into some wire-wrap pin strip, then stuck into a breadboard, or an old IDE cable etc...
  Ugh, this is me first post - but pics are warranted. I din' get shots of the original filing down, but it should be clear what I did. I love filing, and will idly do it the way other folks might whittle or watch tv. I think this is straightforward, though... the tolerances are loose, and the bits flexible enough to handle moderate clumsiness:
(http://geekhack.org/attachment.php?attachmentid=10663&d=1275780333)
(http://geekhack.org/attachment.php?attachmentid=10664&d=1275780348)
(http://geekhack.org/attachment.php?attachmentid=10665&d=1275780367)
So - that little whitish toothed spacer is also quite helpful - I found it stuffed into an old AGP slot, but you can make one out of anything. The key thing is that it spaces the two membrane connectors apart the correct amount so that they both will line up with the contacts of the ISA slot. Yes, I used a file to make it. The hook is just so you can get it out again, should you want to.
Now, you can see that I scraped the thickness of the scrap board down a bit. It only required about 0.1 mm, i.e. 1/10th of a mm. But - it really needs it: you don't want yer membrane folding and buckling as you try to force it in.
(http://geekhack.org/attachment.php?attachmentid=10666&d=1275780384)
and here we have two easy ways to connect the back end of an ISA slot to yer prototyping environment, we have it easy here since we are only worried about one side of the pins so this will plug into a solderless breadboard at the other end without thought.
  One side, half of an old chip-holder, for those who prefer their magic smoke kept inside chips. I soldered some normal straight pin-headers (e.g. fer jumpers, etc...) onto it, so I could use whatever ribbon cable I had handy.
  In the other, the wire-wrap headers. both work well, though, with lots of headers you can stuff the ISA slot right into a breadboard and it will hold well. normally, that would suck, but again, we are only using one side at a time so we don't mind shorting across the ISA pins what are directly opposite.

Cool - images din' take too much damage from the 'resizing' process.

Oh, and I made it as stiff as I could get away with, while still being able to get it in. I put both pieces of membrane in using the white spacer to position them, then work the piece of card in which locks them in place. locks is about right - my cat knocked my setup off my desk, and my actual breadboard and a nasty 1394100 keyboard assembly (metal, membranes, keysockets, keys) all ended up dangling on either side of the back support of my chair - hanging by the bloody IDE connectors I was using.
 Breadboard: I screw solderless breadboards, etc... onto it. I can't help it, it's the way I worked when I was a kid. Breadboards are made of wood, keyboards are made of IBM. :)

  Anyway, to introduce myself, I'm working on a gaming mod fer 101 and 122 key IBM Model M keyboards.
  The first step is documenting modifying the things to be USB keyboards without dropping simultaneous keypresses. Towards this end I've been working on a ps2 signal->USB converter that can handle either 101 or 122 key M's without promulgating that BS 'max 6 keys plus modifiers' tripe. That only applies to keyboards in boot mode - neither linux nor macs, nor 'dose forces that fer HID devices, the HID USB spec even describes how keyboards are supposed to implement their descriptors once a USB aware OS is booted. /endgripe

  The next part, however is dealing with the ghosting inherent to matrix keyboards... much pain here resides. Thus I am currently hacking around with replacing bottom matrices, trying to read resistances to better than 1% while retaining the original matrix, etc...

  'Yeah, I'll release my code under an open license, but... it's not cleaned up yet' (how many times have we heard that one before?)
 
  So, I've used a number of the ideas from this site, so I think this is where I'll hang out and feed back my smaller tricks/ideas back into the community.
  Wish me luck. :)
dfj
Title: Making a cheap Model M USB controller
Post by: timofonic on Sat, 05 June 2010, 20:49:01
Hello dfj...

Imentioned you on another forum thread, you can look it here (http://geekhack.org/showpost.php?p=190038&postcount=28). That way more people can look at your amazing effort and then more possibilities to help you too ;)
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Mon, 07 June 2010, 15:55:49
Quote from: dfj;190019
So, I'm new here, so here is a 'practice' post about something simple you folks have mentioned in this thread a few times. I've had good success with ISA slots, so I'm going to try to describe how I do so in the same way I'm going to describe other, hopefully more useful, topics. :)


Ah, very nice to see this being done. :) Should be of help for those out of luck getting the correct connectors.

Quote from: dfj;190019
Anyway, to introduce myself, I'm working on a gaming mod fer 101 and 122 key IBM Model M keyboards.
  The first step is documenting modifying the things to be USB keyboards without dropping simultaneous keypresses. Towards this end I've been working on a ps2 signal->USB converter that can handle either 101 or 122 key M's without promulgating that BS 'max 6 keys plus modifiers' tripe. That only applies to keyboards in boot mode - neither linux nor macs, nor 'dose forces that fer HID devices, the HID USB spec even describes how keyboards are supposed to implement their descriptors once a USB aware OS is booted. /endgripe


True, no one forces you to use the HID specs, only the regular PC BIOSes do.

You'd need to design a new protocol to support more keys being sent at once and write OS drivers for this protocol, but you'd still need to implement the HID specs to get the keyboard to work when the driver is not available (in BIOS, during OS installation, rescue CDs). Since the 6-key limit is not a true limitation for most people, the simple protocol is sufficient in most cases, plus it's implemented already everywhere, so that's most probably the reason why none of the keyboard manufacturers are trying to make anything better.

Maybe one day when PS/2 is really, really finally dead, and if there's demand for NKRO ("demand" as in "worth serious amounts of money"), someone might devise a new protocol and declare it the new "standard" HID protocol for keyboards. Today it's cheaper to just build and sell PS/2 keyboards with NKRO and not putting effort into developing something new for USB.

You know all of this already, I guess. :) Just my two cents here.

Quote from: dfj;190019
The next part, however is dealing with the ghosting inherent to matrix keyboards... much pain here resides. Thus I am currently hacking around with replacing bottom matrices, trying to read resistances to better than 1% while retaining the original matrix, etc...


While I doubt that NKRO with N > 1 plus modifiers is useful for anything (hey, I'm not a gamer! :nerd:), I'm still interested in your project and the techniques you are going to use. Keep us posted, please! :)
Title: Making a cheap Model M USB controller
Post by: JBert on Mon, 07 June 2010, 17:07:56
Quote from: Mnemonix;190632
A
Quote from: dfj;190019
Anyway, to introduce myself, I'm working on a gaming mod fer 101 and 122 key IBM Model M keyboards.
  The first step is documenting modifying the things to be USB keyboards without dropping simultaneous keypresses. Towards this end I've been working on a ps2 signal->USB converter that can handle either 101 or 122 key M's without promulgating that BS 'max 6 keys plus modifiers' tripe. That only applies to keyboards in boot mode - neither linux nor macs, nor 'dose forces that fer HID devices, the HID USB spec even describes how keyboards are supposed to implement their descriptors once a USB aware OS is booted. /endgripe

True, no one forces you to use the HID specs, only the regular PC BIOSes do.

You'd need to design a new protocol to support more keys being sent at once and write OS drivers for this protocol, but you'd still need to implement the HID specs to get the keyboard to work when the driver is not available (in BIOS, during OS installation, rescue CDs). Since the 6-key limit is not a true limitation for most people, the simple protocol is sufficient in most cases, plus it's implemented already everywhere, so that's most probably the reason why none of the keyboard manufacturers are trying to make anything better.

Maybe one day when PS/2 is really, really finally dead, and if there's demand for NKRO ("demand" as in "worth serious amounts of money"), someone might devise a new protocol and declare it the new "standard" HID protocol for keyboards. Today it's cheaper to just build and sell PS/2 keyboards with NKRO and not putting effort into developing something new for USB.

You know all of this already, I guess. :) Just my two cents here.
Ehr, as far as I understood the HID specs correctly the device has a "descriptor" of its data format available so the host knows what it can send and receive. The low-level protocol stays the same, it is then up to the host to make sense of the bytes which are sent over the wire. Hence programming a driver is mostly rewriting scan code to virtual key mapping, the only catch is that you have to do it for most OSs.

If you want to support the BIOS, you can still allow the keyboard to be put in legacy mode, it just makes the firmware more complex.
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Tue, 08 June 2010, 14:29:14
Quote from: JBert;190669
Ehr, as far as I understood the HID specs correctly the device has a "descriptor" of its data format available so the host knows what it can send and receive. The low-level protocol stays the same, it is then up to the host to make sense of the bytes which are sent over the wire. Hence programming a driver is mostly rewriting scan code to virtual key mapping, the only catch is that you have to do it for most OSs.

If you want to support the BIOS, you can still allow the keyboard to be put in legacy mode, it just makes the firmware more complex.


Yes, that's what my many words tried to say. :)
Support for more than six keys at a time is possible, but comes at a cost.
Title: Making a cheap Model M USB controller
Post by: dfj on Wed, 09 June 2010, 01:03:00
Quote from: Mnemonix;190983
Yes, that's what my many words tried to say. :)
Support for more than six keys at a time is possible, but comes at a cost.


Bah, says the bloke what wrote them krazed makefiles. :)
 
  But, the parent is nearly correct - the HID configuration is parsed by the OS, and then a FA-alike is built to eat the responses/generate requests... but the sweet part is that the USB HID spec describes this in detail, and current linux, OS X, and 'dose versions are all happily parsing the things correctly after boot.
  That is to say - no drivers need to be installed unless you want to support writing to the device in fancier ways.
  So, in the morning handshake for keyboards, the boot protocol is requested, which is fixed, (rumour has it) since in the early days mainboard manufacturers raised a stink about having to write parsers. Once an OS is up, the kb is rebooted, and is not forced to the boot proto, so can freely define its own whacky descriptor. Nice thing, these are not alternate responses, rather entire protocols set at startup, so the response descriptor need not contain that 1 byte 'which' field. This is a big deal when you are trying to keep yer responses inside the 8 byte limit per interrupt.
  Not that it matters until folks start using the kbupgrade for nkro hardware, but the 8 byte limit applies to each interrupt - you can spec a response bigger than 8 bytes, but it will need to span two ints, with a delay of at least 1m per int, if I remember. The HID spec is pretty readable, particularly if you skip past the discriptor protocol higher levels to the keyboard samples. They even have a cute mouse+keyboard combined protocol example.
  Oh wait, folks _have_ requested that for kbupgrade, no? They want to poke the mouse cursor about using some cursor-ish thang?

  mumble, grr... stayed up too late again. kraxy forum.
until,
dfj
Title: Making a cheap Model M USB controller
Post by: Mnemonix on Wed, 09 June 2010, 14:13:37
Quote from: dfj;191195
Bah, says the bloke what wrote them krazed makefiles. :)


Makefile.am files, if you please. ;)
The Makefiles are generated. No way I would write those by hand.

Quote from: dfj;191195
Not that it matters until folks start using the kbupgrade for nkro hardware, but the 8 byte limit applies to each interrupt - you can spec a response bigger than 8 bytes, but it will need to span two ints, with a delay of at least 1m per int, if I remember.


Yes, low speed USB hubs are required to support at least (only) 8 bytes per interrupt packet, and Keyboard Upgrade keyboards are only low speed USB devices. You could try sending larger packets, I guess, but it may not work. Sending the keyboard status in multiple packets can be slow and is more complicated for the firmware and the OS driver, but it could be done; not by me, however. ;)

Quote from: dfj;191195
The HID spec is pretty readable, particularly if you skip past the discriptor protocol higher levels to the keyboard samples. They even have a cute mouse+keyboard combined protocol example.
  Oh wait, folks _have_ requested that for kbupgrade, no? They want to poke the mouse cursor about using some cursor-ish thang?


I've also requested that feature. :)
The currently dead trackpoint on my M4-1 needs to get a new life.
Title: Making a cheap Model M USB controller
Post by: dfj on Wed, 09 June 2010, 15:53:57
Dang, I've got no nipples on any of my boards to test with - I'm not a nipple person.

  I've got the multi-packet deal working on a PS2->USB nkro adapter, but I've been driven mad by the two streams of interrupts - need to grok the locking abilities of the AVR and get my queues to stop borking before I release... unless you grok that crap, in which case this might be sweet, as I've got interrupt-spanning responses working for nkro, sturdy ps2 parsing, and a SPI debug stream... You've got a stack of matrices already, an optional host-side client, and on-the fly remapping working... As it happens we focussed on different stuff, so there isn't anywhere near as much duplication as I feared. That is to say, my own mad research was not wasted. :)

 So - to be clear, you have a live repo, actual users, and you don't vanish into the void for months at a time as much as I do. I am totally offering express my stuff in terms of your design and contribute it as patches for you to make the call on.

(in my PS2 handler I deal with lots of the errors, and request resends relatively well. This was needed because I gave the USB interrupt priority, thus it would periodically nuke the PS2 packets).

  For the rest of us without an over-hot board, and don't care about preserving the 2-10 (min 2, max 10) rollover of an M, the conversion to USB with hardware remapping is pretty sweet all by itself. Also, if the board still works, a converter doesn't require much work - in particular, no need to hack a connector to them bloody membranes. :}
  The cost of that conversion (if V-USB's claims to be able to stabilize the internal oscillator of an ATINY is well-founded) might fall down to under $5, or even lower... visions of someone throwing yer stuff onto an 8-pin with a few resistors and diodes, dead-bug style.... Hey, we can all have our fantasies. ;)
 
off to blink some LEDs,
dfj
Title: rough example: tired of alluding to things.
Post by: dfj on Wed, 09 June 2010, 17:19:32
Feel like I'm talking too much, and not 'showing' enough.
 This is the idea of what I did for the large packets - I've gotten these through a few cheaper and more expensive hubs, to a couple of OS Xs, XP and w7... I don't think I've tested much of my recent stuff under linux.  
[ insert excuse here: 'I din' wanna crash me file-server, it still has decent uptime', etc... ]

Not to worry, the C++ in my stuff is 90s-style, I'll convert it to C without effort.

So, courtesy of the v-usb licensed examples what I based these snippits (Thanks Christian!) on:

Code: [Select]

char UsbKeyboardDevice::fct_read_remaining = 0;

uchar usbFunctionRead(uchar *data, uchar len) {
    if(len > UsbKeyboardDevice::fct_read_remaining) {
        len = UsbKeyboardDevice::fct_read_remaining;
    }

    uchar * buffer = UsbKeyboardDevice::reportBuffer;
    buffer += (BUFFER_SIZE - UsbKeyboardDevice::fct_read_remaining);
    for(uchar i=0; i<len; i++) {
        data[i] = buffer[i];
    }
    //currentAddress += len;
    UsbKeyboardDevice::fct_read_remaining -= len;
    return len;
}


Gets yer state across at startup, and then in yer big loop you want to periodically call something like:
Code: [Select]

if (UsbKeyboard.ready()) {
    if (dirty) {
left = UsbKeyboard.sendPartialBuffer();
if (left == 0) {
   dirty = false;
}
    }
    if (usb_queue_count && !dirty) {
        unsigned char key = usb_queue[usb_queue_first];
if(usb_queue_breaks & (1 << usb_queue_first) ) {
   UsbKeyboard.releaseKey(key);
} else {
            UsbKeyboard.pressKey(key);
}
        // race laden queue :(
usb_queue_first++;
usb_queue_first &= USB_QUEUE_MASK;
usb_queue_count--;
dirty = true;
    }
}


where sendPartialBuffer might look like:
Code: [Select]

int sendPartialBuffer() {
    if(spb_remainder == 0) {
spb_remainder = BUFFER_SIZE;
spb_data = reportBuffer;
    }

    if (usbInterruptIsReady()) {
if(spb_remainder > 8) {
   usbSetInterrupt(spb_data, 8);
   spb_data += 8;
   spb_remainder -= 8;
} else {
   usbSetInterrupt(spb_data, spb_remainder);
   spb_data = reportBuffer;
   spb_remainder = 0;
        }
    }
    return spb_remainder;
}



V-USB does the usbSetInterrupt properly, so it doesn't race - at least. ;)


So - I'll need to grok what you are doing with the HID client stuff, so as to figure out which bits will mix and which will fight. My stuff is pure HID, no drivers needed - just stuff it in, wait fer the beeps/blinkenlights and type away.
Title: Mebbe breadboarding it first wasn't all that reasonable...
Post by: dfj on Fri, 11 June 2010, 22:19:07
... but, I tested the 1391401 code, then feeling all cocky I threw on the 1390702 code (sans led)... which I am typing on currently. :)
  So - kudos to ze Mnemonix, the 1390702 stuff works, yup.

Yeah, so - I can't say I'm a fan of automake, but once I figured out that my deltas to the config went into config.status, it wasn't so bad...

Ok - I'm not actually using a 1390702, I'm actually using a 1394100, so it has some funky labels on the keycaps - I'm going to have to take a closer look at how you mapped this stuff out by default...

Anyway, Mnem: Thanks fer all the hard work!

oh - and here's the mess that is serving these poor USB packets:


(http://geekhack.org/attachment.php?attachmentid=10973&d=1276311670)
The glowing green LED was the caps while the chip thought it was in a 1391401...
(http://geekhack.org/attachment.php?attachmentid=10974&d=1276311688)
and this is the horror story that I test on.
  I have a strange aversion to zeners, so I use a couple of diodes to step the signal voltage down and a schottky to bring it back. I'm a coder, not an EE, nuff with the mockings. :)

kk, someone wake up kish, I've got a beautiful 1386887 which is crying out fer a perfboard hackjobby...

until,
dfj
Title: Making a cheap Model M USB controller
Post by: kishy on Fri, 11 June 2010, 22:29:52
Kishy's awake. Click the link at the top right of the screen and come find me.
Title: Making a cheap Model M USB controller
Post by: Specter_57 on Tue, 29 June 2010, 06:41:38
.

Here is an interesting read I stumbled across, a design reference manual from Freescale Semiconductor,...."USB and PS/2 Multimedia Keyboard Interface" with a reference design schematic included, and firmware discussion.

The controller design in this thread is electrically and physically simpler than the one presented in the reference document due to the use of the ATmega device, and is to be preferred.....but the document is worth a read nonetheless, in my opinion.


Take a look here at this PDF:  

http://www.freescale.com/files/microcontrollers/doc/ref_manual/DRM014.pdf

Enjoy

............
Spec_57
Title: Making a cheap Model M USB controller
Post by: sethstorm on Wed, 30 June 2010, 11:47:22
Quote from: Specter_57;197499
.

Here is an interesting read I stumbled across, a design reference manual from Freescale Semiconductor,...."USB and PS/2 Multimedia Keyboard Interface" with a reference design schematic included, and firmware discussion.

The controller design in this thread is electrically and physically simpler than the one presented in the reference document due to the use of the ATmega device, and is to be preferred.....but the document is worth a read nonetheless, in my opinion.


Take a look here at this PDF:  

http://www.freescale.com/files/microcontrollers/doc/ref_manual/DRM014.pdf

Enjoy

............
Spec_57

Since I have a 8x13 matrix on my Wheelwriter, that only makes things more interesting.  That, and it appears to have room for terminal boards.
Title: Making a cheap Model M USB controller
Post by: MarkWilliamson on Fri, 05 November 2010, 18:28:02
So, whilst noodling around reading about Model Fs, I think I found a thread where Mnemonix acquired one - I wondered if you'd had any success in replacing the controller in that?

I've got a Model M waiting for me to build a new controller but it'd be awesome to be able to USB-ify the F and add some programmability to make up for the lack of keys (e.g. layer switching like the HHKB, say).
Title: Making a cheap Model M USB controller
Post by: kishy on Mon, 09 May 2011, 17:11:48
Well...it only took...forever...

[ATTACH=CONFIG]18031[/ATTACH]

I'm having severe matrix incompatibility problems, but these I'm sure can be fixed easily (appears the old 122s do have a different matrix from the new ones)

The problem seems to have been supply power...hooked the suckers up to my PSU 5V output and it's good to go...thanks to the lovely folks in IRC who put up with frustrated me over the last couple days as I revisited this project.

Also, I dumped that irritating avrdude in favour of this (http://extremeelectronics.co.in/avr-tutorials/gui-software-for-usbasp-based-usb-avr-programmers/)...highly recommended (if you have the usbasp programmer, as I do)