Difference between revisions of "TinyPS2"

From Land Boards Wiki
Jump to navigation Jump to search
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:TinyPS2_P899_cropped-720px.jpg]]
+
See [[TinyPS2 Revs 1-3]] for ATTiny85 based build
 +
 
 +
[[File:TinyPS2_Front_Rev4_3D.png]]
  
 
== Introduction ==
 
== Introduction ==
  
It is getting difficult to find ASCII serial keyboards for use in Retro-Computer projects. This card fills that need. The card is a PS/2 keyboard to TTL Level Serial adapter. PS/2 keyboards are still widely available. This is based on the [https://www.smbaker.com/ps2-ttlserial-adapter-for-rc2014-and-midi design from Scott Baker BLOG].
+
It is getting difficult to find ASCII serial keyboards for use in Retro-Computer projects. This card fills that need. The card is a PS/2 keyboard to TTL Level Serial adapter. PS/2 keyboards are still widely available.
  
 
[[file:Keyboard_PS2_MicrosoftNatural.jpg]]
 
[[file:Keyboard_PS2_MicrosoftNatural.jpg]]
Line 9: Line 11:
 
== Features ==
 
== Features ==
  
* [https://www.microchip.com/en-us/product/ATtiny85 ATTiny85 8-bit CPU]
+
* [[QT_Py_(RP2040_based)|QT Py (RP2040 based)]]
** Run at 8 MHz in this use-case
+
** Run at 125 MHz
** 8 KB of In System Programmable (ISP) flash
+
** 2MB of In System Programmable (ISP) flash
** 8-MHz internal RC oscillator that can be used as the default clock
+
** 264KB of SRAM
** 512 bytes of EEPROM
 
** 512 bytes of SRAM
 
 
* 115,200 baud serial
 
* 115,200 baud serial
 
** 57,600-250,000 are build time options
 
** 57,600-250,000 are build time options
Line 21: Line 21:
 
* 3.3V or 5V operation
 
* 3.3V or 5V operation
 
* Current measurement
 
* Current measurement
** 1 mA @ 5V (without keyboard)
+
** TBD @ 5V (without keyboard)
** 13 mA @ 5V (including keyboard)
+
** TBD @ 5V (including keyboard)
** 8mA @ 3.3V (including keyboard)
+
** TBD @ 3.3V (including keyboard)
*** Requires a keyboard that works at 3.3V
+
*** Does not require a keyboard that works at 3.3V
 +
 
 +
=== CPU Connections ===
  
=== ATTiny85 Connections ===
+
[[file:TinyPS2_CPU_Rev4_Conns.PNG]]
  
[[file:TinyPS2_CPU_Pins.PNG]]
+
<pre>
 +
#define DATAPIN 27
 +
#define IRQPIN  26
 +
</pre>
  
 
== Connectors ==
 
== Connectors ==
Line 34: Line 39:
 
=== J1 - TTL Serial Connector ===
 
=== J1 - TTL Serial Connector ===
  
[[file:TinyPS2_J1.PNG]]
+
[[file:TinyPS2_J1_Rev4_Conns.PNG]]
  
 
# VCC (pin nearest to J1 silkscreem)
 
# VCC (pin nearest to J1 silkscreem)
Line 45: Line 50:
 
* Standard PS/2 Mini-DIN-6 connector
 
* Standard PS/2 Mini-DIN-6 connector
  
[[file:TinyPS2_J2_kbd.PNG]]
+
[[file:TinyPS2_J2_Rev4_Conns.PNG]]
 
 
=== H2 - In-System Programming Header ===
 
 
 
[[file:ICSP.PNG]]
 
  
* SPI connector to download ATTiny85
+
== Firmware Build Card Rev 4 ==
* 2x3 header
 
* Program ATTiny85 without PS/2 keyboard attached
 
* Pinout
 
  
# KBCLK
+
[[file:asciifull.png]]
# VCC
 
# SERTX
 
# KBDAT
 
# RST*
 
# GND
 
  
== Firmware Builds ==
+
=== Arduino ===
  
Two software builds:
+
* Card rev 4 uses a QTPy or XAIO RP2040 CPU
 
+
* Arduino Library
* Scott Baker's build
+
** [https://github.com/techpaul/PS2KeyAdvanced PS2KeyAdvanced]
* Arduino IDE port
+
* [https://github.com/land-boards/lb-Arduino-Code/blob/master/LBCards/TinyPS2/TinyPS2_PCB_Rev4_AdvKbd/TinyPS2_PCB_Rev4_AdvKbd.ino TinyPS2_PCB_Rev4_AdvKbd] - code
 
 
=== Scott Baker's Software Build ===
 
 
 
* [https://www.smbaker.com/ps2-ttlserial-adapter-for-rc2014-and-midi Scott Baker's Build BLOG page]
 
* Scott's demo video
 
 
 
<video type="youtube">cSaBCtcUoq4</video>
 
 
 
* [https://github.com/sbelectronics/ps2-ttlserial Scott's GitHub page]
 
** Scott appears to have used [https://obdev.at/products/crosspack/index.html Crosspack] for AVR software development
 
* Scott uses two libraries from other projects
 
** [https://github.com/thegaragelab/tinytemplate ATTiny85 UART Library] - The Garage Lab
 
*** [https://github.com/thegaragelab/tinytemplate/blob/master/firmware/shared/uart_send.c uart_send.c]
 
** [http://www.nerdkits.com/videos/interrupts_and_ps2_keyboard/ Interrupts: Interfacing a Microcontroller with a PS/2 Keyboard] - PS/2 Keyboard Library
 
 
 
==== Programming Scott's Build ====
 
 
 
* Used [[TL866ii Plus Programmer]]
 
* Scott has [https://github.com/land-boards/lb-Arduino-Code/blob/master/LBCards/TinyPS2/ScottBakerCode/serkey.hex serkey.hex file]
 
** FUSES = -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m
 
** Used Fuse bits from  Programmer
 
*** Matched lfuse values already
 
 
 
==== Tested Scott's Build ====
 
 
 
* Works really well
 
* 115,200 baud
 
* Works at 3.3V or 5V
 
** Drops out around 3.15V - may need BOD bit changed?
 
 
 
=== TinyPS2 Software Build Using Arduino IDE ===
 
 
 
* Converted Scott Baker's build to the Arduino IDE
 
** Move main init code to setup()
 
** Move main inner loop to loop()
 
* Compiled fairly easily
 
* [https://github.com/land-boards/lb-Arduino-Code/tree/master/LBCards/TinyPS2/TinyPS2 GitHub Software Repo]
 
* Resources (Arduino UNO)
 
 
<pre>
 
<pre>
Sketch uses 850 bytes (10%) of program storage space. Maximum is 8192 bytes.
+
#define DATAPIN 27
Global variables use 15 bytes (2%) of dynamic memory, leaving 497 bytes for local variables. Maximum is 512 bytes.
+
#define IRQPIN  26
 
</pre>
 
</pre>
  
==== Setting Baud Rate ====
+
* Example code produces warning
  
* The implementation is optimized for higher baud rates - please don't use anything below 57600 on an 8MHz clock
 
* It does work at up to 250000 baud but you may experience a small amount of dropped packets at that speed.
 
* Set in TinyPS2.ino file
 
 
<pre>
 
<pre>
#define BAUD_RATE 115200
+
WARNING: library PS2KeyAdvanced claims to run on avr, sam, samd1, stm32, esp32 architecture(s) and may be incompatible with your current board which runs on rp2040 architecture(s).
 +
Sketch uses 82336 bytes (0%) of program storage space. Maximum is 16777216 bytes.
 +
Global variables use 43096 bytes (15%) of dynamic memory, leaving 227240 bytes for local variables. Maximum is 270336 bytes.
 
</pre>
 
</pre>
  
==== Arduino IDE Setup for ATTiny85 ====
+
* Code works well!
  
* [http://highlowtech.org/?p=1695 Programming procedure is taken from here]
+
=== C++ ===
* Add ATTiny Board support to Preferences, Path:
 
<pre>
 
https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
 
  
</pre>
+
* [https://github.com/tvlad1234/pico-ps2Driv pico-ps2Driv] - SDK C code
  
==== Programming Card (Arduino IDE) ====
+
=== CircuitPython ===
  
* Select ATTiny85, 8 Mhz
+
* CircuitPython support issues
* '''Burn bootloader''' - Otherwise clock is way off
+
** [https://docs.circuitpython.org/en/latest/shared-bindings/ps2io/index.html PS/2 Library] - Not in Pico core modules
  
[[File:Arduino_IDE_ATTiny85.png]]
+
<pre>
 
+
>>> import ps2io
* [[ATProgHead]]
+
Traceback (most recent call last):
** Running Arduino as ISP
+
  File "<stdin>", line 1, in <module>
* Can program from an Arduino UNO like this:
+
ImportError: no module named 'ps2io'
 
+
</pre>
[[file:ProgramFromArduinoUNO.jpg]]
 
  
 
== Schematic ==
 
== Schematic ==
Line 149: Line 99:
 
== Issues ==
 
== Issues ==
  
=== Rev 3 ===
+
* [[TinyPS2_Revs_1-3|Revs 1-3 are documented here]]
 
 
* Added D3 to J1 connector
 
* Change from SMT parts to through hole parts
 
* Silkscreen cleanups
 
** Added ISP VCC/GND to silkscreen
 
** Added silkscreen to J1 pins
 
 
 
[[file:TinyPS2_Rev3_3D.png]]
 
 
 
=== Rev 2 ===
 
 
 
* Fixed issues below
 
  
=== Rev 1 ===
+
=== Rev 4 ===
  
* Missing pull-up resistors on PS/2
+
* Changed CPU
** Rev 2 - add pull-up resistors
+
** Was 8 MHz ATTiny85
** (There's pullups in the part so this may not be needed)
+
** Changed to QT PY or XAIO
* Missing C3 cap in sequence
+
* Changed pin usage
** Rev 2 - change C4 => C3
+
* Uses Hardware Transmitter in CPU
 +
* Keyboard runs at 5V
 +
* CPU runs at 3.3VV
 +
* 3.3V to 5V level shifter
  
 
== Assembly Sheet ==
 
== Assembly Sheet ==
  
* [[TinyPS2 Rev 3 Assembly Sheet]]
+
* [[TinyPS2 Rev 4 Assembly Sheet]]
* [[TinyPS2 Assembly Sheet|TinyPS2 Rev 1 Assembly Sheet]]
 

Latest revision as of 16:51, 15 August 2022

See TinyPS2 Revs 1-3 for ATTiny85 based build

TinyPS2 Front Rev4 3D.png

Introduction

It is getting difficult to find ASCII serial keyboards for use in Retro-Computer projects. This card fills that need. The card is a PS/2 keyboard to TTL Level Serial adapter. PS/2 keyboards are still widely available.

Keyboard PS2 MicrosoftNatural.jpg

Features

  • QT Py (RP2040 based)
    • Run at 125 MHz
    • 2MB of In System Programmable (ISP) flash
    • 264KB of SRAM
  • 115,200 baud serial
    • 57,600-250,000 are build time options
  • 49x49mm ODAS form factor
  • (4) 4-40 mounting holes
  • 3.3V or 5V operation
  • Current measurement
    • TBD @ 5V (without keyboard)
    • TBD @ 5V (including keyboard)
    • TBD @ 3.3V (including keyboard)
      • Does not require a keyboard that works at 3.3V

CPU Connections

TinyPS2 CPU Rev4 Conns.PNG

#define DATAPIN 27
#define IRQPIN  26

Connectors

J1 - TTL Serial Connector

TinyPS2 J1 Rev4 Conns.PNG

  1. VCC (pin nearest to J1 silkscreem)
  2. SERTX
  3. N/C
  4. GND

J2 - PS/2

  • Standard PS/2 Mini-DIN-6 connector

TinyPS2 J2 Rev4 Conns.PNG

Firmware Build Card Rev 4

Asciifull.png

Arduino

#define DATAPIN 27
#define IRQPIN  26
  • Example code produces warning
WARNING: library PS2KeyAdvanced claims to run on avr, sam, samd1, stm32, esp32 architecture(s) and may be incompatible with your current board which runs on rp2040 architecture(s).
Sketch uses 82336 bytes (0%) of program storage space. Maximum is 16777216 bytes.
Global variables use 43096 bytes (15%) of dynamic memory, leaving 227240 bytes for local variables. Maximum is 270336 bytes.
  • Code works well!

C++

CircuitPython

  • CircuitPython support issues
>>> import ps2io
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'ps2io'

Schematic

Issues

Rev 4

  • Changed CPU
    • Was 8 MHz ATTiny85
    • Changed to QT PY or XAIO
  • Changed pin usage
  • Uses Hardware Transmitter in CPU
  • Keyboard runs at 5V
  • CPU runs at 3.3VV
  • 3.3V to 5V level shifter

Assembly Sheet