up/down counter signal conversion

Thread Starter


Joined Jun 9, 2013
I have 8 opto-isolated paraport pins to drive 3 bipolar steppers on my cnc router. Since the two pins per side of my L298's are always opposite each other, I inverted one input, allowing me to use one signal to reverse polarity just by changing the logic state on the, now, single input.
The required sequence to both sides of the h-bridge is 00, 01, 11, 10...reversing it reverses motor direction.
I can get 00, 01, 10, 11 from an up/down 2 bit counter but the least significant bit of the last two outputs are inverted for what I need.
I had thought of putting some tristate switches on the counter's lsb, to invert the lsb output when msb is high but have yet to come up with a circuit to accomplish it.
Any help is greatly appreciated.


Joined Mar 14, 2008
You want a Gray code sequence. You can use a dual D-FF to easily get that as shown below.

Edit: Added XOR gate to allow control of the forward/backward sequence.

Grey counter.gif
Last edited: