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), SRAM 96 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 effects 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 Protocol) 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.
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 to write 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:Design scheme based on experimental system with dynamic circuit reconfiguration
Next article:Application design of vehicle flow detection system based on magnetoresistive sensor
Recommended ReadingLatest update time:2024-11-23 19:24
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- Vicor high-performance power modules enable the development of low-altitude avionics and EVTOL
- Bourns Launches Two Thick Film Resistor Series with High Power Dissipation Capabilities in Compact TO-220 and DPAK Package Designs
- Bourns Launches New High-Pulse Brake Resistor Series with Superior Energy Dissipation Capabilities
- Nexperia launches new 120 V/4 A half-bridge gate driver to further improve robustness and efficiency in industrial and automotive applications
- Vishay's New 150 V MOSFETs Offer Industry-Leading Power Loss Performance
- The first generation of SGT MOSFET series from Qiangmao: innovative trench technology, automotive-grade 60 VN channel, breakthrough in high-efficiency performance of automotive electronics
- DC/DC Power Supplies for Automotive Applications
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- MSP430FW42X Non-Magnetic Sensor Water Meter Solution
- Error handling in C programming for embedded systems
- C language source program for 6B595 or 74HC595
- RF calculation formula backup one
- How to Redefine the Size of Information Memory and Persistent Memory in FRAM
- 38 electromagnetic compatibility design standard reference circuits
- Digital Intelligent Motor Control Module
- I want to ask if it is a lot of work to implement a calculator with a decimal formula
- PCB board_production process_material_design
- [GD32L233C-START Review] - 6. SPI drives RC522 card swiping