Analog Encoder to Quadrature

Thread Starter

metzenw

Joined Jan 3, 2021
7
Hi everyone, first post here.
I'm dipping into the world of microcontrollers and micro electronics. And I want to start with what I feel is a good entry level project.

I'm looking to convert an analog encoder to a 5v quadrature. The analog encoder produces a Sine wave with 2.2-2.7 volts peak to valley. It also puts out a 2.45v reference voltage that you can use to compare to. I did some reading and it sounds like using a voltage comparator circuit is the easiest way. Mainly a LM311 chip. Attached below is the circuit that I made along with the output from my scope. Looks like I'm really close to what I want. I will have to make three of these circuits for the A/B/Z channels of the encoder.

But I'm having a couple problems. First, I'm only getting around 3.7v output, Which is enough for TTL. More would be nice, but its not the end of the world. My cable run will be about a meter.
Second is the problem. My rise time on the square wave is around 20us. Max speed on this I need is 100khz which would be 10us peak to peak. So getting the speed down to at least 5us rise time I think will work. Faster is better for a cleaner signal. I have some 2n2222 transistors on the way, can I use those to speed up the circuit?

Lastly, this signal is going to be fed into a VFD. I have the option of Open Collector or Line Driver. I've looked up both and I don't understand the difference. I think I need open collector so that's what I ordered.

IMG_20210105_101459066.jpgIMG_20210105_084319287.jpg
 

scorbin1

Joined Dec 24, 2019
103
What is the make and model of the encoder you are using? I have honestly never seen an encoder output an array of sine waves. Quadrature encoders are binary by definition and not analog. The A and B outputs should give you the encoded position via a set of 2 out of phase pulses, which also allows you to determine direction, and the Z output pulses at a fixed shaft position giving you an absolute reference point. Analog encoders generally have a single output and encode the position in a 4-20ma or 0-10V signal. My guess is that what you have is indeed already a quadrature encoder and not an analog encoder. I think the sine wave is probably the signature of a lower cost encoder. I'm not sure any buffering circuitry should be needed although this could depend on the type input of the VFD. If it is looking for TTL inputs I think you should be able to connect it directly and the VFD will sort of ignore the fact that it's a sine wave and simply switch on and off when the input has crossed the appropriate thresholds.

I am a little out of practice with encoders so perhaps someone else will chime in and confirm or correct me where I'm wrong.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
I have honestly never seen an encoder output an array of sine waves. Quadrature encoders are binary by definition and not analog. The A and B outputs should give you the encoded position via a set of 2 out of phase pulses, which also allows you to determine direction, and the Z output pulses at a fixed shaft position giving you an absolute reference point. Analog encoders generally have a single output and encode the position in a 4-20ma or 0-10V signal. My guess is that what you have is indeed already a quadrature encoder and not an analog encoder. I think the sine wave is probably the signature of a lower cost encoder. I'm not sure any buffering circuitry should be needed although this could depend on the type input of the VFD. If it is looking for TTL inputs I think you should be able to connect it directly and the VFD will sort of ignore the fact that it's a sine wave and simply switch on and off when the input has crossed the appropriate thresholds.
Heidenhain have been making sine wave output quadrature encoders for years, the decoding utilities a co-tangent method for measurement.
In fact the old original quadrature encoders that used an incandescent lamp for the light source produced two sine wave outputs that were squared up as it is done today , using a Schmidt trigger etc.
Due to the fine grating resolution, the reading is done by producing a Moiré effect with effectively produces a much larger 'shutter' than the otherwise unreadable very fine grating.
This sine shape has to be squared up also.
Max.
 

Thread Starter

metzenw

Joined Jan 3, 2021
7
What is the make and model of the encoder you are using?
The encoder is off of a Fanuc Spindle motor. Below is out of a fanuc manual, showing the wave form.

Waveform.PNG

You want to convert a analog resolver sin/cos/ref signal to a digital A/B zero pulse encoder output?
It's an analog incremental encoder. its a 256 tooth (1024PPR) encoder.

...using a Schmidt trigger etc.
If this what I need to use? or will my circuit work?
I'd love to get this figured out, these Fanuc Spindle motors are starting to become cheap and people want to use them for there CNC home projects. Would be great to make an off the shelf product for this solution. I found a couple VFD's that MIGHT be able to read this type of encoder, but they are double the cost of a name brand VFD.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
The encoder is off of a Fanuc Spindle motor. Below is out of a fanuc manual, showing the wave form.

View attachment 227026
Are there any markings on the actual encoder, the output almost appears to be a Heidenhain in nature.
These were intended to be used detecting the arc-tangent method, they did have a convertor for square wave quadrature.
It should be possible with a suitable op amp method.
Max.
 

Thread Starter

metzenw

Joined Jan 3, 2021
7
Are there any markings on the actual encoder...
The Fanuc part number is A290-0854-V350. That first picture is all the information I could find about the encoder. Fanuc doesn't like to share.

