|
|
|
Encoders are used in many applications where there is a mechanical piece that spins. The by now old ball-based computer mice are the typical example that requires the use of optical encoders to measure how the ball rotates. An optical encoder consists of two parts: an optoelectronic device (usually an infrared transceiver) and a wheel with holes that allow/deny IR light to go through
Figure 1 : explosion diagram of an optical encoder by Minimotor SA The IR transceiver has both a transmitter and a receiver that it cuts in a constant basis by the spinning disc. Each time the light is passing to the other side of the wheel, the encoder sends a pulse out. This is the information we can use as input to our microprocessor. In order to know which direction the encoder is rotating towards we have to make use of two different IR-transceivers so that we can detect which one is the first one producing the pulse
Figure 2 : image showing an optical encoder inside a Logitech mouse, by HowStuffWorks While motors are characterized by the speed they can spin with and by the voltage and current they use, encoders are characterized by the ability to detect movement, direction, resolution, and the so-called cross-by-zero Some of the encoders can only detect if the motor is moving but don't have the capability of informing about the direction. As mentioned earlier, when counting with more complex encoders it is possible to determine the direction the system spins to. The resolution in optical encoders is the amount of holes the wheel has. Obviously the more holes it has, the better is the information we get about the device we want to control In an exploratory attempt of mapping the resolution of different encoders we dismounted several printers, cash registers and other electromechanical machines and discovered that most of those devices count with simple encoders that have a resolution between 4 and 50 steps. For our experiments we counted with a motor that had an encoder counting 500 steps. That is quite a lot of steps if we want to detect the position of the motor's shaft Encoders are not giving us information as “the motor is moving to the right at 30rpm and it is right now at 30 degrees from the origin”. It is unfortunately a little bit more complicated than that. They just transmit pulses that we need to capture with our microprocessors. As mentioned earlier, encoders can be informing about the rotation in one direction, in both directions, or inform about the cross-by-zero state. This means that the encoder will send one, two, or more trains of pulses [A “train of pulses” is a digital signal with a series of on and off pulses. One could say e.g. that PWM signals are trains of pulses] Single pin encodersThese are encoders that send one single train of pulses out. These encoders cannot inform about the direction the motor moves, they only relate to the fact that the motor is moving. A typical application is a carriage return in a matrix printer that only advances in one direction. If we are sure about the direction of movement, then we just need a one-pin encoder to measure how much the motor rotated This is not the kind of encoder we want for applications like e.g. an augmented steering-wheel. With the pin encoders we don't know if the motor will be moved to the left or to the right, since the responsible of the initial movement is an external agent out of our control As mentioned earlier, the way this works is through sending pulses through its output pin. Each pulse means one step of the encoder. If we had a four steps encoder (typical for the printer example) then we will be able of measuring one step every fourth of a rotation Double pin encodersIf we want to detect the direction of the rotation, we need to use a double sensor on the encoder. Those sensors, independently if they are optical or magnetic, will send a double train of pulses. The pulses will present a difference in phase. This means that one will arrive before the other. This is what allows distinguishing the direction of the rotation. If it is line A of the encoder sending the first pulse then the motor is spinning in one direction, if it is line B then it goes in the opposite one. This is easy to measure with a microprocessor
Figure 3: two trains of pulses coming from the two sensors of a two-pin encoder; in the first graph pulses arrive first from the A sensor, while in the other graph it goes the opposite way As the figure shows, if we are always monitoring whether pin A is changing from low (false) to high (true), by observing the value of pin B at that very same moment we will be able of knowing if the motor spins towards one direction or the other This is the case we will find most of the times. The problem it presents has to do with too high resolution encoders. Let's say that we have an encoder that is counting 500 steps each revolution. If it was attached to motor rotating at 1000 rpm, this would mean that our encoder would be counting 500.000 pulses per minute (8.333 pulses per second). If we want to be able to measure such an amount of pulses, then we need to have a microprocessor that is checking out the input for the encoder at least 16.000 times per second. This means that, with a prototyping tool like the Wiring board, we have to measure the value at the input once every 1000 instructions (the Wiring board has a clock running at 16MHz and reaches 16 millions of operations per second), and this not very restrictive code-wise We have to be aware of the limitations of our processor boards when dealing with encoders and motors, because they can produce much more data (or much faster) than we could treat. This means, to put it in other words, that we cannot put the motor to spin at 1000 rpm (maximum power) if we want the microprocessor to be able of following the count. It would be better to have a less sensitive encoder then. Anyhow, Wiring has the capability of counting as quick as most of the combinations of motor-encoder we can find in the market, therefore we should not be worried about it Cross by zeroA cross by zero encoder is the one sending a pulse when the motor crosses a reference point. This kind of signal is interesting for applications that require exhaustive counting taking special consideration of the amount of laps. These encoders are more expensive than the previous ones and if the microprocessor is precise enough to count all the steps, the cross by zero feature can be emulated by having an internal counter |