How to measure angles larger than 360 degrees by MA3 encoder?

I am using ma3 absolute encoder (analog output version) from this link. I want to know if there is any way to measure an angle larger than 360 degrees by this encoder?

1 Like

Could you elaborate on how exactly an angle IRL can be larger than 360 degrees? There might be a much simpler solution to your problem.

Not directly that I know of. I think you’d have to do something in software to handle the angle “roll over” from 360-0 or 0-360.

Though I’ve never had to do it, possible way is to always just look at the change in reading from previous loop to current loop and accumulate it, with special logic to handle the rollover case.

For Example:

If you saw 53 degrees last loop and 56 degrees this loop, add 3 degrees to your accumlator

If you saw 1 degree last loop and 359 degrees this loop, subtract 2.

EDIT: Bonus points: who can spot a simple way this algorithm breaks (hint: it’s related to Nyquist criteria) ?


This is about at 405 degree rotation.

Hmm, yes I get what he’s trying to say, but why would you count the value as 405 for on purpose? 45 would do just fine right? Genuinely curious.

Think about it in terms of drivetrain wheels. A 45 degree rotation is does not produce the same effect as a 405 degree rotation.

That being said, I don’t actually know what the physical mechanism is. I just know it could matter, so I assume it does.

Completely missed the part about it being an encoder possibly attached to a shaft, the whole angle thing threw me off. But yes @irr313v4nt, the encoder itself won’t give you a value above that limit, but I think you will have to offset each time you go over the max value and count it yourself manually.

1 Like

If you have a fixed maximum angle, you can add a gear ratio between the encoder and what you’re measuring. So for example, if you don’t need more than 720° you can use a 2:1 reduction so every 1° of arm rotation equals 0.5° of encoder rotation. You can also theoretically use a potentiometer if you need up to 10 turns with limited precision.

For infinite rotation, you can use code that adds 360 to the value when the encoder goes from 270-360 to 0-90, and subtracts 360 when it goes the opposite direction. You can also use an incremental encoder if you always know the encoder position on startup or can use an index.

If you can give a description of what your use case and requirements are, we might be able to help more.

1 Like

Apparently, he wants to fit this encoder on the smaller end of a transmission system (due to complications with our robot design). We could use an incremental encoder, but we don’t have any spare ones on hand and it also takes up two DIO ports which are already crowded with a variety of sensors.

More specific, I want to use the ma3 encoder to track the height of the elevator, so I need to handle angles larger than 360 degrees

We were facing this problem also, when thinking about how to control an arm that swings through nearly 360 degrees. Our plan was to use an analog-output hall effect rotary position sensor (like the US Digital MA3), but we wanted to place the encoder on a shaft positioned upstream of a significant chain reduction, so the single-turn model we like wouldn’t have worked. So we hunted down a 10-turn guy that we’ll try instead.

It seems like everyone is having a problem with these encoders. Basically, the encoders can measure 0-360 degrees, but when we tested them the voltage only goes from .001 to 4.7. You can to account for this manually.

Here’s a thread: Am-2898 absolute encoder wiring
And here’s a thread: Andymark Absolute Encoders deadzone when being used with breakout board on TalonSRX

If you want to make it continuous, that shouldn’t be too difficult although you’ll have to do that manually as well. If you do this completely manually, you’ll have to track the last encoder position and keep track of the number of rotations based on it going from 4000 to 5 or something like 10 to 4090, etc.

There might be a way to do this through WPILib, but then you’ll have to account for the 0 to 4.7 manually.

1 Like

After some tests, I found a way to measure large angles:

  • my encoder returns value ranged from 11 to 4038
  • the datasheet of the ma3 encoder states that the max shaft speed is 100rpm, so the maximum change in value between each loop (0.02s) is 134 (=100x4027x0.02/60)
  • if the change is greater than 134 and current value < last value: rotation++
  • if the change is greater than 134 and current value > last value: rotation–
    However, I found that this method works correctly only at low speeds. If I rotate the shaft fast, the count of rotations is no longer correct.
    So I want to ask if my method is applicable and is there any improvements?

Probably you’re spinning the shaft beyond the recommended 100rpm, so it’s adding/subtracting rotations when it shouldn’t. Really, you only want to add/subtract rotations when the value crosses 0 degrees. If you find the values for 90deg and 270deg, you can write code like this:

if value < [90 value] and last_value > [270 value]:
[add rotation]
if value > [270 value] and last_value < [90 value]:
[subtract rotation]

Here is more of a design thought. Do you need a continuous position of the elevator? If you are trying to get away from added complexity having fixed points measured via limit switches, capacitive sensors or hall effect sensors. Could work for your purpose. Based on working with industrial automation a lot of machines use two switches for set points one to slow the mechanism down towards the set point and the other as the setpoint.

It seems like an incremental encoder is much better suited for this application.

1 Like

thank you very much for your help :slight_smile: