Rotary encoder use process2021
Rotary encoder use process2021
The rotary encoder rotates and sends out pulse signals for the device to calculate speed, angle, displacement, and distance. It is suitable for many fields. Regarding the use of rotary encoders, here are a few necessary rotary encoder use procedures to facilitate everyone's operation use.

One, modify the driver
Rotary encoder is a precision instrument. It needs to issue instructions through the program during its use to play a specific role. According to the needs of different environments, different drivers need to be set, so the effect of the encoder is determined. It is very important to modify the appropriate driver. Under normal circumstances, just modify the reg file directly, register a table file at the same time, use the method of adding to rewrite the dynamic link, in the case where it is determined that the dynamic link has been modified, it needs to be added to the kernel;
2. Hardware interface connection
After the driver is modified, the following is the hardware interface connection operation. In the connection, there are usually two collector output interfaces A and B. In order to ensure the line connection, you need to operate on a resistor on 3.3V. Connect A and B The two interfaces are plugged into the CPU respectively. After the hardware interface is successfully connected, just in case, you must do a test to check whether the high and low voltage values of the voltage output terminal are correct. For example, after pressing the button, if the P2 port output value is high, the connection is correct;
Three, the preparation of the stream interface driver
The writing of the stream interface driver is to prepare for the following interrupt service program. The specific writing step is to create a thread to record the value of the variable, and at the same time record whether the value of each port is still high in the case of a line interruption;
Fourth, the preparation of the terminal service program
The terminal service program is mainly used to protect the encoder circuit, and the interrupt service program is written on this basis by initializing the I/O interface of the CPU.