📜 ⬆️ ⬇️

The use of STM32 in industrial machines on the example of the blow molding machine CHODOS (Czech Republic)

In one of the shops of the company where I work, there is a machine that produces plastic packaging. The machine is called a blow molding machine. It was released in 1988 in Karlovy Vary by CHODOS:

image

Cycle controls electronics on TTL logic chips (such as K155 (555) or SN74xx). Under the cut, I'll tell you how I replaced the electronics of the last century with the STM32 microcontroller.

The principle of operation of the blow molding machine in brief is as follows: the plastic crumb coming from the bunker melts and is squeezed out by a screw under pressure through nozzles, forming “sleeves”. After that, the “sleeves” are cut off and fed into blow molding forms in which a product is formed under the pressure of the supplied air (in my case, it is a plastic bottle).
')
The machine is controlled by a pair of dozens of TTL-logic boards, several load switch boards with seven-dors for switching on valves and actuators, several boards of transducers of input signal levels from limit switches. All boards are inserted into the basket with connectors in the control cabinet. In the basket, all connected by the method of cheating. TTL logic boards are assembled on TESLA production chips (analogs of K155 (555) or SN74XX).

The indication of the cycle state is practically absent and therefore during its strong glitches it is almost impossible to understand what's wrong with it. In addition, the boards eventually fail and before you repair them, you need to go through an endless quest with a multimeter and a bunch of paper schemes, and even in uncomfortable positions.

Photo baskets with cards (2 photos)




It was decided to transfer the control and management of the casting cycle to microcontrollers. The first experimental controller was the Arduino Mega 2560. The controller was very "gentle" to work in conditions of strong electromagnetic bursts from starters and electric motors. He just hung out when he pleased. Neither the shielding of the controller itself, nor the replacement of all cables coming from the limit switches to an earthed MKESh 3x0.5, helped. And of course, the entire wiring of the machine was completely replaced. One solution to the hangup problem was to use the optiboot bootloader for Arduino with the watchdog function enabled while maintaining state in the EEPROM and restoring the state with the loop continuing after a reset. But it did not help.

In general, it was decided to abandon Atmega and switch to STM32.

As an STM32, the NUCLEO-F401RE controller was purchased. All signals from limit switches were collected through PC817 optocouplers. Control of the solenoid valves and starters was done on the SSR SHARP S202S02 (a pair of MOC3061 + BT138 can also be used).

image

As an indicator, it was ordered and paid for on Aliexpress LCD12864 (ST7920), but the seller sent a 20x4 LCD (during the dispute, the money was returned, but the display remained) and decided to use it.

The program was written in the online compiler mbed .

Now a little on the methods of programming this controller in mbed. Work with signals from a limit switch, load control and work with timers:

Cut from code
All code takes about 2000 lines. I will not post. I can only say that service information is constantly coming out of the controller via the COM port (made for myself).

I will show only the key fragments.

// Initial Settings
// Operator-regulated variables are stored in the eeprom memory.
#include "_24LCXXX.h" // Library of working with the eeprom memory chip
_24LCXXX eeprom (& i2c, 0x50); // Connect the eeprom chip
DigitalIn S41 (PC_8); // End switch S41 is connected via the optocoupler to the controller output PC_8
DigitalOut Y43 (PA_13); // Hydraulic valve control Y43 (coil 220V) through the output PA_13
Timer T48; // T48 - timer used in the casting cycle
float SetT48 = 15.0; // Variable adjustable by operator. The time for which the timer T48 is activated.
...
void setup ()
{
...
S41.mode (PullDown); // Enable pull-up resistor
...
}
int main () // main loop {
...
// Method of working with the signal from the trailer
if (S41 == LOW) { // Check the status of the trailer
...
}
...
// Load control method
Y43 == 1; // Enable Hydro Valve Y43
Y43 == 0; // Turn off the hydraulic valve Y43
...
// Work with timer
T48.reset (); // Reset Timer T48
T48.start (); // Start timer T48
...
CurrentT48 = T48.read (); // Read the current value of the counting timer T48
if (CurrentT48> SetT48) { // Compare with a given value
T48.stop ();
}
// Displays the dynamic state of the timer on the LCD
lcd.printf ("T48 =% 4.1f", CurrentT48);
...
// Method of working with eeprom:
eeprom.nbyte_read (0x00, & SetT48, 4); // Reading 4 bytes from its eprompm starting at address 0x00 and writing the contents to the setT48 variable allocated to memory (the type of the variable float is 4 bytes)
eeprom.nbyte_write (0x00, & SetT48, 4); // Write to it with 4 bytes starting from the address 0x00 of the memory values ​​of the allotted variable SetT48 (the type of the variable float is 4 bytes)
...
}

The controller is flashed. NUCLEO stitched very easily. After connecting the USB cable from the NUCLEO to the computer, the removable disk appears in the latter. In it we copy the binary obtained after compilation in the online compiler and everything - the firmware itself will be poured into the crystal. There were moments when you had to upload a binary directly from the Galaxy Nexus via an OTG cable.

Made PCB method LUT. Soldered. Mounted in the cabinet of the machine. Launched. He taught the operators to set up.

Result photo


Result Video


To date, the "mileage" is more than 100 thousand cycles! Not a single fault due to electronics.

Total. The blower controller has 13 optical isolating inputs, 11 optical isolating outputs, each switching up to 8A load. Programming the casting cycle. LED indication of inputs and outputs. Display of various information. Automatic and manual control modes. In manual mode, it is possible to turn on and off each power output separately with software protection from emergency conditions (for example, controlling the three-phase reverse motor starters of one of the machine mechanisms) to diagnose the health of individual machine components.

We have three machines. The remaining two also translate to the controller.

About the prices do not write. The course is jumping. Yes, and all the details can be found on Aliexpress, where I bought everything.

Thank. I will answer questions.

PS At the next stage, the replacement of the ancient control of heating of the six zones of the screw and the “head” of the machine with modern electronics (6xMAX6675 + Atmega328 + 6xMOC3061 + 6xBT138-600 + LCD20x4). I will collect everything in a small box and finally throw out a huge control cabinet.

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


All Articles