With the improvement of industrial production automation level, various sensors are being used more and more. As a sensor for speed and displacement feedback, rotary encoders are mainly used in CNC machine tools, high-precision closed-loop speed control systems, servo motors, asynchronous motors, stepper motors, elevator traction machines, elevator door machines and even mechanical axes, which require automatic control of motion speed and displacement information feedback to ensure high-precision and stable operation of the machinery, thereby improving production efficiency and ensuring safe operation.
Aiming at the application of rotary encoders in industrial sites, this paper designs a rotary encoder acquisition module based on the LPCI768 hardware platform. The module has high-precision analysis, shaping, and decoding circuits inside, which can analyze and decode 2 encoder input signals at the same time. The processed rotation signal is collected and digitally filtered by a high-performance processor. The rotary encoder also calculates the angular velocity of the 2 encoder signals. Finally, the module sends the collected rotation position value and angular velocity value to the DPU (distributed processing unit) through the CAN bus for use in industrial sites.
1 Rotary encoder
A rotary encoder is a sensor that measures the movement of a rotating part. It converts the mechanical displacement of the rotation into an electrical signal, and then processes the signal to detect position, speed, etc. The so-called encoding is actually the process of converting the information of the rotation angle into an electrical signal that can be read by a single-chip microcomputer. Rotary encoders can be divided into three types according to their working principles: contact, photoelectric, and electromagnetic. According to the form of the output signal, they can be divided into incremental and absolute values. Among them, the incremental encoder is the most commonly used encoder in industry.
The incremental encoder includes a code disk, a light-emitting element, a receiving element, and a signal processing part. When the shaft rotates, the code disk is driven to rotate, so that the engraved lines are transparent and the intervals are not transparent. The transmitted light is received by the receiving element and input into the signal processing part to generate a pulse signal output. The output signal generally includes two phases A and B (with a phase difference of 90°). Some encoders will also output a zero pulse Z for each revolution as a mechanical reference zero position. When the spindle rotates clockwise, the A channel signal is located before the B channel; when the spindle rotates counterclockwise, the A channel signal is located after the B channel, so it can be determined whether the spindle is rotating forward or reverse.
2 CAN bus
CAN bus (Controller Area Network) is one of the most widely used field buses in the world. CAN bus was originally developed by Bosch in Germany for automotive applications in 1983. It is a serial communication network that can effectively support distributed control and real-time control and belongs to the category of field bus. With the continuous improvement and development of CAN bus, it has been adopted as an international standard by international standards organizations.
CAN bus is a multi-master serial communication bus. The basic design specifications require a high bit rate and high anti-interference performance, and the ability to detect any errors. When the signal transmission distance reaches 10 km, it can still provide a data transmission rate of up to 5kb/s. After being standardized by ISO, the CAN protocol has two standards: ISO11898 and ISO11519. The difference between the two lies in the different definitions of the physical layer. ISO11898 is a CAN high-speed communication standard with a communication speed of 125 kb/s---1 Mb/s, while ISO11519 is a CAN low-speed communication standard with a communication speed of less than 125 kb/s.
3 Hardware Design
According to the system function requirements, this paper selects the LPCI768 processor produced by NXP. This processor is a 32-bit processor based on the ARMCortex--M3 core. It has 3 pipelines and Harvard structure, with independent local instruction and data buses and a slightly lower performance third bus for peripherals. It also includes an internal prefetch unit that supports random rotation and can operate at a frequency of up to 100MHz. The peripheral components of the LPCI768 processor include up to 512 kB of Flash memory, 64 kB of data memory, 4 general timers, 8-channel 12-bit ADC, 10-bit DAC, motor control PWM, 4 UARTs, 2 CAN channels, ultra-low power RTC with independent battery power supply, and up to 70 general I/0 pins. Figure 1 is the overall block diagram of the rotary encoder acquisition module.
3.1 CPU part
According to the chip manual, LPCI768 can select the internal RC oscillator or the main oscillator as the system clock source. However, since the accuracy of the internal RC oscillator cannot meet the requirements of CAN bus communication, and the main oscillator can work in the frequency range of 1 MHz to 25 MHz, a 12 MHz crystal oscillator plus a 22 pF capacitor is selected to form a Pierce oscillator as the clock source of the main oscillator. Since the A/D module of the chip is not used in this system, VDDA can be connected to 3.3V together with VDD, and a 0.1uF decoupling capacitor needs to be connected between each pair of VDD and GND pins. At the same time, JTAG and communication pins are connected to VDD through a 10k pull-up resistor to improve the stability of signal transmission.
3.2 Rotary encoder acquisition part
When the rotary encoder is used for angle positioning or measurement, the shaking of the rotating shaft may cause the encoder output waveform to shake, thus causing miscounting. In this case, the waveform cannot be counted correctly. This system uses a monostable trigger to eliminate the jitter of the rotary encoder output pulse signal. Figure 2 shows one of the rotary encoder acquisition circuits.
By analyzing the circuit, we can see that when the rotary encoder rotates forward, F1 outputs a pulse sequence, and when the rotary encoder rotates reversely, R1 outputs a closed pulse sequence. The circuit simulation waveform is shown in Figure 3.
3.3 CAN bus communication part
The LPC1768 processor supports the CAN 2.0B specification and is compatible with the IS011898-1 standard. Based on this, this paper selects the PCA82C250 chip produced by Philips Semiconductors as the CAN bus transceiver, and the communication matching resistor is selected as 120 , i1. The CAN transceiver circuit is shown in Figure 4.
3.4 Power supply
The operating voltage of LPC1768 is 3.3 V, while the voltage of CAN transceiver and rotary encoder acquisition circuit is 5 V, so MC33063 is used to reduce the input voltage to 5 V for related circuits, and then LM1117-3.3V is used to reduce the 5 V voltage to 3.3 V as the processor operating voltage. The power supply circuit is shown in Figure 5.
4 Software Design
The system uses RealView MDK-ARM V4.10 as the development platform and C language as the main development language. The program is mainly divided into three parts: the rotary encoder acquisition part uses the interrupt method to complete the counting of the input pulse signal through the timing capture unit of LPC1768; the CAN communication part also uses the interrupt method to monitor the commands from the DPU or other control host, and then execute the corresponding data transmission task; and the main program uses a certain time scheduling algorithm to complete the judgment of the rotary encoder's rotation direction, the calculation of the angular velocity, and the setting of the corresponding indicator light status, handle abnormal conditions in the CAN communication process, and feed the dog. The main program flow chart is shown in Figure 6.
5 Conclusion
The rotary encoder acquisition module designed in this paper is suitable for various industrial control sites and has a broad application prospect. After preliminary laboratory verification and application in an industrial field test, the module's processing results for the rotary encoder input signal meet user requirements, and can reliably communicate with the field control system, with stable working performance, strong anti-interference ability and high security.
Previous article:Detailed analysis of the characteristics and differences of MCU, ARM, and FPGA embedded
Next article:Fingerprint recognition system circuit design diagram
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [Xianji HPM6750 Review] + Software simulation IIC reads the temperature and humidity sensor values
- In fact, Valentine's Day 20200214 was cancelled
- This problem occurs when setting up the stm8 environment. What is the reason? Thank you
- dsp28335 data space
- [Xianji HPM6750 Review 8] Detailed description of the small twists and turns encountered by SPI peripherals
- MSP430 MCU Development Record (16)
- I posted a thread about icebabycool. He didn't answer the question but laughed at me instead of showing my low IQ. Please punish this kind of rogue behavior severely.
- Help with POE design issues
- [Voice and vision module based on ESP32S3] Material unpacking—ESP32S3 BOX
- PCBA intelligent detection fixture, one-click generation of test reports