encoder troubles

I am trying to read the output from a MA3 encoder (link below) it is a 10-bit version.


I have the basic idea of how this should be done through arduino code, but maybe I am missing something. All I want to do is read the values coming off of the encoder through the serial monitor. Seems straight forward, but when I run the code I the number changes from 300-360 randomly without any motion of the shaft. My code is pasted below.

int enc = 10; int x = 0;

void setup() { pinMode(enc, INPUT); Serial.begin(9600);


void loop() { x = analogRead(enc); Serial.println(x); delay(1000);


Any help would be much appreciated. I am doing this basic code so I can know how to construct the LabView code which will be used in a larger project I am working on. Thanks.

10-bit pwm or analog output?

I am using the 10-bit PWM version

Then you need to add a suitable low-pass filter. analogRead() cannot read PWM signals, only true analog voltages.


measure the duty-cycle of the signal using the pulseIn() function.

Ok great! That worked, thanks. It is now outputting a value between 0 and 1023 which is what the datasheet on the encoder prescribes. This was done using the pulseIn() function. LabView doesn’t have an arduino vi for pulseIn(), but thats a problem for another forum I suppose.

Hello, I need to read the position of an antenna with the MA3 . As 've implemented encoder reading ? Thank you