But back to the circuit, what improvements can I make to increase the speed and and voltage while still using a 5v power supply.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
I have listing for many older Fanuc encoders but could not find that one, if it is one of the later Alpha series motors, it could be up to 1 million lines/rev, Absolute readout.
The difference between line driver and open collector is usually line driver is where the interface is RS485 5v. Open collector is as it implies and can be used single ended up to 24vdc.
The output of most Incremental encoders is some form of high speed version of the RS485 driver.
Max,
 

scorbin1

Joined Dec 24, 2019
103
Heidenhain have been making sine wave output quadrature encoders for years, the decoding utilities a co-tangent method for measurement.
In fact the old original quadrature encoders that used an incandescent lamp for the light source produced two sine wave outputs that were squared up as it is done today , using a Schmidt trigger etc.
Due to the fine grating resolution, the reading is done by producing a Moiré effect with effectively produces a much larger 'shutter' than the otherwise unreadable very fine grating.
This sine shape has to be squared up also.
Max.
Very interesting.. I'm definitely going to have to look into that. Thanks for the info!
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
I once had a study paper on it, it was quite interesting, as already mentioned, once you get above a certain grating definition, (~100 p/rev) it becomes impossible to differentiate between light & dark conditions.
This is overcome by the reading head carrying a small piece of grating at a slightly skewed angle, causing a Moiré effect, and a much larger 'shutter' is produced, which actually moves at right angles to the direction of motion.
i.e., if the head is moving horizontally, the shutter moves up and down, depending on the direction of travel.
This much larger 'shutter' produces a sine wave due to the gradual blocking of the shutter movement.
In some devices, this can be seen with the naked eye.
Max.
.
 

Ian0

Joined Aug 7, 2020
9,671
. First, I'm only getting around 3.7v output, Which is enough for TTL. More would be nice, but its not the end of the world. My cable run will be about a meter.
Second is the problem. My rise time on the square wave is around 20us. Max speed on this I need is 100khz which would be 10us peak to peak. So getting the speed down to at least 5us rise time I think will work. Faster is better for a cleaner signal. I have some 2n2222 transistors on the way, can I use those to speed up the circuit?
Before you try and complicated solutions, try a better comparator. Microchip has plenty of dual comparators, some of them with rail-to-rail outputs. https://uk.rs-online.com/web/p/comparators/1772875/
You might need a bit of hysteresis, check for jitter on the outputs.
 

Thread Starter

metzenw

Joined Jan 3, 2021
7
Before you try and complicated solutions, try a better comparator. Microchip has plenty of dual comparators, some of them with rail-to-rail outputs. https://uk.rs-online.com/web/p/comparators/1772875/
You might need a bit of hysteresis, check for jitter on the outputs.
Thanks for the On topic reply. I ordered up a new chip couple days ago. A LM2903P, which looks like it will do the trick. If not I'll need to research more to learn what I'm doing wrong.
 

Ian0

Joined Aug 7, 2020
9,671
Don't forget that it is open-drain output, so you'll need a pullup resistor unless your next stage already has one.
It's also not the speediest, but a response time of 400ns isn't so bad.
It also tends to jitter with sinewave inputs, so you might need a little hysteresis unless your next stage will ignore them (not that any comparator is completely free from jitter)
 

Thread Starter

metzenw

Joined Jan 3, 2021
7
Don't forget that it is open-drain output, so you'll need a pullup resistor unless your next stage already has one.
I'm still learning this stuff. Making some progress.
So I got an LM2903N chip and have it wired as shown.
Circuit.PNG
It appears to work, but the rise time is higher then I want at around 5us with a 15k Resistor.



IMG_20210120_183013501.jpg
I switched to a 4.7k resistor and it dropped to 2us. This I can work with.

So, my next goal is to turn it into a differential signal. I'll update with my progress on that.
 

MisterBill2

Joined Jan 23, 2018
18,176
There are LOTS of comparator types available and some are incredibly fast. The LM311 has both collector and emitter available for the output and one use is faster than the other, but I don't recall which. You could also use a video amp at high gain, check the applications for the LM733 as a line receiver for how to do that.And there are newer ones that are faster and cheaper, also.
 

MisterBill2

Joined Jan 23, 2018
18,176
The LM733 has differential outputs and inputs. But it is an amplifier, not a comparator. But certainly it could drive a comparator very well.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
I'm looking to convert an analog encoder to a 5v quadrature. The analog encoder produces a Sine wave with 2.2-2.7 volts peak to valley. It also puts out a 2.45v reference voltage that you can use to compare to. I did some reading and it sounds like using a voltage comparator circuit is the easiest way. Mainly a LM311 chip. Attached below is the circuit that I made along with the output from my scope. Looks like I'm really close to what I want. I will have to make three of these circuits for the A/B/Z channels of the encoder.
Are you in fact using one of the Heidenhain encoders, or similar type?
They have the sine wave 11μa version , their literature also show a means of squaring up each sine wave, I can scan a copy if needed.
Also see Link
Max.
 
Last edited:
Top