I have been trying to use this digital 12-bit PWM encoder with my Arduino. Ultimately, I hope to use it with a ESP32 but that is a little more complicated because it requires a logic level shifter, so I decided to first get it to work on a Arduino Uno. When plugged into pin 6, a digital PWM pin, and when running the digitalRead() function, I get values of 0. When plugged into an analog pin and using the analogread () function, I get a small range of numbers from 180 to about 260. On the ESP32, I get a range of numbers from 470-880. The encoder is supposed to output a 4-5v High and a 0.4v low, but the maximum voltage I've been able to measure on the PWM port is 0.7v. What could the issue be?
As described in the data sheet, the shaft position is encoded in the output pulse width.
You will need to use Arduino pulsein() or a similar approach to determine the pulse width, and then appropriately scale the result to arrive at position.
If you have a PWM version of MA3 you need to measure not a voltage but ON and OFF pulses duration and then do a calculations as described at chapter PWM Ou****tput Operation of MA3 datasheet**.**
jremington:
As described in the data sheet, the shaft position is encoded in the output pulse width.
You will need to use Arduino pulsein() or a similar approach to determine the pulse width, and then appropriately scale the result to arrive at position.
I tried this, but am getting values of 0. Am I incorrect in saying that I should be able to see values of 1 when using digitalRead() because PWM is a measurement of a digital signal?
sajivshah:
I tried this, but am getting values of 0. Am I incorrect in saying that I should be able to see values of 1 when using digitalRead() because PWM is a measurement of a digital signal?
You should see a mixed reading of 0s an 1s. If it's always 0 you need to troubleshoot your connections. Do you have an oscilloscope?