[Home]ResolverToQuadratureConverter

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

This page describes a three channel Resolver to Quadrature encoder convertor I have made to allow me to interface some eBay servo motors to EMC2.

The basis of this system is an Arduino ( http://www.arduino.cc ) an inexpensive ($25) easily-programmed open-source microcontroller platform based on the AVR Atmega series. A timer is set up to synthesise a 2kHz sine wave excitation signal for the resolver using a 32kHz base frequency. To drive the resolver this signal needs to be buffered to supply 200mA or so, and it needs to be filtered to remove the 32kHz carrier. Both these functions are performed by one gate of an LM272 power Op-Amp which functions as both a unit-gain high current buffer and the active element of a 2-pole Sallen-Key topology version of a Butterworth filter. (See Wikipedia for details, that is where I learned what little I know about the subject)

Because the Sin and Cos signals from the resolver output coils are AC and their relative phases are important for determining which quadrant the angle lies in it is necessary to find a way to measure negative voltages with the Arduino. This is done by using a voltage divider to hold the low-sides of the secondary coils at half the (adjustable) Digital to Analog reference voltage. At boot-up the Arduino code measures the no-excitation secondary voltage (ie zero position) and then this number is subtracted from the measured voltage to give a range of +/- 128 ADC counts.

At fixed points in the excitation cycle an analog acquisition is started. Ideally both sin and cos would be measured simultaneously, but the Atmega ADC is multiplexed so that is not possible (it does have a sample-and-hold though, or this whole thing would be a non-starter). The best compromise available is to measure the two complementary voltages at exactly the same time on alternate cycles.

On one excitation cycle all the Cos channels are measured, followed by all the sine channels.

When the acquisition finishes it triggers an interrupt which stores the new voltages in an array and sets a flag.

A free-running main loop re-calculates the encoder angle on the basis if the flags using a fast, lookup-table based Arctan function, and converts it to an angle (0-1023 angular counts)

The free-running loop tries to keep the angular position and the quadrature counter counts the same, counting up and down through an BAAB quadrature cycle.

One feature of this mode of operation of the quadrature counter is that if the EMC2 or add-on-board quadrature counter is active as the Arduino powers up there will be a burst of pulses that will drive the counter to the correct absolute encoder position. Hence some of the advantages of an absolute encoder are realised in the attached incremental encoder counter.

A variant of this code can be used to convert Resolver output to Hall sensor signals for a BLDC motor drive.

The Arduino sketch for the 3-channel Quadrature converter is here: http://wiki.linuxcnc.org/uploads/Resolver.pde

And this is the code for a single-channel Quadrature-and-Hall convertor http://wiki.linuxcnc.org/uploads/HallSensor.pde

Below is a schematic of the circuit used and a listing of the Arduino code:

[Edit] I went mad and had a bunch of Arduino shield boards made for this. Contact me at andy at bodgesoc dot org if you are interested in one or more. None left, sorry

[Edit some more] I didn't like the quadrature stage, as it loses the absolute aspect of Resolvers, I now send the positions at 1Mbps as serial data from the Arduino to a Mesa-card UART function.

(And here are some good links that the author recommended later: )

Arduino Tutorial: http://www.ladyada.net/learn/arduino/index.html

Starter Pack for Arduino - 1.0: http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=68

Download the Arduino Software: http://arduino.cc/en/Main/Software


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited May 31, 2016 1:32 am by Andypugh (diff)
Search:
Published under a Creative Commons License