Stupid 4024 freq divider question (shaft encoder resolution)

Hi, I have a motor with a diffential optical encoder (A and B outputs), which is configured as a 1000 count-per-revolution device. I really want this thing to be a 250 CPR device...so rather than replace the encoder, I figure there must be an easy way to divide the pulses coming out of the encoder.

It's been years since I've played around with this stuff...so is it as simple as piping the A and B outputs of the encoder into two separate 4024 ICs, and then picking off Q2 of each, as the new output?

Also, the encoder I have says it is a "line driver" output. Does that mean it is 5V, but can sink more current than typical TTL? If so, I think I'm okay if I just put my 4024s within a few inches of the motor control, correct?

Last stupid question: If the output signal from one channel of the encoder looks like this:

____|-|_________|-|__|-|__|-|________________|-|____|-|___|-|____|-|_____

Does the output of Q2 on the 4024 look like this?:

__________________________|-|____________________________________|-|_____

In other words, is Q2 only transmitting every 4th pulse? That's exactly what I am looking for, since I want to be able to tell the motor control software that the shaft is in the spot that it would be in, if the encoder were 250 CPR instead of 1000 CPR.

Thanks for your patience & help.

-Randy

Reply to
Randy MacKenna
Loading thread data ...

I doubt that the encoder produces pulses. More likely, it is a quadrature encoder which produces one of four output states according to the shaft position modulo 4.

If you intend only to use the encoder as a tachometer, it could be that simple. But the fact that you mention use of both outputs leads me to believe you want to read shaft position, not just velocity. In that case, you have a more complex task ahead of you. You need a state machine to convert the input 2-bit grey code into a divided-by-4 output 2-bit grey code. In other words, you will produce another quadrature encoding that has

1/4 as many output transitions but preserves position within the limitation imposed by the lower resolution.

No, the counter will increase its count output at every input pulse, (specifically at the leading edge of the input pulse). This means, if you use Q2 as the output, it will toggle at every other input pulse.

If, with that language, you reveal that you are trying to control position rather than speed, then a simple divider simply will not work.

Good luck.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
 Click to see the full signature
Reply to
Larry Brasfield

Okay, thanks...I thought that the A / B channels of the encoder were more or less independent, and it was up to the motor driver hardware to integrate them. I figured I could just put a divider on each channel, and 'trick' the motor driver into seeing every 4th pulse on both the A and B channel.

I just looked at the datasheet for the encoder... the A and B channels sure look like square wave pulses to me. The B channel seems to lag the A channel by about 25% of the pulse width. The spec says "90 degree quadrature".

Not meaning to be a pest, but is there any hope here for a simple circuit, or do I really have to replace this encoder?

-Randy

Reply to
Randy MacKenna

Maybe. But that would depend on a factor I mentioned in my previous post and which still remains a mystery.

Clearly, it is a conventional quadrature encoder.

I cannot tell, yet.

You caught me in a good mood today, so I'll play the 20 question games. To save some time, I'll pose a few at a time:

  1. Does your application have to position the motor?

  1. Does the motor direction ever have to change?

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
 Click to see the full signature
Reply to
Larry Brasfield
  1. Yes. 2. Yes.

Actually, "I" don't want to try to set position and rotation of the motor -- I already have motor driver hardware and software that does this -- I just want to make the motor advance faster.

Here's an example. The motor is currently at zero degrees. I want to move and stop the motor at 360 degrees - one full rotation. Today, I'd have to pulse the driver 4000 times to effect that amount of rotation (1000 CPR encoder, quadrature = 4000 pulses per revolution). Instead, I want to pulse the driver only 1000 times.

Therefore, my thinking is that if I can "throw away" all but every 4th returned pulse out of both the A and the B channel, then the driving hardware (the stuff with the real 'brains') will only have to be pulsed

1000 times to effect one full rotation. I will tell the driver that it is connected to a 250 CPR encoder (I set this via software), thus when it sees every fourth returned pulse from the A and B channel, it will say "Ahh, my motor was just advanced by 1.44 degrees", an it will do the math the correct way and "land" the motor at the right spot.

One other way to do this is to replace the optical disk in the encoder with a different disk of lower resolution. That, in effect, is a 'mechanical' way of dividing the A and B outputs by 4. I can't buy a replacement disk for this encoder...thus my desire to solve this digitally.

