How do rotary encoders work

How do rotary encoders work

Rotary encoders are the type of encoder that is often used in volume control. You can find them on everything from your car radio to some household objects like some electric kettles, blenders, and microwaves. This article goes over what a rotary encoder is, how it works and how they are designed.

What is Rotary Encoder?

Rotary encoders are rotary switches where the position of the switch determines how a motor will function. In a typical motor, there are two coils of wire attached to two small magnets on either side.

These two coils of wire are placed on top of the magnets and spin side-to-side. When a motor is switched on, a voltage is sent through the coils, and it spins the magnets in one direction or another depending on which side of the switch is connected to power.

In this simple example, you can imagine that if you had 12-volt batteries around your wheel, then when you turned your wheel forwards, it would apply 12 volts to both sides of these coils. If you spun the wheel to the left, it would apply 12 volts to one side of the coil and 0 volts to the other.

When you connect a rotary encoder, it works by taking advantage of this phenomenon. The most basic rotary encoder is two magnets and two coils that will spin as you turn a dial.

When these coils spin with respect to these magnets, they generate a voltage which is then interpreted as a binary number (0 or 1). It can be calculated easily how many ticks you have turned your knob based on the number of voltages generated by each side as they spin past each other (Pictured below)

See also  Best Ways to Fix a 100% Disk Usage on Windows 10

The different positions represent different positions in binary, and thus these devices are essentially binary counters.

How do Rotary Encoders work?

To make a rotary encoder, you need to take a coil of wire and attach it to the magnet, with one end connected to the switch and the other end connected to a small potentiometer. If you connect the switch to 12 volts, then as you turn your knob around counterclockwise, you will generate a voltage that goes through this potentiometer that tells your program how far it has turned.

In this way, your knob can detect how far it is turned, and thus it can also tell what the position of the knob is.

Some encoders have a buffer chip that works with the potentiometer to help smooth out any vibrations in the knob or potentiometer. This helps to make it easier for your code to interpret the signal correctly.

The role of rotary encoders 

Rotary encoders are used in a lot of different electronics. One of the more common uses for rotary encoders is the volume control. If you have a stereo, car radio, or even a TV, you will see that there is a dial on the device that allows you to adjust the volume up and down.

In most situations, this is actually a rotary encoder adjusting how much power gets sent to the speakers. By turning this knob around clockwise, you will increase the volume, and turning it counterclockwise will decrease it.

How to Use Rotary Encoders?

Now that you know what rotary encoders are made of, how does one go about using them?

See also  A VPN allows access to Hulu from abroad, but how do you sign up for Hulu outside the US?

To use a rotary encoder, you need to follow these five steps:

  1. The first thing you need to do is calibrate the potentiometer. If your potentiometer is not perfectly calibrated, it can throw off your readings and cause your motor to spin the wrong way. To fix this problem, you need to connect three resistors in line with your power source.
  2. Next, you will want to initialize the pins as inputs and set up a timer for each one.
  3. Now, you want to write some code. The first thing you’ll want to do is also set some variables to store some values for later use.
  4. You will then want to initialize your state machine.
  5. Here, each rotary encoder pin is initialized with the initial count of the wheel. This is where your wheel will start out when you first initialize your motors. This also stores the current wheel position, which will be read by your program later on in this process.
  6. Lastly, you will want to determine how many ticks have passed by checking the wheel position against these variables and storing this in a variable called counts.

Applications of Rotary Encoders

Rotary encoders are useful no matter what type of application you need. You can find them all over the place and in almost every application that requires a rotary switch. Some examples of these would be:

  • Volume Control(Featuring rotary encoder with audio jack).
  • Dimmer switches.
  • Speed Control of Motors/Pumps.
  • Navigation Controls on boats, airplanes, and cars.
  • CD player controls.  

A typical car radio uses a rotary encoder to control the volume, seek controls, and some even have rotate buttons for changing preset stations.

See also  Cutting-Edge Reasons to Utilize 3d Scanning Technology

Advantages of Rotary Encoders

Rotary encoders are generally well designed and reliable, meaning they are well suited to the task at hand. Their small size also makes them ideal for applications where space is at a premium.

They are available in every possible type of application you would want to use them in, but keep in mind that they require a special circuit to work with.

Disadvantages of Rotary Encoders

While rotary encoders are great for most applications, they do have some minor downsides that may make them unsuitable for your application. Their main disadvantage is their price tag. These encoders can get quite expensive, so if you are on a budget, you may want to consider other alternatives.

They also consume power when they are generating signals to be read by your program, which can quickly drain your batteries in the case of wireless applications. They also transmit signals through the air, which other interferences can intercept if they aren’t properly shielded.

Lastly, while rotary encoders are great in most applications, there is one application where it does not work that well: precision positioning control.

Rotary Encoders vs Analog Switches

There are two main types of rotary switches that you might come across, mechanical and electronic.

Mechanical rotary switches have a shaft that slides between two magnets that spin around it according to the position of a switch plate. With mechanical switches, there are no electronics involved. All the electronics are in the coil of the wire itself.

Electronic rotary switches, on the other hand, use a coil of wire and magnets to form a circuit that generates a signal. They don’t need any sensors or controllers to provide input or output.

Leave a Reply