Design of photoelectric encoder detector based on Arduino development environment

Publisher:ananan一二三四五Latest update time:2014-04-10 Source: 21ICKeywords:Arduino Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:Arduino Reference address:Design of photoelectric encoder detector based on 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

Application of Proteus and Arduino integration in single chip system development
  1. Introduction   Arduino is a convenient, flexible and easy-to-use open source electronic prototyping platform with the advantages of rich interfaces, simple programming environment, high degree of freedom and strong scalability. It is based on the AVR platform, recompiles and packages the AVR library, and packag
[Microcontroller]
Application of Proteus and Arduino integration in single chip system development
How to Make a Touch Capacitive Piano Using Arduino
This tutorial is going to be very exciting for electronics makers as we will be designing our very own touch controlled capacitive piano using Arduino Nano. We will be adding recording and playback features to our piano. So far we have made a few piano projects using Arduino but this project is completely different
[Embedded]
How to Make a Touch Capacitive Piano Using Arduino
Engineers must learn DIY: Use Arduino to build a unique multimeter
  ——This article is selected from the May "Test and Measurement Special Issue"   Design requirements: This project can use Arduino Uno or Duemilanove board, with three design modes:   · Single - Measurement data can be viewed on character or graphic LCD display modules.   Connections - You can use the Arduino IDE ser
[Test Measurement]
Engineers must learn DIY: Use Arduino to build a unique multimeter
Latest Power Management Articles
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号