Team:HBUT-China/AutomaticControlSystem

Automatic Control System

The basic control principle of the pump

The state of the water pump is controlled by controlling the GPIO state of the microcontroller.

First, the IO port of STM32 can be configured by software into the following 8 modes:

1. Input floating

2. Input pull-up

3. Input pull-down

4. Analog input

5. Open-drain output

6. Push-pull output

7. Push-pull multiplexing function

8. Open-drain multiplexing function.

Each IO port of the STM32 has 7 registers to control.

They are: two 32-bit port configuration registers CRL and CRH in configuration mode; two 32-bit data registers IDR and ODR; one 32-bit set/reset register BSRR; one 16-bit reset register BRR; one 32-bit latch register LCKR.

After determining the various states and various control methods of GPIO, we officially began to regulate it. The operation steps are as follows:

1. Start IO clock function. The calling function is RCC_APB2PeriphClockCmd().

2. Initialize the IO parameters. The calling function is GPIO_Init();

3. Operation IO.

For example, setting the value of the ODR register in the firmware library to control the output state of the IO port is implemented by the function GPIO_Write: void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);

This function is generally used to set values on multiple ports of a GPIO at a time.

The BSRR register is the port bit set/clear register. To set the first port value of GPIOA to 1, then you need to write 1 to the 16th bit of the BSRR register.

Finally, complete the control of the three IO ports, so as to control the three pumps, which is the most basic control principle.

The basic working principle of the LCD and ideas of program design

During the design process, we added some support for MDK –O2 optimization. If it is removed, there will be problems when -O2 is optimized. Through the combination of these simple functions, we can perform various operations on the LCD.

In the LCD_ShowChar function, we use the fast draw function, LCD_Fast_DrawPoint to draw characters. This function is the same as LCD_DrawPoint, with only color parameters and reduced time for function calls. In this code we used three character set dot matrix data arrays asc2_2412, asc2_1206 and asc2_1608.

The code design steps are mainly as follows:

1. Start GPIO, FSMC, AFIO clock function

2.GPIO initialization: GPIO_Init() function.

3. FSMC initialization: FSMC_NORSRAMInit() function.

4. FSMC enable: FSMC_NORSRAMCmd() function.

5. Run the initialization code for the LCD driver.

Finally, combined with the ADC and then through the DSP to complete the real-time display of the data.

The basic working principle of the water level gauge

When the measurable liquid level H = 0cm, there is a capacitance C0 between the stainless steel tube and the metal cylindrical capacitor formed by the coaxial insulated wire. According to the literature, the capacitance is:

equation (1):

$C_0 = {{ \frac{2\Pi\epsilon_0 L}{Ln(R1/R0)} }}$

C0 is the capacitance, the unit is F;

Ε0 is the equivalent dielectric constant of the gas in the container, the unit is F / m;

L is the maximum height of the liquid level;

R1 is the radius of the stainless steel tube;

R0 is the radius of the insulated wire., the unit is m.

When the measurable level is H, there is a capacitance CH between the stainless steel tube and the coaxial insulated wire:

equation (2):

$C_H = {{ \frac{2\Pi\epsilon_0 L-H }{Ln(R1/R0)} }} + {{ \frac{2\Pi\epsilon H }{Ln(R1/R0)} }} = {{ \frac{2\Pi\epsilon_0 L}{Ln(R1/R0)} }} + {{ \frac{2\Pi(\epsilon - \epsilon_0)H }{Ln(R1/R0)} }}$

ε is the equivalent dielectric constant of the gas in the vessel, and the unit is F/m.

When the liquid level in the sensor increases from 0 to H, the amount of change in capacitance ΔC can be obtained by equations (1) and (2).

equation (3):

$\Delta C = C_H - C_0 = {{ \frac{2\Pi(\epsilon_0 -\epsilon_0) H}{Ln(R1/R0)} }}$

It can be seen from the formula that the parameters ε0 , ε, R1 and R0 are constant values. Therefore, the amount of change in capacitance ΔC is approximately linear with the amount of change H in the liquid level.

Because the parameters ε0, ε, R1, R0, L are all fixed values. It can be obtained by the formula (2):

equation (4):$CH= a_0 + b_0H $(a0and b0are constant)

As can be seen from the above, the magnitude of the capacitance value CH of the sensor is linear with the depth H of the capacitor immersed in the liquid. Thus, the water level can be calculated as long as the capacitance value is measured.

Copyright 2019 © Hubei University of Technology