The electronic scale (English name: electronic balance) is a kind of weighing instrument, which is a tool for measuring the quality of objects by using the principle of lever balance of Hooke's law or force. According to the structural principle, it can be divided into three categories: mechanical scales, electronic scales, and electromechanical combined scales.
The electronic scale is mainly composed of a load-bearing system (such as a weighing pan, a scale body), a force transmission conversion system (such as a lever force transmission system, a sensor), and an indication system (such as a dial, an electronic display instrument).
Based on stm32 electronic scale program Daquan (1)Design of multifunctional electronic scale based on STM32
Subject requirements:
1, the basic part:
(1) The unit price can be set with the keyboard, and the weight, unit price and total amount can be displayed at the same time after weighing; the electronic price scale: the maximum weighing is 10.000 kg, and the weight error is not more than ±0.1%;
(2) With TFT LCD display, display weight, unit price, total amount and other information.
a, the weight is displayed as 5 digits, the unit is kilogram, and the maximum weight display value is 99.999 kg;
b. The unit price is displayed as 5 digits, the unit is yuan, and the maximum unit price display value is 999.99 yuan;
c. The total price is displayed as 6 digits, the unit is yuan, the maximum total price display value is 9999.99 yuan, and the total price amount error is not more than 0.01 yuan;
(3) It has a peeling function and a total accumulation calculation function;
(4) The unit price of 10 kinds of commodities can be pre-stored;
(5) measuring and displaying the ambient temperature, the temperature measurement error is not more than 1 ° C;
(6) Weighing 0-10kg;
(7) Voice broadcast measurement results
2. Play part:
(1) It has a real-time clock display and has power-down protection, which can display the calendar clock (year, month, day, hour, minute, second);
(2) Expanding the high-precision A/D converter and improving the measurement accuracy of the electronic pricing scale, the measurement error is not more than ±0.01%;
(3) The name (or code) of the 10 types of goods and the unit price of the goods can be pre-stored;
Unit module design:
1, the main control chip module
2, TFT LCD module
3, weighing module
4, voice broadcast module
5, 24bitAD HX711 conversion module
6, the software part
Module introduction: 1, the main control chip moduleIn this production, we used STM32 as the main control chip, mainly considering that HX711 is 24bit AD, and the calculation amount is large, and our production also adds peripherals such as TFT color liquid crystal module and voice broadcast module. The MCU's screen and operation speed is not enough, so I chose STM32 as the master chip. The following is a brief introduction to the chip: The STM32F103xC, STM32F103xD, and STM32F103xE enhanced series use the high-performance ARM® CortexTM-M3 32-bit RISC core operating at 72MHz with built-in high-speed memory (up to 512K bytes of flash and 64K words) Section SRAM), a rich set of enhanced I/O ports and peripherals connected to two APB buses. All models include three 12-bit ADCs, four general-purpose 16-bit timers, and two PWM timers. They also include standard and advanced communication interfaces: up to 2 I2C interfaces, 3 SPI interfaces, and 2 I2S interface, 1 SDIO interface, 5 USART interfaces, one USB interface and one CAN interface.
2, TFT color LCD moduleA TFT-LCD is a thin film transistor liquid crystal display. Its full name in English is: Thin Film Transistor-Liquid Crystal Display. Unlike a simple matrix of passive TN-LCD and STN-LCD, TFT-LCD is provided with a thin film transistor (TFT) on each pixel of the liquid crystal display to effectively overcome crosstalk during non-gating. The static characteristics of the display liquid crystal screen are independent of the number of scanning lines, thus greatly improving the image quality. TFT-LCD is also called a true color liquid crystal display. The module has the following features:
1, 320 & TImes; 240 resolution.
2, 16-bit true color display.
3, comes with a touch screen, can be used as a control input.
4, the universal interface, in addition to the ALIENTEK MiniSTM32 development board, the LCD module can also be used on the development board of the excellent special, STMSKY, Red Bull and so on.
Here in the hardware, the corresponding relationship between the TFTLCD module and the IO port is as follows:
LCD_LED corresponds to PC10;
LCD_CS corresponds to PC9;
LCD _RS corresponds to PC8;
LCD _WR corresponds to PC7;
LCD _RD corresponds to PC6;
LCD _D[17:1] corresponds to PB[15:0];
The relevant setup steps required for TFTLCD display are as follows:
1) Set the IO that the STM32 is connected to the TFTLCD module.
In this step, first set the IO port that we connect to the TFTLCD module as the output, which IO port is used, which needs to be determined according to the connection circuit and the setting of the TFTLCD module.
2) Initialize the TFTLCD module.
In fact, here is the same as the initialization process of the above OLED module. The display of the TFT LCD is initiated by writing a series of settings to the TFT LCD. Prepare for subsequent display of characters and numbers.
3) Display characters and numbers on the TFTLCD module by function.
Touch part:
Resistive touch screens are controlled using pressure sensing. The main part of the resistive touch screen is a resistive film screen that is very compatible with the surface of the display. It is a multi-layer composite film with a layer of glass or hard plastic as the base layer and a transparent oxide metal on the surface (transparent conductive). Resistor) Conductive layer, covered with a layer of outer surface hardened, smooth anti-scratch plastic layer, coated with a coating on its inner surface, with many fine (less than 1/1000 inch) transparency between them The isolation point separates the two conductive layers from each other. When the finger touches the screen, the two conductive layers have contact at the touch point position, the resistance changes, and signals are generated in both the X and Y directions, and then sent to the touch screen controller. The controller detects this contact and calculates the position of (X, Y), and then operates according to the position obtained by simulating the mouse. This is the most basic principle of the resistive touch screen.
The characteristics of the resistive screen are:
1) It is a working environment completely isolated from the outside world, not afraid of dust, water vapor and oil.
2) It can be touched with any object, and can be used for writing and drawing, which is a big advantage.
3) The accuracy of the resistive touch screen depends only on the accuracy of the A/D conversion, so it can easily reach 4096*4096.
3, weighing moduleFull-scale output voltage = excitation voltage x sensitivity 2.0mv / v
For example: the supply voltage is 5v times the sensitivity 2.0mv/v = full scale 10mv
Wiring: red line input voltage +, black line input voltage -, green line output signal +, white line output signal - installation method: cantilever beam installation
4, voice broadcast moduleThe WT588D voice chip is a powerful voice-removable chip that can be repeatedly erased and programmed. The WT588D allows the voice chip to no longer find a suitable peripheral MCU circuit for the control mode. The highly integrated MCU technology is sufficient to replace the complex peripheral control circuit. Supporting WT588D VoiceChip PC operation software can freely replace any control mode of WT588D voice MCU chip, and download the information to SPI-Flash. The software operation mode is simple and easy to understand, and the voice combination technology is combined, which greatly reduces the time of voice editing. Full support for online download, even if the WT588D is powered on, you can download the information to the associated SPI-Flash through the downloader, reset the WT588D voice chip circuit, and update to the control mode just downloaded.
The voice broadcast module of this work uses a one-line serial port control mode, which can control voice play, stop, loop play and volume level through the code end, or directly trigger any voice of 0~219 address bits, and the code speed is 600us~2000us; Two output modes: PWM and DAC, PWM output can directly drive 0.5W/8Ω Speaker, DAC output external amplifier, good sound quality. Since this work does not require excessive sound quality, the PWM output method is used.
When using the WT588D voice broadcast module, voice synthesis software is required to synthesize the voice, and then the voice corresponding to the specific address is compiled into a bin file and downloaded into the WT588D module through the Voice_Chip_V-B software.
5, 24bitAD HX711 conversion moduleThe HX711 is a patented 24-bit A/D converter chip designed for high-precision electronic scales. Compared with other chips of the same type, the chip integrates peripheral circuits required by other types of chips including a regulated power supply and an on-chip clock oscillator, and has the advantages of high integration, fast response, and strong anti-interference. The overall machine cost of the electronic scale is reduced, and the performance and reliability of the whole machine are improved.
The interface and programming of the chip with the back-end MCU chip is very simple, all control signals are driven by pins, no need to program the internal registers of the chip. The input selector switch can be used to select either Channel A or Channel B to connect to its internal low noise programmable amplifier. Channel A has a programmable gain of 128 or 64, and the corresponding full-scale differential input signal amplitude is ±20mV or ±40mV, respectively. Channel B is a fixed 64-gain for system parameter detection. The regulated power supply provided on the chip can supply power directly to the external sensor and the A/D converter in the chip, and no additional analog power supply is required on the system board. The clock oscillator inside the chip does not require any external devices. The power-on auto-reset feature simplifies the boot process. Features:
• Two selectable differential inputs
• On-chip low noise programmable amplifier with selectable gains of 64 and 128
• On-chip voltage regulator circuit provides power directly to external sensors and on-chip A/D converters
• The on-chip clock oscillator does not require any external devices, and an external crystal or clock can be used if necessary.
• Power-on automatic reset circuit
• Simple digital control and serial communication: all controls are input by pins, and the on-chip registers do not need to be programmed
• Choice of 10Hz or 80Hz output data rate • Synchronous suppression of 50Hz and 60Hz power disturbances
• Power consumption (including regulated power supply circuit): Typical operating current: “1.7mA, power-off current: “1μA • Operating voltage range: 2.6~5.5V
• Operating temperature range: -20~ +85°C • 16-pin SOP-16 package
6, the software part of the TFT driver part:Void LCD_WR_REG(u8 data) Write register function
U16 LCD_ReadReg(u8 LCD_Reg) Read Register
Void LCD_WriteRAM_Prepare(void) Start writing GRAM
U16 LCD_ReadPoint(u16 x,u16 y) Read the color value of a certain point
Void LCD_DisplayOn(void) //LCD On Display / void LCD_Clear(u16 Color) Clear Screen Function
Void LCD_Init(void) Initialize lcd
Void LCD_DrawPoint(u16 x,u16 y) Draw points
Void LCD_Fill(u16 xsta, u16 ysta, u16 xend, u16 yend, u16 color) Fills the specified area in the specified area
Void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2)
Void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2) draw rectangle
Void Draw_Circle(u16 x0,u16 y0,u8 r) Draw a circle of the specified size at the specified position
Void LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode) Display a character at the specified position
Void LCD_ShowNum(u16 x,u16 y,u32 num,u8 len,u8 size) Display number
Void LCD_Show2Num(u16 x, u16 y, u16 num, u8 len, u8 size, u8 mode) Display 2 digits
Void LCD_ShowString(u16 x,u16 y,const u8 *p) Display string
WT588D part:
Void wt588d_init(void) WT588D initialization
Void send_dat(u8 addr) Sends data to WT588D as a one-line serial port
Void pronounce_num(u16 t) integer part number pronunciation range (0~9999)
Void pronounce_point3num(u16 t) Decimal part of the digital pronunciation range (0~0.999)
Void pronounce_point2num(u8 t) Fractional part digital pronunciation range (0~0.99) HX711 part:
U32 Read_HX711(void) This function reads the amplified value after HX711 is collected.
U32 Sampling(void) This function filters the values ​​of the AD samples back to the arithmetic mean and removes the lowest and highest averages.
Main.c part:
Void UI(void) setting interface
The main function integrates the functions of each module to realize the electronic scale weighing function, TFT display function and so on.
The mechanical Buzzer uses a magnet to move a reed up and down quickly to emit a lower-pitch buzz! It's quieter than the piezoelectric buzzer but uses more power, so you the terminals will have to be closer to the battery packs. To use them, you'll need to match the wire colors to the wires from the battery pack.
Piezo Beeper,Mechanical Buzzer,Piezo Mechanical Buzzer,Low Frequency Mechanical Buzzer
Jiangsu Huawha Electronices Co.,Ltd , https://www.hnbuzzer.com