I found this, which I could go out and buy (I'd need 4 of them). I'd like to avoid that cost, and at the same time solve this puzzle for my own education.

formatting link

I guess that this thing could be complex enough to contain a state machine and be doing the analysis of both A and B at the same time, and synthesizing new A and B outputs, based on the division factor specified by the DIP switches.

If you think that is indeed the case, then I am in way over my head, and I just have to spring for the $160 to buy four of these units for my four motors...

-Randy

Reply to
Randy MacKenna

To sum up:

Randy, you have a quadrature encoder, but every time someone mentions "quadrature" you seem to read it as "". Just dividing the two channels will _not_ get you where you want to go, you need direction information as well.

Go do a search on "quadrature encoder" (NOT "encoder"!). Learn how they work. Then you'll know over half of your answer. With a PLD, a PIC, or a few 7400 series parts you can do this -- but first you have to understand how a quadrature encoder works.

--
Tim Wescott
Wescott Design Services
 Click to see the full signature
Reply to
Tim Wescott
[In answer to: 1. Does your application have to position the motor? 2. Does the motor direction ever have to change? ]

That's why I referred to "your application".

The controller will have to recover correct position information from the encoder subsystem, then. For example, many positioning systems will overshoot the setpoint a little bit, then correct for that. And to stay in one position, they often have to hunt around the setpoint, jogging back and forth a little bit.

Your simple divider simply cannot retain position correctly in the face of direction reversals.

That's good thinking, as far as it goes. Be aware, however, that by decreasing the position sensing resolution, the hunting is likely to be worsened. (This may not happen for some controllers and some motor/hardware configurations.)

The problem is that, unless you know the direction is always the same, you cannot just throw away

3 of every 4 position transitions. Some of them may be ones that represented a new direction. Without a direction sensitive discard, and some state to track where the shaft is within the hidden set of positions, the correct ones cannot be "thrown away".

I'm sure that a simple PLD, with no more than 8 registers, could do this job provided you can live with a slight loss of transition time resolution. The loss can be kept negligible for ordinary positioning applications. It could be clocked continuously and produce the right output for any input speed up to a maximum of one input transition per clock. Let me know if this solution looks attractive and I will take a little more time to describe it in more detail.

I think you are in deeper than your first realized. But the problem is not really that difficult.

I would do the $0.80 PLD, in a heartbeat.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
 Click to see the full signature
Reply to
Larry Brasfield

Tim, I wasn't ignoring 'quadrature' out of arrogance...I didn't understand what the implication was. I will research, as you suggested, and better educate myself about this technology.

As I stated, I am looking to save money (I'm a hobbiest, trying to build a woodworking CNC router) -- and at the same time, I'm trying to learn as much about every aspect of my project as possible.

I do appreciate you guys taking the time to help educate me.

Thanks, Randy

Reply to
Randy MacKenna

Ahhh...now I get it...thanks!

encoder

a

That would be very nice. I suppose that if I go down this route, I'd have to buy some sort of FPGA programmer (like Digikey sells?) and learn how to code the solution. A long time ago, I was a grad student at Syracuse, writing VHDL and doing other digital logic coursework. Life took a different turn, so I've long forgotten most of it. I do remember how much fun it was setting up the system clock, mapping out state transistions, and reducing the problem to a circuit...so if there's an outside chance I can actually figure this out, that'd be nice.

All I need to know is the path I need to take, e.g.:

  1. learn how a quadrature encoder really works
  2. learn how to program a PLD
  3. figure out the inputs/outputs and state transistions
  4. design the circuit
  5. code the PLD

I understand that there's a loss of resolution here (which buys the added speed)...but we are talking about way below the spec of the woodworking machine I'm trying to build. The servo driver is tunable, so using an o-scope, I ought to be able to get the motor to be critically damped. All I need to do is to decide to go down one of these paths:

a. sell the encoders I have and buy new ones b. add the $40 divider box to each encoder circuit c. sell the drivers I have and buy new ones that have pulse multipliers onboard d. explore building my own encoder frequency division circuit.

I'd like to explore 'd' a little bit more, before giving up...if 'd' is a pipe-dream (for me), then my next viable option is 'c'.

-Randy

Reply to
Randy MacKenna

Somewhere in my bag of tricks I have a synchronous divide-by-two that might do what the OP wants. I'll search for it.

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
 Click to see the full signature
Reply to
Jim Thompson

Of course there's a simple circuit, a micro. Now all the complexity and headache is in software instead.

That said, how fast of a motor are you talking about? Are these 1000 and/or 250 pulses going to be coming once an hour? Minute? Second? Millisecond?

Reply to
Rob Gaddi

I didn't assume it was arrogance -- sometimes a term is superfluous, or gives a nuance that might get you that last 2% of the understanding when you only need 90%, so ignoring it is a good thing. As an example, when I talk to my lawyer I often interpret as many as half of his words as "" to retain my sanity.

In this case however it means everything, which is why I was stressing it.

--
Tim Wescott
Wescott Design Services
 Click to see the full signature
Reply to
Tim Wescott

Gosh, yes...this is starting to make sense. I think the hard part is going to be the state transition where you have to generate A_OUT leading B_OUT (or vise-versa), and do it exactly 90 degrees phase-shifted. It'll have to be that way, since the motor driver is expecting to see a nice, clean quadrature-style signal.

The clock rates on all of this are measured in the kHz, not mHz, so no worries about speed in this circuit.

I'm burned out tonight (long week at work), and I'm now working on the fiscal books for my daughter's school (I'm the volunteer bookkeeper :-)

So, I'll be checking back here on Monday...and not giving up!

Thanks to everyone, have a great weekend.

-Randy

Reply to
Randy MacKenna

lol! Nope, I figured when I talked to a group of guys like you, in this NG, every word is going to be pretty important. Especially words that start with "Q" :-)

