Share this

Design of a Product Quantity Counting System Based on Infrared Technology

2026-04-06 06:42:00 · · #1

Abstract : A product quantity counting system was designed based on the MSP430F149 microcontroller and an infrared module. The hardware and software design of the system are described in detail. Utilizing the low power consumption of the microcontroller and the single-wire interface of the infrared module, the entire system achieves low power consumption, exhibiting a simple structure, stable performance, and cost-effectiveness.

Keywords : microcontroller; infrared transmitting module; infrared receiving module

0. Introduction

In industrial automated production, it is necessary to statistically analyze the production quantity of products to measure the overall production system efficiency. Traditional methods primarily involve manual recording of production data in the later stages of production, which not only wastes significant human and material resources but also suffers from time lag. Furthermore, in highly automated industrial settings, manual counting of product quantities is impractical. This paper proposes a product quantity counting system based on microcontroller and infrared technology. This system can easily achieve real-time product quantity statistics and can communicate with a host computer for data report generation and printing. The system boasts advantages such as strong anti-interference capabilities and high statistical accuracy.

1. System Overall Design

The system uses the high-performance, low-power MSP430F149 microcontroller as its core controller, integrating an infrared transmitting module, an infrared receiving module, a data storage device, an RS232 interface, and a power supply module. The microcontroller is responsible for processing and recording various data, storing the processed data, and transmitting the recorded data to the host computer via the RS232 interface. The infrared transmitting and receiving modules primarily detect the quantity of products passing through the production line and notify the microcontroller to record the quantity. The power supply module uses an LM2574 step-down DC-DC power converter to provide the necessary power for the entire system. The system block diagram is shown in Figure 1.

Figure 1 System structure block diagram

Fig . 1The block diagram of the system

2. System Hardware Design

The hardware circuit design uses MSP430F149 as the core controller [1]. The P1 port ( P1.0 ) outputs a PWM signal to drive the infrared transmitter module; the P1 port ( P1.1 ) is connected to the signal output pin of the external infrared receiver module; the general serial port UATR0 ( P3.4 , P3.5 ) is connected to RS232 to communicate with the host computer; P3.6 , P3.7 are analog serial communication interfaces to transmit data with the memory; LM2574 provides a 3.3V working voltage for the system. The system hardware circuit diagram is shown in Figure 2.

Figure 2 System hardware circuit diagram

Fig . 2The hardware circuit of system

2. 1MSP430F149 microcontroller

The MCU uses Texas Instruments' (TI) MSP430F149 microcontroller [1]. This microcontroller is an ultra-low power microcontroller with a 16-bit architecture, 16-bit CPU integrated registers and constant generator, which maximizes code efficiency. It includes two built-in 16-bit timers, a fast 12-bit A/D converter, two general-purpose serial synchronous asynchronous communication interfaces and 48 I/O ports.

Here are some of its key features: Low power supply input range: DC 1.8 ~ 3.6V ; Ultra-low power consumption: 2.5uA@4kHz , 2.2V ; Five power-saving modes; Wake-up time less than 6µs; 12-bit 200Ksps A/D converter with built-in sample-and-hold; One serial communication interface for asynchronous or synchronous communication modes; Six 8-bit parallel ports; On-chip 60KB FLASHROM and 2K RAM; Two general-purpose 16-bit timers and an on-chip temperature sensor.

The microcontroller is the core controller of the entire system, responsible for product quantity statistics, storage, infrared module control, and communication with the host computer.

2.2 Infrared Emitting Module

The infrared emitting diode LF5038 is used as the infrared signal emitting device of the emitting module . Its electrical parameters are as follows: peak wavelength is 940nm; forward working voltage VF is 1.2V ; forward drive current IF maximum value is 100mA; generally speaking, the larger the IF, the farther the infrared emission distance [2].

Since the infrared receiver module can only receive carrier frequencies of 38kHz, the infrared transmitter module needs to transmit signals with a 38kHz carrier. The MSP430F149 microcontroller has internal PWM output control, making it easy to set the carrier signal. However, the microcontroller's pin output drive capability is limited. To increase the transmitter module's transmission distance, an external transistor driver circuit is used to increase the forward current IF of the transmitter module, thereby improving the transmission distance. The infrared transmitter driver circuit is shown in Figure 3a.

2.3 Infrared Receiver Module

The infrared receiver module uses LF0038F, and its performance parameters are as follows: the typical value of the carrier frequency that can be received is 38kHz; when the forward current of the infrared transmitter module is 300mA, the minimum receiving distance of LF0038F is 15m; the typical value of the receiving angle is ±45º[3].

