Maker Pro
Maker Pro

Stupid 4024 freq divider question (shaft encoder resolution)

R

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"):

http://i5.nyu.edu/~mm64/x52.9545/dogs.gif
 
P

PN2222A

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
 
J

Jim Thompson

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.
[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: <4i512194sq6lnl5r2oh0mnqc7cguohmc00@4ax.com>

...Jim Thompson
 
F

Fred Bloggs

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.

That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.




---- ---- ---- ---- --
A or B | | | | | | | | |
input o o o | | | | | | | | | o o o
| | | | | | | | |
--- ---- ---- ---- ----


------------------- --
| | |
Divide | | |
output | | |
--- -------------------



QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

---- ---- ---- ---- ---- --
| | | | | | | | | |
A | | | | | | | | | |
| | | | | | | | | |
---- ---- ---- ---- ----

---- ---- ---- ---- ---- --
| | | | | | | | | | |
B | | | | | | | | | | |
| | | | | | | | | | |
--- ---- ---- ---- ---- ----

------------------- ----
A | | |
- | | |
4 | | |
----------- -------------------


--- -------------------
| | |
B | | |
- | | |
4 ------------------- -----------
 
L

Larry Brasfield

Fred Bloggs said:
That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.
[waveforms and only waveforms cut]
QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:
[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute? And if that
is the case, what do think guarantees the output
phase relationship that you drew? Just wondering.
 
F

Fred Bloggs

Larry said:
That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.

[waveforms and only waveforms cut]
QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute?

Yes, yes, no, and yes, respectively, since I can make a viable, perfect
actually, 1/4 quadrature encode output happen, without direction input,
and optional direction output if necessary.

And if that
is the case, what do think guarantees the output
phase relationship that you drew? Just wondering.

Didn't I say that he must add logic to enable/disable the respective
counter advance in accordance with direction? If CPR is a programmable
input to his controller then your concern about "hunting" will not be a
problem. Don't assume that something that is non-evident to you may even
begin to challenge someone else...
 
M

Mac

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

I think all you have to do is make it so that A_OUT is high when count =
0 or 1, and B_OUT is high when count = 1 or 2.

I think this will do it (this is an untested verilog module):

module quad_div(a, b, clk, rst, a_out, b_out)
input a, b, clk, rst;
output a_out, b_out;

reg a_out, b_out;
reg [1:0] count;
reg a_in, b_in, b_in_d; // d for delayed

/*************************************************
This block syncs a and b to clk, and increments
or decrements count on the rising edge of the
sync'd 'b'.
************************************************/

always @(posedge clk or posedge rst)
if (rst)
count <= 0;
else begin
a_in <= a;
b_in <= b;
b_in_d <= b_in;
if (b_in && (~b_in_d))
count <= a_in ? count + 1 : count - 1;
end

always @(posedge clk)
case (count)
0:
a_out <= 1;
b_out <= 0;
1:
a_out <= 1;
b_out <= 1;
2:
a_out <= 0;
b_out <= 1;
3:
a_out <= 0;
b_out <= 0;
endcase

endmodule

Like I said, it's untested. ;-)

--Mac
 
J

James Meyer

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.
The most simple solution is to add a couple of gears to the motor shaft.
Make the ratio of teeth be equal to 1:4 so that 1 revolution of the
motor/encoder equals 4 revolutions of the output shaft.

Jim
 
L

Larry Brasfield

Fred Bloggs said:
Larry said:
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.

That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.

[waveforms and only waveforms cut]
QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute?

Yes, yes, no, and yes, respectively, since I can make a viable, perfect actually, 1/4 quadrature encode output happen, without
direction input, and optional direction output if necessary.

If my challenged parsing skills are working today, I
take that to mean that you can make a perfect
quadrature encoder, using nothing but the method
the OP asked about plus some secret logic that
depends on his application in an as yet unspecified
manner. And that is something of value to contribute.
I guess that would have to be a future contribution.
Didn't I say that he must add logic to enable/disable the respective counter advance in accordance with direction?

I see only a single post by you on this thread.
And it said no such thing. Nor did it give any
hint that direction was or might be involved.

In fact, given only your post, and given the OP's
actual application, your "solution" would have led
him to a system with mysterious misbehavior.
If CPR is a programmable input to his controller then your concern about "hunting" will not be a problem.

So, you believe that hunting cannot be affected
by the resolution of the position sensor in a
position control system? Having designed a
few such systems myself, that astounds me.
Don't assume that something that is non-evident to you may even begin to challenge someone else...

But I can hope to be educated, right?
 
F

Fred Bloggs

Larry said:
Larry said:
message

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.

That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.

[waveforms and only waveforms cut]


QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute?

Yes, yes, no, and yes, respectively, since I can make a viable, perfect actually, 1/4 quadrature encode output happen, without
direction input, and optional direction output if necessary.


If my challenged parsing skills are working today, I
take that to mean that you can make a perfect
quadrature encoder, using nothing but the method
the OP asked about plus some secret logic that
depends on his application in an as yet unspecified
manner. And that is something of value to contribute.
I guess that would have to be a future contribution.

Yes- you understand that correctly, the drawing will be cumbersome
because the OP needs everything spelled out and I do not feel like doing
that right now.
I see only a single post by you on this thread.
And it said no such thing. Nor did it give any
hint that direction was or might be involved.

The words in my post were "...sounds like a dual counter with simple
logic..."- the simple logic would be the A>B or B>A decision. I am under
no obligation to give away the farm- things get much more interesting
after the " cannot be done " crowd chimes in.
In fact, given only your post, and given the OP's
actual application, your "solution" would have led
him to a system with mysterious misbehavior.

True- if he's a sloppy reader and does not follow up with any confusion
he may have.
So, you believe that hunting cannot be affected
by the resolution of the position sensor in a
position control system? Having designed a
few such systems myself, that astounds me.

The controller is configurable to any motor- and it is receiving true
encoder data at 1/250th revolution- so what is the problem?- there is
nothing be "fooled" here- the encoder is being electronically converted
to 1/4 resolution.
But I can hope to be educated, right?

Well- let's see your version of it then.
 
F

Fred Bloggs

Mac said:
I think all you have to do is make it so that A_OUT is high when count =
0 or 1, and B_OUT is high when count = 1 or 2.

That's obviously flawed- A and B are then in anti-phase and not
quadrature. I am assuming here that A is LOW when it's not HIGH and
vice-versa, but maybe...
 
L

Larry Brasfield

Fred Bloggs said:
That's obviously flawed- A and B are then in anti-phase and not quadrature. I am assuming here that A is LOW when it's not HIGH
and vice-versa, but maybe...


You should not assume that what is obvious to you is true.

A_OUT and B_OUT, as Mac described them, are not
anti-phase. Read more carefully. They are true for a pair
of input state sets that are not disjoint. This means they
can both be true at the same time. And a little more
attention to Mac's post (the part you cut) would show that
those outputs are, in fact, in quadrature for any monotonic
counting sequence.
 
L

Larry Brasfield

Fred Bloggs said:
Larry said:
Larry Brasfield wrote:

message

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.

That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.

[waveforms and only waveforms cut]


QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute?

Yes, yes, no, and yes, respectively, since I can make a viable, perfect actually, 1/4 quadrature encode output happen, without
direction input, and optional direction output if necessary.


If my challenged parsing skills are working today, I
take that to mean that you can make a perfect
quadrature encoder, using nothing but the method
the OP asked about plus some secret logic that
depends on his application in an as yet unspecified
manner. And that is something of value to contribute.
I guess that would have to be a future contribution.

Yes- you understand that correctly, the drawing will be cumbersome because the OP needs everything spelled out and I do not feel
like doing that right now.
I see only a single post by you on this thread.
And it said no such thing. Nor did it give any
hint that direction was or might be involved.

The words in my post were "...sounds like a dual counter with simple logic..."- the simple logic would be the A>B or B>A decision.
I am under no obligation to give away the farm- things get much more interesting after the " cannot be done " crowd chimes in.

Clearly your obligations are very limited here.
True- if he's a sloppy reader and does not follow up with any confusion he may have.

Here is a summary of your contribution:
OP asks: "Can I use two binary up counters to
get from one encoding to a courser encoding?"
Fred says: "A dual counter with simple logic
should do it." This with no indication as to what
that logic might be, what it should accomplish, or
that the counters might have to be bidirectional.

What, precisely, is the value added by that?
If there is any, I cannot fathom it.

When the OP mentioned "CPR" it was shorthand
for "Counts Per Revolution". I cannot tell what your
"CPR" input would be in this context.
The controller is configurable to any motor- and it is receiving true encoder data at 1/250th revolution- so what is the problem?-
there is nothing be "fooled" here- the encoder is being electronically converted to 1/4 resolution.

I take it that by "problem" you mean my claim
that "hunting is likely to be worsened". While I
hesitate to attempt to educate you about what
happens in positioning systems connected to
real hardware, with all its non-linearities and
dynamics, I will allude to the fact that getting
some error feedback for a smaller error can
allow finer correction. With your intellect, I am
sure you can work out the details.
Well- let's see your version of it then.

I feel no need or compulsion to prove myself
to you. If the OP finds Mac's solution less than
satisfactory, I will be happy to lend a hand.

Thanks for the education.
 
F

Fred Bloggs

Larry said:
You should not assume that what is obvious to you is true.

A_OUT and B_OUT, as Mac described them, are not
anti-phase. Read more carefully. They are true for a pair
of input state sets that are not disjoint. This means they
can both be true at the same time. And a little more
attention to Mac's post (the part you cut) would show that
those outputs are, in fact, in quadrature for any monotonic
counting sequence.

Really? And what is your "clk"?- an unspecified input.
 
G

Glenn Gundlach

I had a similar project on a telecine (film to video) to do 3 or 4
pulses per frame. It boiled down to using only 1 of the 2 phases BUT
you must count both edges meaning divide by 4 needs to count to 8.
Detecting both edges used an RC delay and then XOR the delayed and non
delayed for a pulse per transition. The secondary phase (which is not
counted down) was used to gate the proper state of the counter. This
unit had to run forward and backward and generate a new quadrature
output at the divide by 3 or 4 for another film (magnetic sound)
machine. It required a buffer for the clock pulse delay and a 22V10 for
all the counting and gating including the XOR function routed back to
the clock input of the 22V10. Changing from RC to delay line should be
able run up to the max frequency of the 22V10.
GG
 
L

Larry Brasfield

Fred Bloggs said:

Yes, that's why I posted.
And what is your "clk"?- an unspecified input.

Irrelevant. What clock can you construct, in this
universe, that will cause A_OUT and B_OUT to
be anti-phase when, for some inputs, they have
the same value?
 
F

Fred Bloggs

Larry said:
Larry said:
message

Larry Brasfield wrote:


message


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.

That sounds like a dual counter with simple logic should do it:

View in a fixed-width font such as Courier.

[waveforms and only waveforms cut]



QUADRATURE SEQUENCE A/4 & B/4 TO CONTROLLER:

[waveforms and only waveforms cut]

So, Fred, I wonder, did you peruse the rest of this
thread before replying? If so, was it irrelevent, in
your mind? Or incomphrehensible? If you could
not bother, were you pretty sure that you actually
had something of value to contribute?

Yes, yes, no, and yes, respectively, since I can make a viable, perfect actually, 1/4 quadrature encode output happen, without
direction input, and optional direction output if necessary.


If my challenged parsing skills are working today, I
take that to mean that you can make a perfect
quadrature encoder, using nothing but the method
the OP asked about plus some secret logic that
depends on his application in an as yet unspecified
manner. And that is something of value to contribute.
I guess that would have to be a future contribution.

Yes- you understand that correctly, the drawing will be cumbersome because the OP needs everything spelled out and I do not feel
like doing that right now.

And if that
is the case, what do think guarantees the output
phase relationship that you drew? Just wondering.

Didn't I say that he must add logic to enable/disable the respective counter advance in accordance with direction?

I see only a single post by you on this thread.
And it said no such thing. Nor did it give any
hint that direction was or might be involved.

The words in my post were "...sounds like a dual counter with simple logic..."- the simple logic would be the A>B or B>A decision.
I am under no obligation to give away the farm- things get much more interesting after the " cannot be done " crowd chimes in.


Clearly your obligations are very limited here.

True- if he's a sloppy reader and does not follow up with any confusion he may have.


Here is a summary of your contribution:
OP asks: "Can I use two binary up counters to
get from one encoding to a courser encoding?"
Fred says: "A dual counter with simple logic
should do it." This with no indication as to what
that logic might be, what it should accomplish, or
that the counters might have to be bidirectional.

I already drew a waveform that graphically describes what it should
accomplish- which is way more than anything you contributed.
What, precisely, is the value added by that?
If there is any, I cannot fathom it.

Well- that's your problem then. I am not going to waste even as little
as 5 minutes drawing an MSI level diagram for some ingrate who may or
may not deign to give it the time of day.
When the OP mentioned "CPR" it was shorthand
for "Counts Per Revolution". I cannot tell what your
"CPR" input would be in this context.

It was the OP himself who said that CPR was an input parameter for his
controller's configuration file. What the hell else could it mean?
I take it that by "problem" you mean my claim
that "hunting is likely to be worsened". While I
hesitate to attempt to educate you about what
happens in positioning systems connected to
real hardware, with all its non-linearities and
dynamics, I will allude to the fact that getting
some error feedback for a smaller error can
allow finer correction. With your intellect, I am
sure you can work out the details.

Apparently you missed the part about it being a router tool- these
people set-up their work before each run and the OP apparently thinks
1/250th revolution resolution is good enough.
I feel no need or compulsion to prove myself
to you. If the OP finds Mac's solution less than
satisfactory, I will be happy to lend a hand.

You haven't leant much of a hand so far- making a mountain out of a mole
hill.
 
F

Fred Bloggs

Larry said:
Yes, that's why I posted.




Irrelevant. What clock can you construct, in this
universe, that will cause A_OUT and B_OUT to
be anti-phase when, for some inputs, they have
the same value?

What is "clk"?
 
F

Fred Bloggs

Larry said:
Yes, that's why I posted.




Irrelevant. What clock can you construct, in this universe, that
will cause A_OUT and B_OUT to be anti-phase when, for some inputs,
they have the same value?

There is no conceivable way a single counter can produce true quadrature
outputs synchronous to the appropriate edges. You would need to use some
dumb doubler thing. Why don't you have the counter count its output as
"clk"- that would be as rational as anything else you have suggested
thus far.
 
F

Fred Bloggs

Larry said:
I take it that by "problem" you mean my claim
that "hunting is likely to be worsened". While I
hesitate to attempt to educate you about what
happens in positioning systems connected to
real hardware, with all its non-linearities and
dynamics, I will allude to the fact that getting
some error feedback for a smaller error can
allow finer correction. With your intellect, I am
sure you can work out the details.

Controller- shmoller/ there is no way in hell any general purpose
positioning system is going to set itself up for "hunting" by adjusting
around what by definition is an encoder boundary - and an encoder that
may or may not be detented at that. What are you going to do? Jog the
thing into what you imagine to be mid- resolution cell? Now it will jog
into mid- 1/250th instead of 1/1000th. All of this is dog standard
practice- to listen to you, you invented the whole field.
 
Top