Figgipad Encoder

337 views
Skip to first unread message

fig8r

unread,
Jun 12, 2012, 2:40:23 AM6/12/12
to fign...@googlegroups.com
This is a continuation of Another Keyboard thread.

First a little preview

http://youtu.be/SUzmImvY_F0

... details will follow.


Simon

unread,
Jun 12, 2012, 5:31:13 AM6/12/12
to fign...@googlegroups.com
Impressive!  You 'de man.

Julian Skidmore

unread,
Jun 12, 2012, 5:36:44 AM6/12/12
to fign...@googlegroups.com
Hi Oleg,

I guess future plans involve integrating this into a single FIGgy shield with its own AtTiny?

Looking at the previous thread it appears as though you hold down scans for 0.5s at a time, in fact you only need to hold them down for two keypad scans: PD0=0, PB7=0, PD0=0, PB7=0. to register each keypad press. Thus most keys (which require two presses) require merely four keypad scans to be registered: PD0=0, PB7=0, PD0=0, PB7=0. Note also from the actual code, the scan itself takes place just before the row selection changes to select the next row which means you have the maximum amount of possible time (about 0.01s) between observing e.g. PD0=0 and setting C0..C3.

With this kind of setup you can achieve a keypad typing rate of one character every 0.08s or about 12.5cps.

Logically it could be improved further, because if a subsequent key shares one of the same keypad presses then only the other key would need to change. So, e.g. 'it could be encoded as: SW7+SW4 then have SW5 replace SW7. This would give a typing rate of up to 25cps. In practice you could only make use of this so it'd only raise the typing speed to 14cps and the keypad driver doesn't actually support that, so this optimisation can't be made use of :-(

-cheers from julz
--
                             
                  The DIY 8-bit computer from nichemachines™


NmLogoMini.jpg
FIG - black on whiteMini.jpg

Carl Attrill

unread,
Jun 12, 2012, 12:08:14 PM6/12/12
to fign...@googlegroups.com
That is very impressive, well done and keep up the good work ( I have no idea how you do all this !)


On Tuesday, 12 June 2012 07:40:23 UTC+1, fig8r wrote:

fig8r

unread,
Jun 12, 2012, 4:21:53 PM6/12/12
to fign...@googlegroups.com
Hi All

From the earlier post:

    This is a continuation of Another Keyboard thread.

    A concept Figgipad Encoder is presented in
   "Figgipad Encoder Preview"
    http://youtu.be/SUzmImvY_F0

Additional details:

Figgipad Encoder Preview: sending keystrokes from PC to FIGnition via Arduino.

An Arduino is connected to the PC via USB/Serial port and is sent input from a serial terminal. The Arduino sketch captures the serial input and encodes each known ASCII code into Figgipad scan code.

The Figgipad pins are connected to Arduino digital pins. The Figgipad scan code is sent as column signals when the corresponding row pin is in scan cycle.

Attached is the (slightly refactored) Arduino source "figgipad_encoder_concept.ino"

Some comments:
 - there are many simplifications in this concept
 - when we change the pin states from "hold" to "release" between OUTPUT LOW and INPUT with pull-up modes, the previous state is not taken into account
 - the bit order in Figgicode is arbitrary, and suggestions for different reasoning are welcome
 - the ASCII encoding in "figgicode" routine is only a subset, but illustrates both 1 and 2 key codes; it should also be represented as a lookup table

Oleg
figgipad_encoder_concept.ino

fig8r

unread,
Jun 12, 2012, 5:12:33 PM6/12/12
to fign...@googlegroups.com
Hi Julz,


>> I guess future plans involve integrating this into a single FIGgy shield with its own AtTiny?

Well, yes, in order to provide PS/2 to Figgipad interface the classic AtTiny (AtTiny2313) would be the choice. We can more experiments in a separate topic of PS/2 Decoder.

However, as shown in the Figgipad Encoder concept, direct PC connection is per se not a bad idea, given that nowadays people are more likely to have a laptop than a stand-alone keyboard. This assumes USB connectivity. Looks like the options would be
 1) FTDI chip plus a classic AtTiny
     (in place of MAX200 used in Apple 1/2 keyboard adapter referred to by Simon)
     https://groups.google.com/d/msg/fignition/4SI9bkz_mu4/nTWosi7OZhkJ
     http://www.willegal.net/appleii/appleii-kb-int.htm
    Being an extra chip with slower relative speeds, it is less favored lately.
 2) an existing microcontroller like Arduino
 3) a USB-enabled AtTiny such as AtTiny16u4 or 32u4, or a board like Teensy, which is variation of (2)

