Alteration of cash registers. Part 1

Good day everyone. Several years ago, I accidentally got into the hands of an old written-off cash register. It was called "Elves micro-F". Because I'm fond of electronics and programming, including the construction of various devices on microcontrollers, the device decided to explore. Having examined it, I saw:


  • PCB with electronic filling and AT89C52 microcontroller in socket
  • display
  • thermal printer
  • battery
  • film keyboard
  • two LEDs

image
Fig.1 Appearance cashier


At that time, I already had the experience of creating unpretentious devices from scratch (a clock, a relay controlled from a COM port, etc.). Understanding the finished device seemed much more difficult. For a start, I found on the network a description of this device, a schematic, repair documentation. As it turned out, there are several schemes, they differ quite strongly, although the devices are called almost the same. But in the end, I found the desired scheme. He looked at her and realized that in fact the cash register device is not so complicated.


I needed to figure out:


  • how easy it is to program the microcontroller so as not to go back and forth to the programmer, then back to the board
  • how to exchange computer
  • how to work with RAM (and there was a serial AT24C08)
  • how to draw something on display
  • how to get keystrokes
  • and the most important thing! how to display something meaningful on a thermal printer

In this article, I will talk about the beginning of my work. The ultimate goal is to create a thermal printer from an old, withdrawn cash register.


Part 1
Getting Started


At first, I decided to abandon the microcontroller that stood in the board. First, it was possible to program it only on the programmer, which I still did not have for this type of controller. Secondly, he had little internal flash memory for programs.
Having suffered from a choice, I stopped on the Winbond w78e58b microcontroller. He was in the same package (plcc44), had 32K of program memory and more internal static memory for storing variables, and most importantly, he allowed himself to be programmed using an in-circuit programmer without removing it from the panel!


But even here there was a difficulty: in order to start programming it, a parallel programmer was needed for this type of microcontroller, in order to sew up the bootloader, with which I would later flood my firmware. Information on how to make such a programmer I found on the Internet, gathered the programmer, stitched bootloader!


Then there was another problem - this unit did not have a connector for connecting to a PC!


image
Fig.2 Original interface board

Although, as I read in the manuals, there was such a handkerchief, and there were plugs in the case for the device and a connector on the board, but the pairing did not work out. At that time, it was on sale nowhere, and it was worth the poor in cash. Then I decided to make the interface myself. I broke one plug out of the case, disassembled the socket from the local network with the RJ45 connector, cut this connector into a piece of board and pasted it into the cash register case with hot melt glue. As a result, the normal twisted pair was perfectly inserted outside the click! It remains to connect the connector pins to the microcontroller. Of course, it is impossible directly, it is necessary through a level converter, for example MAX232. On a small piece of breadboard placed the microcircuit itself, strapping capacitors, soldered the wiring. Soldered the cable to connect to the computer from a piece of twisted pair.


The next task was to find a compiler, free and not very difficult for such purposes. I got keil microvision. It was some kind of demo version with a limit on the length of the code. For my purposes, enough. The first program was simple: just put something like Hello world on a computer into a terminal program!


I wrote the program, the complexity was only in the initial initialization of ports and service registers. But looking for examples online, I quickly coped with this. Next, I launched the
8051IspWriter program , which floods the firmware. In order for the microcontroller to switch to the firmware download mode, it was necessary to activate the built-in bootloader. As it turned out, this can be done by closing the controller output to the ground before energizing. What exactly - found in the datasheet on the microcontroller. The firmware was flooded, after which I turned off, turned on the cashier and saw my text on the terminal screen! The system worked!


Further, I decided to control the cash register a little, or rather to flash the LED. According to the scheme, I determined which leg of the microcontroller this LED is on, I wrote the simplest flasher and the LED began to flash at the checkout! The path to the final goal has already become visible!


Excerpts from source code:


voidmain(void) 
{
    UCHAR               i;
    char                        c;
        staticint data                     value;
    UCHAR               bCassaTypeOld;
    UCHAR               iNumSymbolsOld;
        jmpLDROM=0;
        // пишу в порты начальные значения чтобы не спалить термоголовку и шаговик
    P0 |= 0x01;                         // PPWR = 1
    P1 |= 0x20;                         // PM1 = 1
    P1 |= 0x40;                         // PM2 = 1
    P3 &= ~0x40;                        // SI = 0
    P3 &= ~0x20;                        // CLOCK = 0
    P3 |= 0x80;                         // LATCH = 1
    P3 |= 0x10;                         // STBA = 1
    P3 |= 0x08;                         // STBB = 1// эта процедура из библиотеки для работы с СОМ портом
        initUart(BAUD_RATE_19200);
        puts("Hello world!");
        while(1) ;
}

Also popular now: