https://github.com/xunker/panasonic_typewriter_interface
Print text using the Interface Port of your compatible Panasonic KX-R Daisywheel typewriter, KX-W word processor, RK-T "CupWheel" typewriter, or KX-WD55 daisywheel printer. Emulates the serial/RS-232 function of the KX-R60 (currently working), and RP-K100/RP-K105 (in development) interface adapters.
Use your 🏋️heavy🥌 and 🐢slow🐌 typewriter as a noisy, inconvenient, inflexible, single-page printer!
A complete video of the high low-speed daisywheel action can be found on the TouYubes.
- Compatibility
- Typewriter Pinout
- Arduino Wiring
- Code
- Printerering (aka, how to use this)
- Serial Configuration Terminal
- Known Problems
- Theory of Operation
- TODO
- License
Developed and tested with my KX-R435, and should be compatible with any other Panasonic typewriter with the round, 8-pin MiniDIN port.
Untested, but should work with machines which have a DE-9 (DB-9) connector. Currently does not work, but is in active development. See rp-k10x_vs_kx-r60.md for research details.
See PINOUT.md for detailed information about the typewriter connector pinout.
Although this is built around the Arduino Nano, any 5V board which uses the ATmega328 will also work. Any other 5V ATmega MCU should work as as well (such as the ATmega32U4in the Arduino Micro), and clones like the LGT8F328 (tested).
Non-ATmega/AVR boards may work, as long as they are compatible with the libraries used in this project (see "Required Libraries"), have enough pins, and run on 5V (or are 5V-tolerant). I have not tried any of this.
There's an adapter board available to ease assembly, and to provide additional features.
Minimum required:
Arduino Pin | Goes To | Purpose |
---|---|---|
A0 | Typewriter ON_LINE pin | ~ON_LINE signal to typewriter |
A1 | Typewriter TXD_PIN pin | TXD_PIN signal to typewriter |
A2 | Typewriter STB_PIN pin | ~STB_PIN signal to typewriter |
A3 | Typewriter ACK_PIN pin | ~ACK_PIN signal from typewriter |
A6 | Switch to ground | "RUN/HALT" switch (GO_PIN), active low |
Optional "Mode" button:
Arduino Pin | Goes To | Purpose |
---|---|---|
A7 | Button to ground | Mode button (MODE_PIN), optional, active low |
Separate USB-to-Serial Adapter: You can use the built-in USB port as the Serial connection, but hardware flow control will not be available. To use hardware flow control you will need to connect up to an external USB to Serial adapter:
Arduino Pin | Goes To | Purpose |
---|---|---|
TX1 (D1) | RxD on USB Serial Module | Transmit serial data to USB host |
RX0 (D0) | TxD on USB Serial Module | Receive serial data from USB host |
11 | CTS on USB Serial module | CTS (Clear to Send) |
12 | RTS on USB Serial module | RTS (Request to Send) |
You can also connect some optional additional LEDs for debugging (or because they look neat when they blink):
Arduino Pin | Goes To | Purpose |
---|---|---|
8 | LED + | State of ON_LINE pin |
6 | LED + | State of STB_LED pin |
2 | LED + | State of ACK_LED pin |
3 | LED + | State of TXD_LED pin |
The included code will read data from the Serial
device (usually USB Serial)
and relay that to the typewriter in the correct format.
The following libraries are required by default. They can either be installed manually or via the Arduino IDE:
SerialCmd and MemoryUsage are only needed by the Serial Configuration Terminal (enabled default). AceButton is only needed if the "Mode" button is enabled (enabled by default).
NOTE: if you are using the included adapter board, you do not need to do any additional configuration. Simply connect your cable and adjust the "Cable Type" jumpers so they are both closest to whichever LED (D1 or D2) is lit up.
Edit panasonic_typewriter_interface.ino and change the following lines as appropriate:
#define ON_LINE_PIN A0 // Output, active LOW
#define STB_PIN A2 // Output, active LOW
#define ACK_PIN A3 // Input, active LOW
#define TXD_PIN A1 // Output; HIGH = 1, LOW = 0
#define GO_PIN A6 // trigger printing to begin when this is pulled low
#define MODE_PIN A7 // trigger printing to begin when this is pulled low
/* RTS_PIN/CTS_PIN are only needed if `#define ENABLE_RTS_CTS` is uncommented */
#define RTS_PIN 12 // incoming from RTS, active low (for ENABLE_RTS_CTS)
#define CTS_PIN 11 // outgoing to CTS, active low (for ENABLE_RTS_CTS)
CHECK WHAT KIND OF CABLE YOU HAVE, and remember that a Macintosh-style printer cable likely has several pins swapped.
Once you're done, upload it to your Arduino-compatible MCU.
There is also a "Demo Mode" that will just print text automatically and not
wait for input over serial; enable that by uncommenting // #define TEST_MODE
in panasonic_typewriter_interface.ino.
By default, there are 4 addition LEDs broken out to show the status of each of the signal lines (in addition to the built-in LED).
#define ON_LINE_LED 8
#define STB_LED 6
#define ACK_LED 2
#define TXD_LED 3
#define LED_BUILTIN 13 // "Status" LED
These LEDs will reflect the state of each respective signal. Note, this is a logic state, not the electrical state. That means for active-low pins like ON_LINE, STB, and ACT, a low signal will turn on the appropriate LED.
However, if you do not require these additional LEDs you can comment-out the
line #define ENABLE_MULTIPLE_LEDS
, and then only the built-in LED will be
used.
Once the code is uploaded and your Arduino is properly connected to your typewriter, turn on your typewriter and load paper as appropriate.
Then, you must get in to "On-Line Mode". The command varies from model to model,
so consult the owners manual for more detail. In the case of the KX-R435, you
enter On-Line Mode by holding down the CODE
key and then pressing E
; the LCD
should now say "On-Line Mode". To exit On-Line mode, or to stop printing, press
CODE+E again.
Once in "On-Line Mode", you'll need to set your Arduino to "Run" mode. If you
are using the included adapter board, you do this by
switching the "RUN/HALT" switch to "RUN". If you are have wired your own
microcontroller, you will connect pin A7 (or whatever pin you assigned to
GO_PIN
) to ground.
Once you switch to "RUN" mode, reset the microcontroller once to ensure it's now in the correct mode.
As long as that pin is grounded, sentences will keep being sent to the typewriter.
Finally, open a serial connection to your MCU (using the built-in Serial Console in the Arduino IDE works well).
The default speed is 300 baud. Yes, you read correctly, 300 baud. Because it's a freakin' TYPEWRITER! It can barely keep up with 30 char/sec. If you want a laser printer, you know where to find one.
Out of the box, the Arduino toolchain only gives the atMega328 a 64 byte serial
buffer, which can hold about 2 seconds of data at 300 baud. I'd actually like
to set the default speed to 110 baud, but no operating systems have supported
that speed for at least 30 years. Yes, not even Linux despite the lies that
stty
tells you.
Send some text! With luck, you'll see it appear in your paper! Eventually!
See SERIAL_CONFIG.md.
The default speed is 300 baud (see "Send text - SLOWLY" for reasons), and even that has problems unless you use hardware flow control (RTS/CTS) and text will start to be dropped in about 2 lines.
This is because of two things issues:
- the Arduino Serial buffer is only 64 bytes, on the ATmega328
- Even the fastest Panasonic Daisywheels can only print 15 characters/sec, which is only half the speed of 300 baud, and most models can only print 12 CPS
There are two solutions:
- Use hardware flow control
- On USB, this requires use of a separate USB-to-Serial adapter because the IC included on Arduino Nano does not connect any lines besides TxD, RxD, and DTR
- The current Adapter Board can use a separate USB-to-Serial adapter connected to J4, with CTS connexted to "TX1" and RTC connected to "RX1"
- Future versions of the adapter board will include footprints for a separate USB-to-serial converter
- add a "character delay" when you send, greater than 30ms/character
- CoolTerm can do this:
Options
->Transmit
->Use Transmit Character Delay
- CoolTerm can do this:
If Serial Console support is compiled in (the default), a reboot (via reset button) is require when going from HALT mode to RUN mode.
The "Mode Button" is currently GN/DN (goes nowhere & does nothing).
See rp-k10x_vs_kx-r60.md for a detailed sequence diagram.
Rough order of importance:
- Working emulation of RP-K100 and RP-K105 adapters
- Use .h files properly; move code out of those
- Finish V2 adapter board which will give RTS/CTS and RS-232 options
- must get RP-K100 and RP-K105 workign first
- Get special/accented character conversion functioning
- Convert special characters like tab ("\t") to spaces, to prevent typewriter from going crazy if no tabs have been set
- ability to set tab-to-space count in serial console
In no particular order:
- DTR/DSR support, for compatibility with older hosts that didn't use RTS/CTS
- Ex: Apple II, C64, TRS80, etc.
- Transceivers or driver/receiver pairs for typewriter connection, for buffering
and for possible 3.3v operation
- 3x active-low drivers
- 1x active-low receiver
- Better serial buffering
- Default 64 byte buffer doesn't even do 300 baud well
- Implement a 1K ring buffer? We have the free SRAM
- This is less of an issue with RTS/CTS support
- Support alt Serial on LGT8F328 with Rx/Tx pins 5 & 6
- Separate serial interface for debugging output on different pins, with different baud rate
- Software serial, or SERIAL1 on 328PB or LGT8F328
- I2C display support
- in software, alreadu have hardware support via Stemma connector
- Automatically insert correct line-breaks, depending on CPI switch setting
- May not be needed or even supported
- Windows' generic/text only printer automatically wraps at 80 characters
- May not be needed or even supported
- Automatically pause printing to insert next sheet of paper, based on line-spacing switch setting
- MODE button becomes "Continue" button
- mode button cycles through CPI/Line Space settings? Need display for this?