Interestingly, as observed in the experiments, when correctly wired, the USB as power supply is only needed to one of the boards. So either the keyboard shield can supply power to FIGnition or FIGnition can supply USB pins to the shield (which may not available in non-programming mode).

>> ... With this kind of setup you can achieve a keypad typing rate of one character every 0.08s or about 12.5cps.

Yes, the .5 sec was a ballpark guess emulating a human. On a closer read of the debouncing bit in Understanding It, the assumptions in the concept code were pretty close to your details. Thank you for confirming that.

I am not sure if it is possible for FIGnition to read the clock and data pins of PS/2 itself and then pressing its own 4 column pins. That would likely require 6 additional pins (excluding 6 existing figgipad pins).

Oleg

Julian Skidmore

unread,
Jun 12, 2012, 5:20:19 PM6/12/12
to fign...@googlegroups.com
Hi Oleg,


> I am not sure if it is possible for FIGnition to read the clock and data pins of PS/2 itself
> and then pressing its own 4 column pins. That would likely require 6 additional pins
> (excluding 6 existing figgipad pins).

That variation in my mind is a straight rewrite of the keypad driver for FIGnition which uses some of the C0..C3 pins / D7 / B0 to directly interface to PS/2 holding down the clock line during video scanning to prevent the PS/2 keyboard sending data to the FIGnition.

One thought did occur to me, whether it's feasible to write a dedicated USB Keyboard Host for FIGnition, here the sheild has a USB A connector on it. Although one has to pay for a device and vendor code (yes comms cost money, it's like a tax on ink) I don't think you have to pay to be a host (no device and vendor code needed I think  ;-) ).

-cheers from julz
NmLogoMini.jpg
FIG - black on whiteMini.jpg

fig8r

unread,
Jun 14, 2012, 8:30:40 PM6/14/12
to fign...@googlegroups.com
Regarding USB host for FIGnition, it is an interesting idea. USB host can also support various input devices we well as mass storage.
 
From further reading, USB host is typically done in hardware
 - USB Host shield for Arduino from Circuits@Home by my namesake Oleg Mazurov; How to drive USB keyboard from Arduino; Hardware Manual
 - which uses MAX3421 - USB Peripheral/Host Controller with SPI Interface
 - there's a simpler USB controller Cypress CY7C63813, but the cost difference is not so great and it would have fewer reusable examples
 - there's Atmel AT90USB; AVR287: USB Host HID and Mass Storage Demonstration
 - Software Implemented Atmel Mega32 Universal Serial Bus Host Controller

To correct myself earlier:

>>  3) a USB-enabled AtTiny such as AtTiny16u4 or 32u4, or a board like Teensy, which is variation of (2)
Those AVR MCUs USB device support like Teensy, Leonardo or the USB chip on Uno, are Megas: AtMega16u4 or AtMega32u4

fig8r

unread,
Jun 14, 2012, 8:41:27 PM6/14/12
to fign...@googlegroups.com
Julz >>>> ... With this kind of setup you can achieve a keypad typing rate of one character every 0.08s or about 12.5cps.

Oleg >> Yes, the .5 sec was a ballpark guess emulating a human. On a closer read of the debouncing bit in Understanding It, the assumptions in the concept code were pretty close to your details. Thank you for confirming that.

