By continuing to use this site, you agree to our use of cookies. Find out more
Forum sponsored by:
Forum sponsored by Allendale Jan 24th

DIY Rotary Quadrature Encoder

All Topics | Latest Posts

Search for:  in Thread Title in  
Joseph Noci 106/09/2020 15:11:45
987 forum posts
1247 photos

A common component to many of my machine computerisations has been a quadrature encoder. I have always used optical encoders, all with A/B outputs, some also with index output, for applications that require position timing, such as the lathe ELS.

I also use these encoders extensively as MMI input sensors for display data entry, frequency tuning on radios, etc. So, I end up using lots of the darn things, and the costs become a little silly.. I tried making units, with slotted discs, etc, especially for the low pulse count applications, such as data entry, but it is just to finicky.

So, I decided to try a magnetic encoder - chips implementing this function abound these days, with some being really complex - a neat, simple device is the AS5147P datasheet here with a programmable output interface that can do all one would need - I use the ABI ( chan A, B and index) outputs, and these can be programmed to output from 256PPR to 1024PPR ( 4096 edges).

It can also output angles with 14bit resolution.

The device will easily cope with up to 28K rpm, is US$10.00 for one.

It uses a diametrically magnetized neo magnet, 8mm diameter, 3mm thick.

Programming is via SPI , easily done from any Arduino, and the device can be permanently programmed with your desired setup, so that it remains simply an encoder when you power it, with the SPI interface no longer needed.

It works very well indeed.

I knocked up a prototype to test, just used some PVC rod, with an Aluminium shaft holding the magnet

If higher performance ( speed..) is needed, bore out the ends of the PVC body shaft hole to take 2 x 6mm ID bearings..

26mm diameter PCB for the device:

bare pcb.jpg

PVC Body, the magnet in the shaft and the pcb assembled

bodymagnet.jpg

 

magnet in body.jpg

 

assembled 1.jpg

assembled 2.jpg

 

Joe

edit - fix syntax...

Edited By Joseph Noci 1 on 06/09/2020 15:12:19

Michael Gilligan06/09/2020 18:14:08
avatar
18710 forum posts
915 photos

What an astonishing device, Joe surprise

Being dim ... I am struggling with the concept of:

[quote]

Incremental movements are indicated on a set of ABI signals

with a maximum resolution of 4096 steps / 1024 pulses per

revolution. The resolution of ABI signal is programmable to

4096 steps / 1024 pulses per revolution, 2048steps / 512 pulses

per revolution or 1024steps / 256 pulses per revolution.

[/quote]

.... being available from four Hall sensors and one rotating magnet.

.

If you can spare the time; could you please explain that, in easy words of few syllables.

Meanwhile I will try reading the data-sheet again blush

MichaelG.

DC31k06/09/2020 19:41:02
554 forum posts
1 photos
Posted by Michael Gilligan on 06/09/2020 18:14:08:

.... being available from four Hall sensors and one rotating magnet.

The crux of it seems to be on page 10 of the datasheet.

The Hall sensors give a continually varying analogue output.

This is amplified, then goes through an A to D converter and then there is an inbuilt CORDIC that calculates the angular position.

I guess that for every 'tick' of the encoder, there must be a unique set of four values from the Hall sensors.

The headline cost of $10 seems good but how much value does the time to make the PVC housing, the magnet and PCB consume? And compare that to a 1024ppr encoder available from a source, which will be moderated if mentioned.

Michael Gilligan06/09/2020 20:42:12
avatar
18710 forum posts
915 photos
Posted by DC31k on 06/09/2020 19:41:02:
Posted by Michael Gilligan on 06/09/2020 18:14:08:

.... being available from four Hall sensors and one rotating magnet.

The crux of it seems to be on page 10 of the datasheet.

[...]

.

Thanks for that

Yes, I am sure you are correct ... 'though it still boggles my mind to think of 1024 steps being extracted from four analog sensors on that physical scale.

MichaelG.

Joseph Noci 106/09/2020 21:06:06
987 forum posts
1247 photos
Posted by DC31k on 06/09/2020 19:41:02:
The headline cost of $10 seems good but how much value does the time to make the PVC housing, the magnet and PCB consume? And compare that to a 1024ppr encoder available from a source, which will be moderated if mentioned.

