Preparing to Add a Shaft Encoder to Arduino Fio

The Arduino Fio is a 3.3V board, but the MA3 Shaft Encoder uses 5V. To compensate, I needed to step up the voltage for input, but then step down the output to the Fio input.

I didn’t know exactly how to do this, so I started simple and worked my way up.

Getting 3.3V out of a 5V input

First, I wanted to get 3.3V out of an input of 5V. This would be the part connecting the encoder output to the Fio input.

My Arduino Uno board can output 5V or 3.3V, so it served as my power source. In my images here I have just represented a generic power source to keep the diagrams simple.

Through research, I determined that I would need to build a voltage divider, which uses the formula: Vout = Vin * (R2 / (R1 + R2))
R1 is the resistance between the input and the output, and R2 is the resistance between the output and the ground. Since my desired Vout is 3.3 and my Vin is 5, I was looking for resistors where R1 was half the resistance of R2.

Since the ratio between the resistors is key, I could have used resistors with large or small resistance. In voltage dividers, the smaller the overall resistance the more accurate the output, the tradeoff is that more energy would be wasted. Since I am using battery power, but also care about accuracy, I wanted something in between. This post describes it pretty well.

Also, the formula assumes a perfect environment where the only resistance is on the resistors. In my circuit, the current drawn from the input pin would reduce the ratio between the resistors.

I am using PWM input, which is measuring the time between the peaks in voltage, so it isn’t super critical that I have exactly 3.3V. Based on this post I went with an 18k and 33k resistor, which should give me a peak around 3.23V.

I built the circuit shown in Schematic 1.

Using my multimeter I measured

  • 5V between the 5V input and ground
  • 3.3V between A and ground
5V to 3.3V Schematic
Schematic 1: 5V to 3.3V at “A”

Suppling 5V power to encoder, with 3.3V output

My next step was to add the encoder to the circuit to make sure it could receive 5V of power, but have the output reduced to 3.3V.

Schematic 2 shows the circuit, though I am not sure that the image used for the encoder is appropriate.

I measured

  • 5V between the 5V input and ground
  • Max 3.15V between A and ground (depending on position of encoder)
5V to encoder to 3.3V Schematic
Schematic 2: 5V Encoder input with 3.3V output at “A”

When I first measured at A, it was a lot less than 3.3V. I then turned the encoder and found that I could increase the voltage up to 3.15V. The encoder is using PWM and the voltage should be jumping between 0 and 3.15V with varying spaces between the highs and lows. My multimeter must average the voltage it is receiving, rather than show the peak.

I think the 3.15V is probably due to variations in individual resistors.

3.3V input, stepped up to 5V, with a 3.3V output

My final step before moving to the Fio was to use my 5V step up board to take a 3.3V input and output 5V to the encoder.

Schematic 3 shows the circuit I used. The part number on the step up should be NCP1402, not 1400.

I measured

  • 5V between the input to the encoder and the ground.
  • 5V between left side of R1 and ground.
  • Max 3.15V between A and ground (depending on position of encoder)

Step up and encoder schematic

Schematic 3: 3.3V input, stepped up to 5V for encoder, with output reduced to 3.3V at “A”.

Next Step:

Connecting the Shaft Encoder to Fio

Leave a Reply

Your email address will not be published. Required fields are marked *

15 − 9 =