Path: Home => AVR-Overview => Keyboard => rmatrix

Software for a 1 to 16 key wide keypad on an AVR

This page shows the software for connecting keypads of between 1 and 16 keys to an AVR.
  1. the software,
  2. how it works,
  3. what output it produces,
  4. which experiences have been made,
  5. feedback.

1 The software

Starting RMatrix The software is written in Delphi-Pascal. The zipped executable for Win32 is here.

The following sections of the window are visible on the left side: On the right side of the window

. Starting RMatrix Wine The Win32 software is also executable under Wine in Linux, and looks very much alike. The only difference is the font of the result window.

To the top of the page

2 How it works

2.1 Selecting the keypad size

With the column and row dropdown selectors the size of the keypad can be selected. Please note that selection of the size restarts all resistor values to their default value set. This can be used to restart the approximation from default values if an approximation run ends with an unfavourable result (count of overlaps larger than zero).

2.2 Selecting scheme variations

Two variations can be made to the scheme:

2.3 Resistor type and ADC resolution

The resistor row and ADC resolution is selected automatically from the keypad size but can be changed manually to understand the resulting effects. Reducing the E row down can result in changes of resistors because resistor values are rounded to their nearest equivalent in the selected E row. Changing the ADC resolution affects the number of overlapping voltage areas, the result table and the generated assembler table (see below).

2.4 Approximation steps

The button "Step" performs a single approximation step. Approximation means that The button "Run low" performs 100 approximation steps at once only on the lower resistors (R2 to R4 in the 4-by-4 case), the button "Run all" includes all resistors above R1. The number of steps performed at once can be changed in the editor field, 100 should be sufficient in most cases. All resistors that changed their value during the last run are displayed in red. The total number of runs is displayed in the respective label in the lower left field, together with the distances and the overlap count. The overlap count is increased in all cases where the Max value of a key is equal or larger than the Min value of the next key. It should be zero in a succesful approximation run.

As the resistors are randomly chosen, each run can result in different resistor value combinations. If the overlap count is not zero and no resistor value changed, just try a new approximation by selecting the same column or row size.

2.5 Changing resistor values manually

By clicking on a resistor in the scheme a window opens that allows to change its value. k, K and M are allowed. Clicking on the button "Set" changes the value accordingly.

To the top of the page

3 What it produces

If the last step or run yielded the same distance between reference and nominal values and zero overlaps, the three buttons "Save as ...", "Save" and "Asm table" are enabled. By pressing the button Under Windows, the files are written by default to the same folder in which the executable resides. Under Linux Wine, the files are all written by default to the documents folder.

3.1 Scheme

Scheme 4-by-4 The file names starts with "RMat_" and then includes In that case the name of the graphic file is "RMat_StIn_E12_1%_10bit.gif".

To the top of the page

3.2 Resistor list

The resistor file holds the content of the Results-Resistors field as plain text.

3.3 Assembler table

The assembler table "filename.inc" looks like this:

; C4R4 keypad, Inclusive, Stacked
; Decimal table for assembler
Keytable: ; lower limit, upper limit+1, 'Key'
.DW 20, 22 ; '1'
.DW 54, 57 ; '2'
.DW 66, 70 ; '3'
.DW 84, 88 ; 'A'
.DW 88, 92 ; '4'
.DW 214, 222 ; '5'
.DW 253, 262 ; '6'
.DW 304, 314 ; 'B'
.DW 316, 326 ; '7'
.DW 569, 580 ; '8'
.DW 623, 634 ; '9'
.DW 683, 693 ; 'C'
.DW 732, 741 ; '*'
.DW 896, 901 ; '0'
.DW 918, 923 ; '#'
.DW 940, 944 ; 'D'
.DW 0 ; table end
Keyvalues:
.DB "123A456B789C*0#D" ; Key values ASCII

It can be directly included in an assembler source code file.

Note that with 8 bit ADC selected the include file is different as the table is in bytes instead of words!

4 Experiences made

The inclusive mode works very fine and approximation mostly ends with zero overlaps. If not, just restart the approximation.

The exclusive mode works fine if the number of keys is 12 or less. In case of 9 keys or above 1% tolerance or 10-bit ADC has to be selected (or both) to achieve succesful resuts. With 16 keys most runs end with overlaps in this mode. In that case either stick with the default values or manually correct resistor values.

Stacked or single resistor mode results in different values, but shows no different approximation behaviour.

5 Feedback

Feedback please to info (at) avr-asm-tutorial.net (replace (at) by @ and remove blanks).

To the top of the page

©2014 by http://www.avr-asm-tutorial.net