I did some testing working with serial terminal and pasting lines of text. It turns out playing keys back-to-back causes interference (see picture below). So a delay is required, which is determined experimentally to be 84ms, the same as a debouncing cycle for a single key press.

The update to the code posted earlier:

  while (Serial.available()) {
    char c = (char)Serial.read();  // read ASCII from serial
    byte fc = figgicode(c);        // encode ASCII in figgicode
    if (fc != 0xff) figgiplay(fc); // play foggicode on pins
    Serial.print(c);
    delay(DT);                     // delay between keys
  }

The screenshot shows smaller delays (1) DT/4 ~ 21m with sever interference and (2) DT/2 with some interference



fig8r

unread,
Jun 17, 2012, 8:49:54 PM6/17/12
to fign...@googlegroups.com
Hi All,

Here I share the complete Figgipad Encoder which provides full keyboard use of a PC (Mac) terminal connected to FIGnition via Arduino.

Connections Arduino -> FIGnition:
   Gnd -> Gnd
   D2 -> PB0,  D3 -> PD7
   D4 -> PC0,  D5 -> PC1,  D6 -> PC2,  D7 -> PC3

Features:
 - Arduino is connected to PC via serial (over USB)
 - a terminal program is used to type on PC
 - typed characters are encoded in Arduino and "played" on Figgipad
 - the speed is 4-5 char/sec, which is OK to keep up with normal typing and transfers an average block in just over a minute (details discussed earlier)

Supported characters:
 - all alpha-numeric
 - all syntax chars in Figgipad
   (which excludes tilda '~' and underscore '_' mysteriously omitted therein)
 - Enter, Space, Backspace
 - Arrow keys
 - Special keys:
   - Ctlr+A "Again" - repeat last key
   - Ctrl+B "Begin" - set marker
   - Ctrl+C "Command" - editor commands and octal character entry (lower, upper ASCII, _ and ~)
   - Ctrl+D "Dup" - copy character from marker
 - the Esc key, which exists from Figgy editor and can be used to exit other programs, needs to be pressed twice (as in Unix terminal programs)

Using PC clipboard
 - paste snippets of code
 - copy / paste previous code lines, which acts as command history
 - transfer entire blocks from PC to FIGnition:
   - enter block edit mode in FIGnition (nn edit)
   - clear the block if contain old code ( Ctrl+C Z )
   - copy block / paste to terminal
   - observe until all characters are transfered
   - save editied block (Ctrl+C W)

Design notes
 - an additional memory buffer is used to accumlate the serial input, since the Arduino serial is limited to 128 chars and since key playing is much slower it runs out when pasting 500 character blocks
 - to prevent lost characters, serial pumping is interated with key play and pausing
 - serial speed is set to standard 9600 baud and is not essential due to memory buffer

Figgipad Encoding
 - expressed in a hex matrix corresponding to ASCII
 - to facilitate manual populating of the matrix, the following bit layout is used

    S R C C n r c c  <- LSB
    | | |/  | |  \|---- col of key 2
    | | |   | +-------- row of key 2
    | | |   +---------- no key 2
    | | +-------------- col of key 1
    | +---------------- row of key 1
    +------------------ shift

 - where upper and lower 4 bits are key 1 and 2 and shift adds 4th bit

 - so the 2x4 Figgipad keys are represented as
    0 1 2 3  shift: 8 9 A B
    4 5 6 7         C D E F

 - mapping example
//      0   1   2   3   4   5   6   7   8 ...

// 2  ' '   !   "   #   $   %   &   '   ( ...
    "\x68\x13\x17\x83\x53\x92\xD7\x97\x54 ...
// 3    0   1   2   3   4   5   6   7   8 ...
    "\x46\x01\x02\x03\x05\x06\x41\x42\x43 ...
 
Oleg

figgipad_encoder.ino
MemBuffer.h

fig8r

unread,
Sep 10, 2012, 3:10:20 AM9/10/12
to fign...@googlegroups.com
Announcing Figgipad Encoder v2.1

