The angular displacement sensor is an electronic component that uses the angle change to locate the position of the object. It is suitable for servo systems of automobiles, engineering machinery, space devices, missiles, aircraft radar antennas, as well as injection molding machines, woodworking machinery, printing machines, electronic rulers, robots, engineering monitoring, computercontrolled motion instruments and other occasions requiring accurate displacement measurement. This paper introduces the principle of angular displacement sensor and its application example.
Principle of angular displacement sensor
The angle sensor is used to detect the angle. It has a hole in its body that fits the LEGO axis. When connected to the RCX, the angle sensor counts every 1 / 16 turn of the shaft. When rotating in one direction, the count increases, and when the rotation direction changes, the count decreases. The count is related to the initial position of the angle sensor. When initializing the angle sensor, its count value is set to 0. If necessary, you can reset it by programming.
Example of angular displacement sensor
If the angle sensor is connected to any transmission shaft between the motor and the wheel, the correct transmission ratio must be calculated into the read data. Give an example of calculation. On your robot, the motor is connected to the main wheel with a transmission ratio of 3:1. The angle sensor is directly connected to the motor. Therefore, its transmission ratio with the driving wheel is also 3:1. In other words, the angle sensor rotates for three weeks and the active wheel rotates for one week. The angle sensor counts 16 units per revolution, so 16 * 3 = 48 increments are equivalent to one revolution of the driving wheel. Now, we need to know the circumference of the gear to calculate the travel distance. Fortunately, the tire of each LEGO gear is marked with its own diameter. We chose the largest axle wheel with a diameter of 81.6cm (Lego uses metric units), so its circumference is 81.6 × π=81.6 × 3.14≈256.22CM。 Now we have all the known quantities: the running distance of the gear is divided by the recorded increment of the angle from 48, and then multiplied by 256. Let's summarize. R is called the resolution of the angle sensor (count value per revolution), and G is the transmission ratio between the angle sensor and the gear. We define I as the increment of the angle sensor when the wheel rotates for one cycle. Namely:
I=G × R
In the example, G is 3 and R is always 16 for LEGO angle sensor Therefore, we can get:
I=3 × 16=48
Every time you rotate, the distance the gear goes through is its circumference C. using this equation, using its diameter, you can come to this conclusion.
C=D × π
In our example:
C=81.6 × 3.14=256.22
The last step is to convert the data recorded by the sensor  s into the distance of wheel movement  t, using the following equation:
T=S × C/I
If the value read by the photoelectric sensor is 296, you can calculate the corresponding distance:
T=296 × 256.22/48 = 1580 the unit of distance (T) is the same as that of wheel diameter.
Practical application of angular displacement sensor
Using angle sensors to control your wheels can indirectly detect obstacles. The principle is very simple: if the motor angle sensor structure works and the gear doesn't rotate, your machine has been blocked by obstacles. This technology is very simple to use and very effective; The only requirement is that the moving wheels can't slip on the floor (or slip too many times), otherwise you won't be able to detect obstacles. If an idle gear is connected to the motor, this problem can be avoided. The wheel is not driven by the motor, but driven by the movement of the device: during the rotation of the driving wheel, if the idler stops, it means you have encountered an obstacle.
In many cases, angle sensors are very useful: controlling the position of arms, head and other movable parts. Note that when the running speed is too slow or too fast, RCX will be affected in terms of accurate detection and counting. In fact, the problem is not RCX, but its operating system. If the speed exceeds its specified range, RCX will lose some data. Steve Baker has proved through experiments that the rotating speed between 50 and 300 revolutions per minute is a more appropriate range, and there will be no data loss within this range. However, in the range of less than 12rpm or more than 1400rm, some data will be lost. In the range of 12rpm to 50rpm or 300rpm to 1400rpm, RCX also occasionally has the problem of data loss.