I guess it depends on where you are and how easy it is to procure these things! Fedex/DHL 10 day shipping to me in Namibia varies between US$100 and US$150 from the USA, and about 70 to 80% of that from the UK. From China it is about 1/2 that, but this year I have had poor luck from that part of the world - shipments taking 2 to 3 MONTHS...and some shipments still outstanding since January...

In my world, I sometimes feel that, while most of the rest of you can go out and buy a balanced mixer at the local component store, I have to go out into my back yard, among the granite and quartz mountains, and dig out some Galena while keeping an eye open for a willing cat...

100 of those PCB's can be had for US$40.00. The chips are $7.00 ea for qty 100. I suppose I could do 50 of the housings and shafts in a day maybe?...

The concept is just neat and can easily be adapted to motor shaft ends, etc, without belts and the like.

Michael, exactly as was said - the 4 analogue outputs of the hall sensors are read and a fancy algorithm looks at the relative amplitudes/phase angles and computes the actual angular position of the shaft ( rather, the magnet..) From that it follows that the quadrature outputs are actual just an extension of the position determination. Some very smart design engineers out there, integrating all that into a $10 little chip!

Joe

Michael Gilligan06/09/2020 21:51:27
avatar
18710 forum posts
915 photos
Posted by Joseph Noci 1 on 06/09/2020 21:06:06:
Posted by DC31k on 06/09/2020 19:41:02:

Michael, exactly as was said - the 4 analogue outputs of the hall sensors are read and a fancy algorithm looks at the relative amplitudes/phase angles and computes the actual angular position of the shaft ( rather, the magnet..) From that it follows that the quadrature outputs are actual just an extension of the position determination. Some very smart design engineers out there, integrating all that into a $10 little chip!

Joe

.

Thanks, Joe ... Whilst I can accept the explanation, I must admit it's more a matter of blind faith than actual comprehension

I really can't get my old head around the idea of the 'virtual pitch' of this encoder being whatever tiny circumference, divided by 1024

MichaelG

Michael Gilligan06/09/2020 23:21:35
avatar
18710 forum posts
915 photos

Not as tidy as Joe’s but I see there is an Evaluation Kit available : **LINK**

https://www.mouser.co.uk/datasheet/2/588/AS5147P_AB_UG000375_1-00-1513532.pdf

MichaelG.

Edited By Michael Gilligan on 06/09/2020 23:23:18

Joseph Noci 107/09/2020 07:18:50
987 forum posts
1247 photos
Posted by Michael Gilligan on 06/09/2020 21:51:27:

Thanks, Joe ... Whilst I can accept the explanation, I must admit it's more a matter of blind faith than actual comprehension

I really can't get my old head around the idea of the 'virtual pitch' of this encoder being whatever tiny circumference, divided by 1024

MichaelG

Michael, perhaps this explanation is of some use? AS5147 operation - the pdf is oriented more toward the choice of magnet, but reasonably describes how the device works.

Joe

DC31k07/09/2020 07:50:42
554 forum posts
1 photos

For the purposes of understanding its operation, I wonder whether it is helpful to draw the analogy between this device and some linear scales (Heidenhain and possibly Newall) that use a (n analogue) sinusoidal output instead of a quadrature pulse. The scales will resolve 1 um.

One big advantage of this sensor that struck me overnight is that it can be made into something with a very small length. If we have the end of the shaft as datum, all you need is the magnet thickness, the air gap, the chip height and PCB thickness.

I was dreaming of something that would go under my compound slide and feed into the DRO in the same way that a knee-quill adder box does on a mill.

Michael Gilligan07/09/2020 08:03:59
avatar
18710 forum posts
915 photos

Thanks again, Joe yes

I actually found that document late last night, but haven’t yet done it justice.

The ‘sensor radius’ for the 5147 version is given as 1.1mm

I am fine with the principle of operation, but; even as a microscopist, I find the ‘circular pitch’ of that virtual index wheel quite astonishing.

I calculate it as just under 6.75 microns ... from a rotating magnet !

MichaelG.

Werner Schleidt07/09/2020 10:05:25
avatar
133 forum posts
176 photos

Hello Joe,

this kind of sensors are used to control very accurate brushless motors in electric steering systems vor passenger cars and for steering angle sensors. I do not know it exactly ,but for a good motor control for silent working of the motor it have to be better than 360 steps per revolution. Based on the application the only problem I see by manufacturing to have it all accurate alligned in the middle position. otherwise there can be some wobbeling in the signal caused by a runout. This unit is ideal for homemade displacement senors.

Werner

Edited By Werner Schleidt on 07/09/2020 10:07:10

John Haine07/09/2020 10:07:39
4099 forum posts
241 photos

Michael, maybe think of it in a different way. Imagine that the chip is a compass and the magnet the earth. We are quite blase about the idea that direction can be read to 1 degree from a compass scale, but the needle is doing exactly the same resolving of the magnetic field components as this chip. You could calibrate the compass to 0.1* and have a resolution of 3600 steps using a magnifier to read it. Or even have a vernier and read to 100th of a degree.

The same principle is used in the old "synchro resolver" system. This measured an angle with a rotor coil picking up a signal from two drive coils excited in phase quadrature, so the phase of the induced signal is essentially equal to the angle between the pickup coil and the "in-phase" stator coil. Analog Devices for one (used to?) make chips that could translate between the phase and a precision digital angle measurement.

This is also used in the Newall DRO system. The reference "scale" is a tube tightly packed with a row of precision steel balls, which is surrounded by a pair of pickups that are essentially differential transformers
( "LVDTs" ) excited in quadrature and generating sine and cosine signals that vary in relative amplitude depending on linear relative position. Though the ball diameter is say 5mm, a resolver can convert these into a micron-level position measurement.

The resolution all comes down to the number of bits used to digitise the amplitude measurement, so it's relatively easy in principle to resolve very small movements. The precision and accuracy however depends on many other factors, like the linearity of the sensors and A/D converters, electronic noise, geometry of the magnet and so on. Quite a lot of these depend on good design of the signal processing electronics in the chip. Given that the device will incorporate a processor and non-volatile memory, there is probably a calibration step in the manufacture where some parameters that affect accuracy and measured and compensation parameters stored.

Also think about your optical mouse: this can resolve a movement of 1/3000 inches for an LED type, or 1/15000 inches for a laser mouse, on any old desktop surface. The resolution in this case comes from the patterning of the optical sensor on the chip.

Michael Gilligan07/09/2020 10:22:27
avatar
18710 forum posts
915 photos
Posted by John Haine on 07/09/2020 10:07:39:

Michael, maybe think of it in a different way. Imagine that the chip is a compass and the magnet the earth. We are quite blase about the idea that direction can be read to 1 degree from a compass scale, but the needle is doing exactly the same resolving of the magnetic field components as this chip. You could calibrate the compass to 0.1* and have a resolution of 3600 steps using a magnifier to read it. Or even have a vernier and read to 100th of a degree.

[…]

.

Thanks for that, John ... all generally understood and accepted

.

[quote]
Posted by Michael Gilligan on 07/09/2020 08:03:59:

I am fine with the principle of operation, but; even as a microscopist, I find the ‘circular pitch’ of that virtual index wheel quite astonishing.

I calculate it as just under 6.75 microns ... from a rotating magnet !

MichaelG.

[/quote]

.

It’s the mechanical dimensions, and the speed, that I find astonishing.

It would be extremely difficult to read a magnetic compass to a resolution [never mind accuracy] of one degree if it only measured 2.2mm diameter.

MichaelG.

John Haine07/09/2020 10:51:44
4099 forum posts
241 photos
Posted by Michael Gilligan on 07/09/2020 10:22:27:
.................

It would be extremely difficult to read a magnetic compass to a resolution [never mind accuracy] of one degree if it only measured 2.2mm diameter.

MichaelG.

But if you looked at it with a x100 microscope?

Bazyle07/09/2020 11:21:24
avatar
6000 forum posts
220 photos

Probably pointless but if you put one on a stepper motor spindle and then examined results of microstepping and reading angle what would you get. Both relying on analogue interpolation to deliver quantised results.

Michael Gilligan07/09/2020 13:40:36
avatar
18710 forum posts
915 photos
Posted by John Haine on 07/09/2020 10:51:44:
Posted by Michael Gilligan on 07/09/2020 10:22:27:
.................

It would be extremely difficult to read a magnetic compass to a resolution [never mind accuracy] of one degree if it only measured 2.2mm diameter.

MichaelG.

But if you looked at it with a x100 microscope?

