Code to write sine/cosine curves for angle sensor

Previously users (@rolfo, @Pererva sorry others, new users can only tag 2) discussed how to generate a repeating sinusoidal pattern on a PCB for inductive angle sensors. That thread has now closed due to age, but I wanted to post my recent work. Here is the old thread:

I have written some simple python code which generates a PCB along these lines. It does not generate a complete sensor PCB yet, but it should serve as a jumping off point for anyone interested in this kind of thing. And you may want to watch or star the github project as I may continue this project and make a complete encoder generator.

I hope this is helpful! I am still waiting to access their proprietary coil design software (permission-ware) so I can see exactly how things are arranged. Depending on how many pole pairs you use, the design can be simple and repeating or more complex as traces jump over one another. I am using 10 pole pairs in my design, which makes for a simple regular pattern. But I have a few questions about the reference designs before I can make my program insert vias in the right place and connect everything properly.

5 Likes

I am only allowed one image per post so here is another image I want to share. Many wondered how to generate a proper curve. That would be nice, but I just used line segments.

I have some interest in robotic arms and CNC stuff.
Some time ago I found the “Zettlex Incoder”
These have an quite insane resolution of upto 21 bits absolute over 360 degrees. (Price is also above my budget)
The copper tracks on these are however far from sinusoidal.

image https://www.celeramotion.com/zettlex/products/incoder-inductive-encoders/

When I was young I once took an old telex apart, and that also had a PCB type resolver. The tracks on it were either trapezoidal or just square waves.

The Renesas IPS2200 you are linking to does work with sinusoidal copper tracks, so there clearly are differences here.

https://www.renesas.com/us/en/products/sensor-products/position-sensors/ips2200-inductive-position-sensor-high-speed-motor-commutation

1 Like

Yep I found those Zettlex products first and have a folder of all the useful images of them I could find. Here’s one showing the active board which has a more regular pattern.

If anyone could figure out how they work, this code could be adapted to make those patterns. But they are very serious about their patents so I was glad to find the Renesas!

It seems with the renesas you can do arbitrarily high pole counts and get more resolution. Their examples
with 32 pole pairs claim +/- 0.011 degree resolution.
https://www.renesas.com/us/en/document/oth/ips2-customer-reference-board-catalog-crb?language=en&r=469876

I think the IncOder devices use the same principle and high pole counts to get very high resolution. The cute wavy pattern in your first image is the passive induction reflector (idk what to really call it) so they seem to have figured out something better than just copper strips used for the Renesas.

360/ 0.011 = 32727.272
so that’s only 15 bits. Zettlex probably also only reaches the 22 bit versions on big diameters with high pole counts, but they do claim absolute position measurement (over one rotation).

A quick search:
https://html.duckduckgo.com/html?q=%2Bzettlex+%2Bpatent

quickly finds US7705585B2
https://patents.google.com/patent/US7705585B2/en
which has more text than I can concentrate on to read / understand at the moment. That patent expires in 2016. Similar sensors have been in use for many years and finding some older and completely expired patents should not be very difficult.

I do like the IPS2200 you found though. It’s commonly available at around EUR10 which makes it a viable option for hobby projects.

There are also many other ways to measure rotation. A simple and yet innovative way is what Haddington Dynamics put in their Dexter robotic arm. They started with an optical 2-bit gray encoder, and they extended the resolution by measuring the amount of light that manages to go through a slot.

Another one I like is from Homofaciens (Youube). He just glued a computer mouse to the (X, Y) axis of a CNC machine and analyzed the data from the mouse camera (These typically have 16x16 or 32*32 pixels) But you can of course use any webcam that is looking at some known object and do a bit of image recognition.

If you want to keep it simple, then just use a Hall effect sensor and a magnet. Resolution (not accuracy) is up to 12 bits The AS5200 van AMS is an example of such an encoder.

You’ve made some mistake in your drawing algorithm. The phase between the the three signals is not right. You have used an phase shift of 120 degrees between all signals, while Renesas uses a phase shift of 90 degrees between the signals.

Yes I do use AS5047’s as motor encoders in my robot arm, but I want something very high resolution for the joint encoders.

Partly this is interesting to me because it looks like one can make very high resolution encoders with this $10 chip and some PCBs. Plus its perfect for auto generated PCBs so it’s a perfect project to both have fun writing code and to produce an end result which I can use in my robots.

I actually have a Dexter arm! It is broken though and I need to donate it back to them…

I’ve been looking some more at the datasheet of the IPS2200 and I’m a bit disappointed. The chip itself only does a very low resolution quadrature output and analog sine / cosine outputs. To get a higher resolution output you need a fair bit of extra processing.

My Idea was to use two AS50xx chips per axle. One on the axle itself (for absolute position), and one on the motor shaft. I am aiming for around 20:1 (Maybe upto 40:1) transmission, which also increases the resolution by a factor of 20.

All robot arms I’ve seen with stepper motors use fairly low transmission ratio’s, and I don’t understand that. Nema23 stepper motors start loosing torque above around 600rpm. This means that if you double the transmission ratio, and then run the motors at 1200rpm, you have the same torque at fast movements, but higher torque for slow movements and it also doubles the resolution.

It also has some disadvantages. You need a two stage drive train which is more difficult to make with a small enough backlash, and you loose back-drivability, and therefore also loose accuracy for torque measurement by monitoring the motor current.

So I see you’re using BLDC motors ( from the twitter movie, and motor drivers) Movement looks quite good you have lot of control. I also hear some gear noise. I’m guessing its 3D printed plastic gears, maybe bearings from airsoft balls. This is a quite usable, simple and cheap combination, but it’s not going to be very accurate. I doubt that you can get much more useful resolution by using encoders that have more resolution then the AS5047.

Yes I am aware inductive encoders are potentially overkill for this application. As a robotics engineer who learns by doing, this is largely to familiarize myself with the design of a new (to me) high resolution sensor. I’m not using airsoft bearings though, just low cost metal bearings from china.
The canonical reference for the arm is here:

You can see some of the gears here:

I have been designing 3D printed planetary gearboxes for some years now, and I am bullish that they can be very good. Also this arm could alternatively be injection molded with the necessary design changes, and I dream of flying to china and showing manufacturers my open source design just to help them tool up.

In the mean time I also found the picture of the internals with purple gears and steel bearings. Planetary gears are always going to have backlash. But if you use better encoders, you can better measure your backlash (and try to compensate for it).

I’m also seeing a lot of gears. Is this a 2 stage or a 3 stage geartrain?
I also do not see much scaling between the gears. If you have for example a 2 stage geartrain, then the load in the teeth in the second stage is multiplied by the transmission ratio of the first stage. In all commercial designs this results in smaller teeth for the first stage (which results in higher gear ratio) and coarse but stronger teeth in the second stage. The smaller teeth for the fist stage are also better suited for higher speeds.

The internals of this robotic arm look better then a lot of others I’ve seen. So I’m curious how good you are able to make it in the end.

Each gearbox is two stages, but the two visible ones are a special two stage design with three planet carriers total. The first stage is in the middle, with parallel outputs on both sides. Those drive parallel second stages. (A shaft from the outside passes through a hole in the sun gears to get to the center.) This gives the joint four output locations total, so high forces are distributed across several places. Good for low strength materials like plastic. This also means the second stage has twice the gear area of the first stage.


I came up with that myself, possibly a novel design (I’ve never seen it). One advantage is if you want to use two motors you could actually split the first stage in the middle and drive them in opposition to get true zero backlash. However I am honestly just happy to have a decent arm design together and am not particularly concerned about backlash. So far it is pretty low backlash except for the third stage, which has a problem in the way the output attaches to the frame that is causing several bad backlash, but that is straightforward to fix.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.