# How to fake an encoder signal with one function generator?

I wish to be able to have a encoder quadrature signal that I could set the frequency to some specified values (from 10 to 60 Hz). I have a function gen that fulfills the freq requirements but it has only one output.

So the question: is there some kind of circuit (analog or IC) that I could use to add 90 degrees of phase to a signal generated by a function gen, and then use both as they were the outputs of the encoder. It means that the gain should be unitary as well.

Thanks for any help!!!

• Whole bunch of inverters ought to do the trick! (Just kidding, don't try that.) – NickHalden Sep 14 '12 at 15:59

I would try following approach:

1. Set the frequency of the function generator 2 times higher then the desired frequency (so 120Hz if you would like to have 60Hz)
2. Build the divider by 2 with quadrature output with 74** logic chips. There are many solutions available, schematic of the one that could work is shown below *). It uses one chip with two D flipflops (for example 74??74) and one 74??86 chip with 4 xor gates (only 2 are used).

*) I have just drawn it without any simulations or prototyping. It is not guaranteed to work, but you get the idea.

• Hi there, @mazurnification. Thanks so much for helping. I've just tested your idea and it works as expected. Couldn't ask for better. Really appreciate the drawing. Thanks again! And thanks all of you other guys. – Bergamin Sep 17 '12 at 19:35

Like Dave says an RC filter will give you a delay, which emulates the quadrature signal. Use a Schmitt-trigger to follow the filter. Unless you use a potmeter for the resistor the RC time constant will be fixed, while your frequency varies. That means that the phase shift will vary as well. To make sure you don't get more than 180° shift you could calculate the RC time for about 90° at the highest frequency, then at the lower frequency it will be less than that. 90° at 60 Hz is 4 ms, then depending on the Schmitt-trigger's threshold levels the RC time constant should be around 5 ms. A 4.7 kΩ resistor + a 1 µF capacitor will do the trick, or 47 kΩ + 100 nF, for instance.

You don't really need 90° of phase shift across the whole frequency range you're interested in, you just need enough of a fixed delay so that the circuit you're driving can distinguish the two edges.

A simple R-C circuit followed by a buffer or gate should do the trick; if you use an XOR gate, you can use the other input of the gate to reverse the apparent direction of movement by switching it from low to high.

A two-chip approach which would allow "smooth" control of start/stop and direction would be to use a quad flop with complementary outputs (e.g. 74HC175) and a 4x2 multiplexer chip (e.g. 74HC153). Drive two of the flop inputs with the inputs that should control speed and direction (they can equally easily be wired to behave as "run" and "direction", or "run CW" and "run CCW"). The other two flop inputs should be tied to the outputs of the multiplexer. The multiplexer "select" inputs should be tied to the first two flop outputs (the ones controlled by the direction inputs). The "data" inputs to the multiplexers should be wired such to yield the desired behavior for the various direction modes:

• For stationary, wire them so D2=Q2 and D3=Q3
• For clockwise, wire them so D2=Q3 and D3=/Q2
• For counterclockwise, wire them so D2=/Q3 and D3=Q2

Wiring the circuit in that fashion should yield clean outputs that will move up or down by one click per cycle when the directional buttons are pushed, and remain stationary when the buttons are released, with no "weird" actions on a button press or release. The addition of a 74HC174 would make possible a "single-step" feature (bringing the circuit total up to three chips plus the function generator that produces the clock).