Requirements:
1. Realize the speed regulation of the PWM fan
2. Realize the speed measurement of the PWM fan
3. Realize the fan running at a low wind speed during welding, and accelerate the exhaust of smoke when smoke is detected, reducing noise interference to people and smoke damage to the body.
4. The temperature sensor senses the temperature and
the 5.4-digit digital tube dynamically displays some information.
Completion status:
1. It has been implemented. There are two modes. There are 7 levels of wind speed available in the adjustment mode. The current output gear and the current output gear will be displayed on the interface. The speed measured by the tachometer. In PM2.5 mode, it will operate at normal level 1 (1200RPM) and level 6 (3500RPM) when smoke is detected.
2. It has been implemented, but when the fan is completely turned off and does not rotate, the speed measuring foot display will be abnormal and the data will not be updated. It is not yet confirmed whether it is a code problem or a fan feature.
3. It has been implemented, and the particle content will be displayed on the screen.
4. The driver has been written, but has not yet been adjusted. It will be improved later.
5. The driver has been written and is not needed for the time being. It will be improved later.
1. The PWM speed-adjustable fan

used here is Delta AFB1224SHE, power supply is 24V, fan size is 12038, full load current is 0.75A, and rotation speed is 4500RPM.
Select 4PIN for the plug, which is the same as the computer motherboard definition.
Pin 1: GND
Pin 2: VCC, input 24V
Pin 3: tach, open-drain output, after external pull-up, the fan speed is calculated by reading the frequency.
Pin 4: PWM, internally pulled up to VCC, the fan runs slowly when it is left floating, and turns off when it is pulled down. When adjusting the speed, you need to input a pulse between 20Khz and 30Khz, just change the input pulse width.
Problem: The speed read when the pulse input is 0 is abnormal. We have not yet investigated in detail whether it is a code problem or a fan problem.
2. Smoke sensor

The smoke sensor uses Sharp GP2Y1014AU. This sensor has diagonally distributed infrared light-emitting diodes and phototransistors inside, which work using the photosensitive principle. Used to detect particularly fine particles, such as cigarette particles and fine dust. The particle concentration is judged by the height of the output pulse. (Actually, what is measured is not the PM2.5 value, but the sum of PM1.0, PM2.5, and PM10. In fact, most sensors that claim to be able to detect PM2.5 cannot).
1. The 150Ω resistor and 220uf capacitor in the circuit supply power to the infrared light-emitting diode. They cannot be directly connected to 5V and need to be current limited. At the same time, in order to ensure stable power supply, a 220uf resistor needs to be connected in parallel to the positive and negative poles of the infrared diode. When purchasing the sensor, these two devices I will send it, which obviously means it is very important.
The 2.3-pin LED pin is externally controlled to turn on the infrared light-emitting diode of the sensor. The sensor has strict timing requirements for its operation, so in many cases a transistor is added in front to improve the driving ability for stable power supply. Of course, I did not add it and do not check the stable value. It is just for reference. For the smoke detection switch, it is enough to directly drive it with a microcontroller.
3. Two resistors divide the voltage at the VO pin, because the microcontroller ADC can only receive up to 3.3V.
In addition, the maximum voltage value of the sensor output is limited to a range of 0-512ug/m3. Beyond this range, it will only be displayed as the maximum value. The welding smoke I actually tested was much greater than this value.
Physical map: