0 Preface
Arduino is an electronic product development platform based on a single-chip microcomputer system. Its software and hardware systems are highly modularized, and the software system is completely open source. Its hardware system is also highly modularized. The core control board has switch input/output modules, various analog sensor input modules, bus sensor input modules, and network communication modules [1-2]. Arduino has its own unique programming language. Its syntax rules are similar to those of C/C++ language. The IDE environment and language parameterize and encapsulate some parameters related to the single-chip microcomputer and hardware, package all ports, and basically do not need to care about registers, address pointers, etc., which greatly reduces the difficulty of software development. Therefore, developers do not need to understand its hardware structure to program it and realize the designer's design intent and creativity [3].
This paper proposes a design scheme of photoelectric encoder detector based on Arduino development environment, which can judge the quality of photoelectric encoder and realize the pulse counting of photoelectric encoder during forward and reverse rotation.
1 Overall design
The detector is mainly composed of a conditioning circuit, an Arduino control board, a liquid crystal display circuit, etc., as shown in Figure 1.
CLKA and CLKB are two coded signals with a phase difference of 90° output by the photoelectric encoder. The conditioning circuit is used to perform signal processing such as shaping and filtering on these two signals, and finally send them to the Arduino control board. The Arduino control board is used to count the number of pulses of the optical encoder and distinguish the two pulse signals of forward and reverse rotation. The LCD display circuit is used to display the detected parameters and select and control different types of photoelectric encoders.
2 Hardware Design
2.1 Conditioning Circuit
The signal conditioning circuit is used for the conditioning of detection signals. It mainly sends the AC signal to be measured to the microcontroller for measurement after filtering, amplification, gating, effective value conversion, limiting and other processing.
Figure 2 is a block diagram of the conditioning circuit. The two sinusoidal signals A and B with a phase difference of 90° output by the photoelectric encoder are converted into two groups of square wave signals a and b through the Schmitt trigger. A is divided into two groups: one group passes through the differential circuit to form a pulse signal d at the rising edge of the square wave, which is then output by the gate circuit to form a forward pulse, and the other group passes through the inverter to form an inverted square wave c, which is then formed by the differential circuit to form a pulse signal e. The gate circuit outputs an inverted pulse g. The square wave group B is directly connected to the control end of the two gate circuits as the selection signal of the two gate circuits.
When the photoelectric encoder rotates forward, the signal of group b leads by 90°, and its positive half-wave of square wave corresponds to the rising edge of group a square wave without inverter. The positive half-wave enables the gate circuit, and group d pulses pass through the gate circuit to form a forward pulse; while the rising edge of group c square wave corresponds to the negative half-wave of group b square wave. At this time, although the differential circuit outputs pulse e, the gate circuit is closed and cannot output the inverted pulse g. When the encoder reverses, the situation is just the opposite. The final output pulses are sent to the control detection circuit for counting.
2.2 Arduino Control Board
This detector uses the latest Arduino Due microcontroller developed in Italy. Arduino Due is a microcontroller board based on Atmel SAM3X8ECPU. It is the first Arduino based on 32-bit ARM core. Compared with other Arduinos using 8-bit AVR core, Due using 32-bit ARM core is more powerful: 32-bit core can process 32-bit data in one clock. The control board includes 54 digital I/O pins (including 12 PWM outputs), 12 analog input channels, 2 analog output channels (DAC), and the total output current of I/O port is 130 mA. The output capacity of 3.3 V port is 800 mA, and the output capacity of 5 V port is 800 mA. FLASH 512 KB (all space can store user programs), SRAM96 KB (two parts: 64 KB and 32 KB), the clock rate [4-5] is 84 MHz.
Since the working voltage of Arduino Due is 3.3 V and the voltage that the I/O port can carry is also 3.3 V, the 5 V pulse generated by the conditioning circuit cannot be processed directly. This detector uses the SN74lVC4245 chip to reshape the 5 V pulse into a 3.3 V pulse.
2.3 LCD Display Circuit
This design uses a domestically developed programmable smart LCD (PS-LCD for short). PS-LCD is an intelligent display module that includes an LCD display, LCD controller, touch screen, human-machine interface processing system and communication interface. It is connected to an external control unit (such as 51 single-chip microcomputer, ARM, DSP, PC, PLC, bus equipment, etc.) through an optional communication interface to realize the human-machine interaction interface of the system.
Create a new Designer project, define the interface resolution, interface switching effect and main interface, etc.; set the background, add/set controls, define event actions, etc. PS-LCD uses Java Script, which is the most popular scripting language on the Internet. It exists in all Web browsers around the world and can enhance the interaction between users and Web sites and Web applications. This LCD screen uses scripting to display the number of pulses sent by the microcontroller in real time and make judgments.
Use the LCD simulator to verify the interface effect and communication process, and repeat the previous steps until you are satisfied.
As an advanced intelligent human-machine interface product, PS-LCD can easily and flexibly realize data interaction with external control units through the communication interface. At present, PS-LCD supports two communication protocols: CTP (Cooky Talking Pro-tocol) protocol and User Defined protocol. This detector adopts CTP protocol.
In CTP communication mode, after receiving the communication command, PS-LCD will execute it immediately and return the result to the main controller after completion. Since the serial communication protocol of PS-LCD is inconsistent with the communication protocol of the microcontroller Arduino Due, conversion and control are required during the communication process. In order to cancel the automatic reply message of the PS-LCD command execution result, in CTP communication mode, the automatic reply of PS-LCD is canceled by calling the ctpSet ("reply", 0) function. PS-LCD also controls the operation of the microcontroller through the serial port signal generated by the communication protocol, truly realizing the effect of human-computer interaction [6].
Generate the interface output file spf, and then download the spf file to PS-LCD through the PS-LCD dedicated software tool Flex to verify the final interface effect. [page]
The final detection interface of the detector PS-LCD is shown in Figure 3.
3 Software design
3.1 Pulse counting subroutine
In order to test the pulse more accurately, external interrupts are used for counting. The 54 digital I/O pins of the Arduino Due control board can all be used as interrupt ports. The main counting program written is as follows [7-10]:
3.2 LCD display program
According to the photoelectric encoder to be tested, select different models. Different types of photoelectric encoders define different sending signals. Taking the LBJ-001-2048 photoelectric encoder as an example, the script writing subroutine for selecting the button is as follows:
Among them, sysCom0.write (0×41) is written to the serial port sending buffer, and the serial port sends 1 byte of data 0×41 to the outside, which is the character 'A\'. When the Arduino microcontroller receives the \'A' character sent from the serial port, it can be determined that the photoelectric encoder model to be tested is LBJ-001-2048, and the corresponding program is started for testing. Similarly, when the second model test is selected, the Arduino microcontroller will receive the 'B' character sent from the serial port, and the photoelectric encoder model to be tested can be determined to be SE0932II-5400P/r, and the corresponding program is started for testing.
4 Conclusion
This article focuses on the design of the photoelectric encoder detector based on the Arduino development environment, and realizes the communication control problem between the Arduino microcontroller board and the PS-LCD. Since Arduino is an open single-chip hardware and software platform for developing human-computer interaction products, it has a good reference value for electronic production competitions, electronic artwork creative development, and electronic testing products based on the Arduino development environment.
Previous article:MCU System Reliability Design Solution
Next article:Design of 2D barcode recognition system based on NiosII
Recommended ReadingLatest update time:2024-11-16 21:32
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- EtherCAT: MCU Selection
- Farrow structure filter MATLAB implementation source code and simulation
- [Xianji HPM6750EVKMINI Review] 4# HPM6750 Dual-core Experience
- Goodbye 2019, hello 2020+ There is a European town in Songshan Lake
- PASS F5 Power Amplifier
- CPU card design example and program design--external authentication, card and ESAM common
- Protecting Your IP Cores - Part 1 Soft IP Cores, Chapter 3: Obfuscation of Hardware Design
- R7-4800h R7000, compiling 5.6.18 kernel linux, is make -j8 faster or -j16 faster?
- Ask someone with level 8 Chinese proficiency to explain it to me
- Oscilloscope testing applications in medical equipment