.

We are obviously at cross purposes, John

... I was trying to understand how they achieve it, with that device, and magnet rotating on a shaft.

Other methods are, of course, available but not at the size, convenience, and price of that chip.

I will quietly ponder, and refrain from further comment or question on the matter.

MichaelG.

Robert Atkinson 207/09/2020 17:27:34
avatar
1072 forum posts
20 photos

One important point with this class of sensor is that the field sensng is ratometric between the sensors, not absolute. This means that changes to he total magnetic field do not affect operation. The relative positions of the sensors is accurately defined as they are all on a single piece of silicon.

Robert G8RPI.

Neil Wyatt08/09/2020 18:52:32
avatar
Moderator
18727 forum posts
729 photos
80 articles

I imagine the most critical properties are the alignment of the magnet and chip and how accurately the magnetic field is aligned in the magnet itself.

Joseph Noci 108/09/2020 19:11:00
987 forum posts
1247 photos
Posted by Neil Wyatt on 08/09/2020 18:52:32:

I imagine the most critical properties are the alignment of the magnet and chip and how accurately the magnetic field is aligned in the magnet itself.

That's why I stuck to a circular construction - center is controlled to small enough tolerances quite easily. The placement of the chip on the board is not to difficult - I did it by centering the device pins on the PCB tracks, under a microscope. Final measurements on the microscope stage show that the IC body ended up centered within 0.06 mm of the pcb disc center. The datasheet indicates a 0.25degree non-linearity for a 0.25mm displacement, 1.5 degree for 1mm displacement, so not to difficult to get it fairly good.

If the PCB were assembled on a pick and place machine then the result is easier to control...

As to the accuracy of the actual magnetic field..best to buy a specified magnet from a reputable supplier!

Joe

Neil Wyatt09/09/2020 16:42:02
avatar
Moderator
18727 forum posts
729 photos
80 articles
Posted by Joseph Noci 1 on 08/09/2020 19:11:00:
Posted by Neil Wyatt on 08/09/2020 18:52:32:

I imagine the most critical properties are the alignment of the magnet and chip and how accurately the magnetic field is aligned in the magnet itself.

That's why I stuck to a circular construction - center is controlled to small enough tolerances quite easily. The placement of the chip on the board is not to difficult - I did it by centering the device pins on the PCB tracks, under a microscope. Final measurements on the microscope stage show that the IC body ended up centered within 0.06 mm of the pcb disc center. The datasheet indicates a 0.25degree non-linearity for a 0.25mm displacement, 1.5 degree for 1mm displacement, so not to difficult to get it fairly good.

If the PCB were assembled on a pick and place machine then the result is easier to control...

As to the accuracy of the actual magnetic field..best to buy a specified magnet from a reputable supplier!

Joe

That's not bad, more than enough for a control and probably as good as using a potentiometer for servo applications, obviously less ideal as a precision position sensor although you could easily calibrate it against a conventional rotary encoder.

Does it just give a quadrature output or can it give an absolute one as well?

Neil

 

Edit ... once the printer is working you could print a jig to hold the IC central whilst you solder it. Another use for 3D printing - custom index wheels and (relatively low-resolution) opto encoders (I once made an absolute 4-bit rotary encoder by photocopying the design onto acetate, for a wind vane, I used IR diodes from two dead computer mice).

Edited By Neil Wyatt on 09/09/2020 16:45:16

All Topics | Latest Posts

Please login to post a reply.

Magazine Locator

Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!

Find Model Engineer & Model Engineers' Workshop

Latest Forum Posts
Support Our Partners
Eccentric July 5 2018
emcomachinetools
Dreweatts
JD Metals
Warco
walker midge
cowells
rapid Direct
Eccentric Engineering
Subscription Offer

Latest "For Sale" Ads
Latest "Wanted" Ads
Get In Touch!

Do you want to contact the Model Engineer and Model Engineers' Workshop team?

You can contact us by phone, mail or email about the magazines including becoming a contributor, submitting reader's letters or making queries about articles. You can also get in touch about this website, advertising or other general issues.

Click THIS LINK for full contact details.

For subscription issues please see THIS LINK.

Digital Back Issues

Social Media online

'Like' us on Facebook
Follow us on Facebook

Follow us on Twitter
 Twitter Logo

Pin us on Pinterest