Design of rotary encoder acquisition module based on CAN bus

Publisher:精品古钱斋Latest update time:2015-05-21 Source: dzsc Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    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, generating 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 standard 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.

    Figure 1 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.

    Figure 2 One of the rotary encoder acquisition circuits.

    By analyzing the circuit, we can know 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. [page]

    Figure 3 Rotary encoder acquisition circuit simulation waveform

    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.

    Figure 4 CAN transceiver circuit

    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.

    Figure 5 Power supply circuit

    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.

    Figure 6 Main program flow chart

    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.

Reference address:Design of rotary encoder acquisition module based on CAN bus

Previous article:I2C bus PTZ motor control design in high-definition video surveillance
Next article:Feiling OK6410 timer accurately controls LED

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号