📜 ⬆️ ⬇️

Usb typewriter



Portable typewriter Unis tbm de Luxe, produced in Yugoslavia, Sarajevo. The most common copy in the post-Soviet space, the keys in Cyrillic.

The combination of red and white colors of the case attracts attention, and there is always a desire to use the machine as an element of decor. But why clutter the room with unused things. Therefore, the goal has been set: to adapt the machine to modern conditions so that when printing, the characters are output on a PC.

Electronics


As contacts for keys, reed switches are provided. A Pro Micro device, based on the ATmega32U4 microcontroller, is selected for the controller of the contact matrix.
')
The source code is written in C, as the basis was the LUFA library code for the keyboard. The LUFA library is written specifically for the free AVR-GCC compiler. The firmware was made by SPI. There is a second version of the firmware, via the bootloader, and via USB, but then you need to display a reset button on the MK pins (Reset and GND).

The program algorithm is as follows:

  1. Four I / O are configured for output (scan), twelve for input (polling). The resistors (PullUp) are tightened to the inputs (software). In the interrupt, for each output, we sequentially set “0”, according to the cycle 1110-1101-1011-0111 and so on.
  2. In the cycle with the running “0”, the conditions are checked, if under some condition there is a “0” (key is pressed), then this condition is marked accordingly with the pressed key column = x, line = y.
  3. In the callback function CALLBACK_HID_Device_CreateHIDReport (), the condition is checked for each value column = x and line = y, and when it is executed, the corresponding symbol scancode is sent to the computer.
  4. With one press, only one character should be displayed, not like on a regular keyboard.

This is not exactly an elegant version of the algorithm, but it is working!

It is imperative that the cathodes of the diodes should be connected to the conclusions of the scan (column) of the microcontroller, and the anodes to each of the four columns of the matrix of contacts. This must be done in order to avoid closures by simultaneously pressing several keys on different columns (column).

The keys "Uppercase" and "Superscript" must be displayed in separate lines to simplify the code. The keys "Enter-transfer to another line" and "Space" are displayed in separate lines, due to the design features of the machine, but it is possible to embed them in the matrix.

Unfortunately, Pro Micro did not have enough conclusions, literally for one key. I made a mistake: put the reed key "superscript" in the matrix with the rest. It was possible to do the opposite, the contact of the space bar to inject into the matrix, and the superscript to bring a separate line! But the board was already collected and painted, it was necessary to complicate the code. There is one more flaw, but it is dictated by the design features of the typewriter: the number of pins 4 and polling inputs 12, gives us 4x12 = 48 keys, with 4 + 12 = 16 inputs and outputs used. With the number of 48 keys, I could use 8 pins and 6 polling inputs, thereby freeing 2 missing inputs.

There is no point in drawing a circuit diagram; all connections can be made according to the table below.

Contact matrix scan table, for typewriter



Note:
Red color indicates symbols for scan codes.
The Atmega32U4 I / O is listed in (). PRO MICRO I / O

On the PC included Russian layout!

When column 1 includes a combination of scan codes. With column 2-4, upper case is enabled when you hold or hold the register key

Mechanics


It is possible to switch the device to a mechanical seal, with the movement of the carriage, then the seal can be duplicated. If there is a tape, the machine will print on paper and of course in the editor on a PC, the text will be authentic.

To this end, the machine has been modified fixer. When the screw is screwed, the carriage is fixed, with the screwed out we get the usual typewriter + USB keyboard in Cyrillic, in one device.



This is a board made of one-sided foil getinax, on which sealed contacts are mounted. The printed circuit board, on the front side, is painted in silver to fit it into the design of the device. Earlier, in place of the board, a sticker of the same color was installed.



The distances between the elements are carefully chosen experimentally, and depend on the kinematics of the typewriter. On the edges of the levers, under the keys, neodymium magnets are installed.

The position of the magnet in space and the distance between the central lines of the reed switch and magnet affect the stable operation of the contact. When approaching a lever with a magnet at a distance (6-8mm), the reed switch closes under the action of a magnetic field. It is also necessary that there are no false positives of neighboring contacts, so I had to spread the elements evenly onto two printed circuit boards. The boards are oriented, in relation to each other, at a certain angle (selected experimentally). The reed switches are evenly distributed and each is distant by the same distance (vertically) from the corresponding lever, in the position of the pressed key (6-8mm).

The reed switches are located on the back side of the board, in the opposite side of the levers. This was done specifically to prevent damage to the reed switches, with a possible touch of the circuit board with the levers. Although the levers do not touch the board, but for every fireman, it is accepted that. decision.



Sensors for the space and register assembly. Although the material is a paramagnetic, the reed switches in such a shell work stably.



Device assembly, but without controller! The controller will be located in the left side (according to the photo), where there are free connectors.



The sensor of the “Enter-transfer to another line” key is installed on the carriage and is connected to the fixed part of the machine with a flexible multicore cable. Inside the carriage, a cable loop is rolled up and turned around, depending on its position.



The device does not carry any application benefits, except that more skills, experience and knowledge have appeared, with related work. And if new knowledge has appeared, then time is well spent!

Source: https://habr.com/ru/post/444864/


All Articles