The infrared receiver module has strict requirements for the power supply. To prevent the occurrence of erroneous output signals, its input power supply is subjected to multi-level anti-interference and filtering processing. The circuit diagram of the infrared receiver module is shown in Figure 3b.

Figure 3 Schematic diagram of infrared transmitter and receiver module

Fig . 3Infraredtransmitandreceivemoduleprinciplediagram

The microcontroller's PWM output drives the infrared transmitting module to emit a 38kHz pulse signal. When the LF0038F does not receive a valid signal, the OUT terminal outputs a high-level signal; when the LF0038F receives a valid signal, the OUT terminal outputs a low-level signal. During this transition from high to low level, a falling edge signal is generated. The waveform of the LF0038F output signal is shown in Figure 4.

Figure 4 Signal waveform diagram

Fig . 4 Signal waveform figure

2.3 Power Module

The system uses the LM2574 high-performance voltage converter to provide the operating voltage. The LM2574's technical parameters are as follows: wide input voltage range (DC7V-DC40V); the chip can output a fixed or adjustable voltage; maximum output current of 0.5A ; simple peripheral circuitry requiring only four external electronic components; built-in fixed-frequency (52kHz) oscillator; high conversion efficiency; and overheat and overload protection.

3. System Software Design

To facilitate system maintenance and upgrades, the system software design adopts a modular program structure, mainly consisting of a main program, a PWM signal generation program, a product quantity statistics program, and a data transmission program.

3.1 Main Program Functions

The main program is responsible for initialization, enabling interrupts, and guiding the system into various corresponding working states. The flowchart of the main program is shown in Figure 5a.

Figure 5 Program Flowchart

Fig . 5 ProgramFlowDiagram

3.2 Product Quantity Statistics Procedure

After system initialization, the program enables PWM output, driving the infrared module to emit a 38kHz pulse signal. The system uses a reflective monitoring method to detect product passage. When no product passes through the production line, the LF0038F does not receive the infrared pulse signal and outputs a high-level signal at the OUT terminal. When a product passes through the production line, the pulse signal emitted by the infrared module is reflected back by the passing product, and the receiving module receives the pulse signal. The LF0038F output signal changes from high to low, and the falling edge triggers a microcontroller interrupt. The program then enters the product passage detection and judgment stage. After the microcontroller processes the data and confirms that a product has passed, the system records the product passage. After a product passes, the microcontroller will promptly notify the host computer of the change in product quantity to update the product quantity. The product quantity statistics program is shown in Figure 5b.

3.3 System Communication Program with Host Computer

To enable normal communication between the system and the host computer, the format of the data information sent by the counting system to the host computer needs to be defined. The data information sent by the counting system to the host computer includes: information code (1 byte), information data (the number of bytes varies depending on the data type), checksum (1 byte, this value is the XOR of all bytes), and information end marker (1 byte). The data information format is shown in Table 1.

Table 1 Data Information Format

Tab . 1Thedatainformationformat

When the product quantity counted by the counting system changes, it promptly sends data to the host computer. The data format for sending data to the host computer is shown in Table 2. Information code "1" represents a command from the counting system to send data to the host computer, with 1 byte; the data range is 00~65536, with 2 bytes, representing the product quantity; the checksum is an XOR operation of the byte values, with 1 byte; the end flag "#" has 1 byte. The flowchart for sending data to the host computer is shown in 5c.

Table 2. Format of data information sent from the system to the host computer

Tab . 2Thedataformatsendtouppermachinefromsystem

content

byte count

meaning

Information Code

1

1

Data Information

2

Product Quantity

Checksum

1

XOR the values ​​of each byte

End mark

1

'#'

4. Conclusion

Infrared technology is a new and rapidly developing discipline, giving rise to a wide variety of infrared devices with applications spanning civilian and military industries. The system's hardware and software employ a modular design, facilitating upgrades and maintenance. After online testing, the acquired data has proven to be accurate and reliable, providing a novel device for product statistics in automated production lines. It avoids the drawbacks of traditional manual statistics, demonstrating significant potential for widespread adoption and promising application prospects.

Read next

CATDOLL 139CM Yuan (TPE Body with Soft Silicone Head)

Height: 139cm Weight: 23kg Shoulder Width: 33cm Bust/Waist/Hip: 61/56/69cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22
CATDOLL Kara TPE Head

CATDOLL Kara TPE Head

Articles
2026-02-22
CATDOLL 135CM Laura

CATDOLL 135CM Laura

Articles
2026-02-22
CATDOLL 108CM Maruko

CATDOLL 108CM Maruko

Articles
2026-02-22