USB typewriter
Portable typewriter Unis tbm de Luxe, made in Yugoslavia, Sarajevo. The most common instance in the post-Soviet space, the keys are 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 up the room with unused things. Therefore, the goal has been set: to adapt the machine to modern conditions so that when printing characters are output on a PC.
Electronics
As contacts for keys, reed switches are provided. The Pro Micro device based on the ATmega32U4 microcontroller is selected for the contact matrix controller.
The source code is written in C, as the basis used LUFA library code for the keyboard. The LUFA library is written specifically for the free AVR-GCC compiler. The firmware was produced by SPI. There is a second version of the firmware, through the bootloader and via USB, but then you need to display the reset button on the MK terminals (Reset and GND).
The algorithm of the program is as follows:
- Four I / O are configured for output (scanning), twelve for input (polling). Resistors (PullUp) are pulled to the inputs (software). In the interrupt, for each output, sequentially set "0", according to the cycle 1110-1101-1011-0111 and so on.
- In a cycle with a running “0”, conditions are checked, if, under some condition, “0” is present (the key is pressed), then this condition is marked with the pressed key column = x, line = y.
- In the callback function CALLBACK_HID_Device_CreateHIDReport (), conditions are checked for each value column = x and line = y, and when it is executed, the corresponding character scan code is sent to the computer.
- With one click, only one character should be displayed, not like on a regular keyboard.
This is not a very elegant version of the algorithm, but it is working!
It is imperative that the cathodes of the diodes and the anodes for each of the four columns of the contact matrix must be connected to the scan (column) conclusions of the microcontroller. This must be done in order to exclude a closure while simultaneously pressing several keys on different columns.
The keys "Upper case" 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 they can be embedded in the matrix.
Unfortunately, the Pro Micro outputs were not enough, literally for one key. I made a mistake: I placed the reed switch of the “superscript” key in the matrix with the rest. It could be done the other way around, insert the space bar contact into the matrix, and add the superscript line in a separate line! But the board was already assembled and painted, I had to complicate the code. There is one more flaw, but it is dictated by the design features of the typewriter: the number of conclusions 4 and inputs of the survey 12, gives us 4x12 = 48 keys, with 4 + 12 = 16 inputs and outputs used. I could, with the number of 48 keys, use 8 pins and 6 polling inputs, thereby freeing up 2 missing inputs.
It makes no sense to draw a circuit diagram, all the connections can be made according to the table below.
Contact matrix scan table for typewriter
Note:
Symbols for scan codes are indicated in red.
Atmega32U4 is listed in (). In [] the PRO-MICRO inputs and outputs are indicated. The
Russian layout is included on the PC!
With column 1, combinations of scan codes are included. With column 2-4, uppercase is enabled while holding down or holding the register key
Mechanics
It is possible to switch the device to mechanical printing, with the movement of the carriage, then printing can be duplicated. If there is a tape, the machine will print on paper and of course in the editor on the PC, the text will be authentic.
For this, the machine was finalized with a retainer. When the screw is screwed in, the carriage is fixed, when unscrewed, we get a regular typewriter + USB keyboard in Cyrillic, in one device.
This is a board made of one-sided foil-coated getinax, on which sealed contacts are mounted. The printed circuit board, on the front side, is painted 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 selected 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 center lines of the reed switch and the magnet affect the stable operation of the contact. When approaching the lever with the magnet at a distance (6-8mm), under the influence of a magnetic field the reed switch closes. It is also necessary that there are no false alarms of neighboring contacts, so I had to distribute the elements evenly on two printed circuit boards. The boards are oriented, in relation to each other, at a certain angle (experimentally selected). The reed switches are evenly distributed and each is distant at the same distance (vertically) from the corresponding lever, in the position of the pressed key (6-8mm).
Reed switches are located on the back of the board, in the opposite side from the levers. This is done specifically to exclude damage to the reed switches, with a possible touch of the circuit board levers. Although the levers do not relate to the board, but for every "fireman", such is accepted. decision.
Sensors for space and register assembly. Although the material is a paramagnet, reed switches in such a shell operate stably.
The device is complete, but without a controller! The controller will be located in the left side (according to the photo), where there are free connectors.
The key sensor "Enter-transfer to another line" is installed on the carriage and connected to the fixed part of the machine with a flexible multicore cable. Inside the carriage, the cable loop folds and unfolds, depending on its position.
The device does not bear any applied benefit, except that more skills, experience and knowledge have appeared, with related work. And if new knowledge has appeared, then time has been well spent!