This is an update to the Original Figgipad Encoder (Jun 17)
    https://groups.google.com/d/msg/fignition/QmsQnWlZ_lw/b20b6GRxqNMJ

to reflect the changes for the new ragged editor FIGnition firmware
    Announcement: FIGnition Firmware 0.9.7!
    https://groups.google.com/d/msg/fignition/xWf8Ami62pE/dENXgENf1-cJ

Summary of changes:
 - Ctrl+J on PC is mapped to Shift+Enter
   (because Ctrl+J in terminal maps to LF line feed in ASCII)
 - all other keys work as described in the Original Figgipad Encoder
 - on start/reset, in serial terminal the logo says "Figgipad v2.1"
   (logo and version is important to know what's currently running)

The remaining keyboard behavior is determined by the FIGnition firmware and is further discussed in that thread.

figgipad_encoder.ino
MemBuffer.h

Julian Skidmore

unread,
Sep 10, 2012, 5:05:16 AM9/10/12
to fign...@googlegroups.com
Hi folks,

> - Ctrl+J on PC is mapped to Shift+Enter
> (because Ctrl+J in terminal maps to LF line feed in ASCII)
> - all other keys work as described in the Original Figgipad Encoder
> - on start/reset, in serial terminal the logo says "Figgipad v2.1"
> (logo and version is important to know what's currently running)

> The remaining keyboard behavior is determined by the FIGnition firmware and
> is further discussed in that thread.

Correct, it means that if you execute:

key .

And type Ctrl+J it will output 131 (128+<cr>), because Ctrl+J on the
PS/2 keyboard maps to Shift, Enter on the FIGgypad which maps to code
131 on FIGnition's character set.

Or if you typed CursorDown it will output 10, because cursor keys are
mapped to 8 (left), 9 (right), 10 (down), 11 (up) in the FIGnition's
character set.

-cheers from julz

--

fig8r

unread,
Sep 10, 2012, 4:00:38 PM9/10/12
to fign...@googlegroups.com
Announcing Figgipad Encoder v2.2

This is an update to Figgipad Encoder v2.1 (earlier in this thread) and Original Figgipad Encoder (Jun 17)

    https://groups.google.com/d/msg/fignition/QmsQnWlZ_lw/b20b6GRxqNMJ

to reflect the changes for the new ragged editor FIGnition firmware
    Announcement: FIGnition Firmware 0.9.7!
    https://groups.google.com/d/msg/fignition/xWf8Ami62pE/dENXgENf1-cJ

Summary of changes (both 2.1 and 2.2):

 - Ctrl+J on PC is mapped to Shift+Enter with key code 141 (128+13) / 0x8D (08+0D)

   (because Ctrl+J in terminal maps to LF line feed in ASCII)

 - Ctrl+E on PC is mapped to Shift+Space with key code 160 (128+32) / 0xa0 (08+20)
   (stands for "auto completE" or "Extend")

 - Esc on PC is mapped to Shift+Del with key code 27 / 0x1B


 - all other keys work as described in the Original Figgipad Encoder
 - on start/reset, in serial terminal the logo says "Figgipad v2.2"
figgipad_encoder.ino
MemBuffer.h

carl

unread,
Feb 1, 2013, 1:36:42 PM2/1/13
to fign...@googlegroups.com
On 2.2 please note that the wiring connections are the same as the Keyboard interface- not the picture in this thread.

Micky

unread,
Mar 3, 2013, 3:34:17 PM3/3/13
to fign...@googlegroups.com
Has anyone the exact specification from the Fignition pins? I think not all of them has a sign on the pcb.


Micky

Julian Skidmore

unread,
Mar 3, 2013, 3:41:13 PM3/3/13
to fign...@googlegroups.com

Hi micky,

Yes, it would appear on the (non-existent) circuit diagram. But the way the pins are used is listed on the site:

http://www.fignition.co.uk/documentation/understand-it

(you need to scroll down a bit)

-cheers julz

--
You received this message because you are subscribed to the Google Groups "FIGnition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fignition+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages