Points A and B correspond to two photosensitive receiving tubes, the distance between points A and B is S2, and the grating spacing of the angle code disk is S0 and S1 respectively.
When the angle encoder rotates at a constant speed, the ratio of S0:S1:S2 in the output waveform is the same as the ratio of S0:S1:S2 in the actual graph. Similarly, when the angle encoder rotates at other constant speeds, the ratio of S0:S1:S2 in the output waveform is the same as the ratio of S0:S1:S2 in the actual graph. If the angle encoder performs variable speed motion, it is considered as a combination of multiple motion cycles (defined below), then the ratio of S0:S1:S2 in the output waveform in each motion cycle is still the same as the ratio of S0:S1:S2 in the actual graph.
From the output waveform, we can see that the timing of each motion cycle is
Clockwise movementCounterclockwise movementAB
AB
1 1 11
0 1 10
0 0 00
1 0 01
We save the current A and B output values and compare them with the next A and B output values to easily get the movement direction of the angle encoder.
If the grating grid S0 is equal to S1, that is, the radian angle of S0 and S1 is the same, and S2 is equal to 1/2 of S0, then the displacement angle of the angular encoder movement is 1/2 of the radian angle of S0, and divided by the time consumed, the angular velocity of the angular encoder movement is obtained.
When S0 is equal to S1, and S2 is equal to 1/2 of S0, the movement direction and displacement angle can be obtained in 1/4 movement cycle. If S0 is not equal to S1, and S2 is not equal to 1/2 of S0, then 1 movement cycle is required to obtain the movement direction and displacement angle. Hereis a mechanical rotary encoder detection program written in 51.
#define WA = PX.X
#define WB = Py.y
void encoder(void)
{
unsigned char i,j;
static unsigned char ta,tb;
TR1 = 0;
i = WA;
j = WB;
if((i^j)&&(ta&tb))
{
if((i == 1)&&(j ==0))
{
count++;
}
else if((i == 0)&&(j == 1))
{
count--;
}
}
Previous article:Several necessary steps to learn MCU in depth
Next article:The difference between MCU in-circuit emulator and in-circuit programmer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- 【AD21】The mouse cannot be moved to the left and bottom of the PCB origin. What is the solution?
- 2021 ON Semiconductor Avnet RSL10 Bluetooth SoC Development and Design Competition Second Post (Initial Modification Routine)
- CC2531 Zlight2 Reference Design
- Fundamentals of Electronic Design (Huang Genchun)
- MSP430g2553 hardware UART (modification based on official routines)
- [TI recommended course] #Innovation of general-purpose op amp and comparator chips#
- Recently, I am doing an experiment on communication between DSP and AD5390. DSP controls AD5390 through SPI bus. I am not familiar with the core of AD5390.
- A new year and a new beginning. I wish you all a happy New Year!
- 【Project source code】 Analysis of blocking assignment and non-blocking assignment principles
- Please give a comprehensive analysis of the advantages and disadvantages of i.MX8QuadMAX and RK3399PRO