# Generate a false encoder signal CW/CCW 1/4 shifted

I need to generate a 10-100khz square signal freq. to simulate an encoder.

I'd like to be able to simulate CW and CCW, shifted by 1/4 th signal. I've thinked about a crystal with a pot and some logic gates. But don't have enought experience to create a circuit like this.

Can you redirect me to a sample schematic or components to start with?

Ex.

/* UPDATE */

10khz-100khz 24v

Why: it's becouse I'd like to have a tool to simulate motor encoder output to debug my system which has an encoder input.

A micro or develop kit it's too expensive and overkill. Also low cost micro have difficults at this freq.

• You need to think this through a lot more and provide detail in your question. (1) Do you want a precise number of steps? If so, you'll need a counter. (2) Clarify if it's 10 Hz - 100 kHz or 10 kHz to 100 kHz. Your question could be read either way. (3) What voltage is your logic? – Transistor Mar 18 at 11:28
• You need to give a good reason why you need to emulate an encoder when it would be just as easy to use an actual encoder to generate your pulses. – Michael Karas Mar 18 at 11:37
• Thanks, Singed, for the update. This sounded very much like a motor encoder issue. (I worked on a system to calibrate and align infusion pump motors for medical use and the frequencies you mentioned were about right.) Do you already have access to a frequency generator? (Commercial or 555 timer based or any other source of some adjustable square wave?) Also, do you need to control the number of pulses for your tests? Or is it sufficient that it simply generates a forward/backward pulse train whose frequency can be only blindly varied (imprecise but variable?) – jonk Mar 18 at 20:16

I'll assume you can work out the variable square wave oscillator. This might be a 555 timer based design (found everywhere), though you may need to put its output into a JK FF to divide the frequency by two in order to square it up to a clean 50/50 duty cycle.

The following circuit doesn't involve an MCU (which for many reasons might still be your better appraoch.) It's just a simple bit of logic that assumes you can supply it with a square wave at $$\4\times\$$ the actual rate you want. The counter is synchronous and so the output should be relatively clean.

simulate this circuit – Schematic created using CircuitLab

The above system requires two D-flops (in a twisted ring Johnson counter arrangement) and two muxes (to make the twisted ring Johnson counter reversible.) Shouldn't be difficult to select appropriate logic families and then wire it up. Something like the 74LS175 and 74LS157.

If my head is on straight, setting the UP/DOWN to 0 will have A leading B and to 1 will have B leading A.

EDIT: I liked the muxes shown above better because you can get quads of them in a single IC package and because I enjoyed the relative symmetry of it. And so I avoided writing the following, earlier. I've got a moment to add the other thought in my head (not as nice, though, in my opinion.)

So, if you don't like muxes for some reason or otherwise don't mind multiple IC packages with different gate types, then you could use the following schematic instead (or any of nearby varieties of it):

simulate this circuit

This also doesn't use the $$\\overline{Q}\$$ output of the D-type FF. (That may expand your options a little for the D-type FF devices.) But now you can't get everything into two packages (or at least, nothing comes to my mind where only two SSI/MSI ICs might be used.)