I did read a couple of articles on this topic tonight, and I think I "get it" now.

I'm trying really hard not to be like this (substitute "Randy" for "Ginger"):

formatting link

Reply to
Randy MacKenna

--
If you want the thing to put out 250 pulses/state changes every second
you could just divide the 1000 pulses out of either channel by four,
 Click to see the full signature
Reply to
John Fields

But that's the whole point of the encoder. If it just put out single pulses, you'd have no clue which way the shaft was turning. But having two outputs, you can extract direction. If X leads Y, the shaft is turning clockwise. If Y leads X, the shaft is turning counter-clockwise. The number of pulses is how far the shaft is turned.

A classic example is setting a digitally tuned radio. The encoder would feed an up/down counter, with one the pulses counted by the clock input, and the direction telling the counter whether it's adding or subtracting the counts. Turn clockwise, and it increments the counter each time there is a click. Turn counterclockwise, and it decrements the counter each time there is a click.

Michael

Reply to
Michael Black

"Randy MacKenna" schreef in bericht news: snipped-for-privacy@f14g2000cwb.googlegroups.com...

Randy,

Assuming you have nice digital input signals, lets call them A en B, and you want to make new ones, lets call them X and Y, you can try the following quick and dirty circuit:

A four bits positive edge triggered up/down counter is the heart of the circuit. Connect A to the clock input and B to the up/down input. The ripple output of the counter can be used to toggle a flipflop giving you the X signal.

The Y signal is the problem. You need to decode 0011 of the counter(two inverters and an AND.) This signal has to clock a D-type flipflop with B XOR X on its data-input, giving the Y on the output.

petrus bitbyter

Reply to
petrus bitbyter

The quadrature encoder is not that hard to understand. Depending on which way the shaft is rotating, either A leads, or B leads. If A leads, let's say that is clockwise. Then in order to count clockwise position increments, you connect A to the up/down input of a counter, and connect B to the clock input of the counter. So if A is high on the positive edge of B, the counter counts up, because you are going clockwise. But if A is low on the rising edge of B, then the counter counts down, because you are moving counter clockwise. Does that make sense?

So if you have a clocked PLD, you could build your circuit, I think.

Let's say you have three inputs, A, B, and CLK. You have two outputs, A_OUT, and B_OUT. You rig up A and B to the four-bit counter, just as I outlined in the first paragraph. Then you build a clocked circuit which watches the count. When it sees the count transition from 3 to

0, the watching circuit sends out phased pulses on A_OUT and B_OUT such that A_OUT leads B_OUT. On the other hand, when the count transitions from a count of 0 to a count of 3, the watching circuit sends out phased pulses such that B_OUT leads A_OUT.

You just have to run the clock fast enough so that you don't miss any transitions on the counter. And you have to make sure that your output pulses meet whatever timing the subsequent circuitry expects.

There might be an even slicker way to do this to make it behave more like a real quadrature encoder, but it might not be necessary.

Good luck, and don't give up!

--Mac

Reply to
Mac

Randy I've just been working with USDigital encoders for a very similar application. Except for the woodworking...

It's very likely that the encoder can be disassembled, and you can buy the encoder wheel (a photographic transparency with an aluminum hole in the middle) from USD for lots less than $40 per.

Regards PN2222A

-2.6mV per degree C

Reply to
PN2222A

[snip]

Here's a scheme that MAY work in your application....

Newsgroups: alt.binaries.schematics.electronic Subject: Re: Stupid 4024 freq divider question (shaft encoder resolution) - CoherentDiv2.pdf Message-ID:

...Jim Thompson

--
|  James E.Thompson, P.E.                           |    mens     |
|  Analog Innovations, Inc.                         |     et      |
 Click to see the full signature
Reply to
Jim Thompson

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.