# Divide by n, where n is selectable

Discussion in 'General Electronics Discussion' started by n7hmw, Jul 24, 2014.

1. ### n7hmw

1
0
Jul 24, 2014
I am manually sequencing through the outputs of cascaded 4017's using the basic design found at the bottom of page 5 of http://www.ti.com/lit/ds/symlink/cd4017b.pdf , including the reset, making this a run-of-the-mill divide by n circuit. The catch is, n needs to be selectable from a set of values.

What is the best way to select n? My idea is to use another 4017 (or two) to cycle through the options. I'm not sure from there what the best way would be to then trigger the reset at the appropriate step. I could use AND gates between each of my selectors and their corresponding output pins in the array, and then OR these together to the reset of the first chip in the array.

That would get the job done, but it seems rather clumsy to me. What if I had 20 different values for n? That is a lot of AND gates and a huge OR.

Is there a better/more elegant way of doing this? I'd like to do it in logic if possible, so no rotary switches, and ideally no microcontroller.

2. ### KrisBlueNZSadly passed away in 2015

8,393
1,271
Nov 28, 2011
Hi there and welcome to Electronics Point

How about a binary counter and a magnitude comparator? Feed the divisor into one side of the magnitude comparator and reset the counter when the count matches the divisor and the magnitude comparator output goes true. Detect wraparound by NORing the counter outputs together; when they're all zero, the NOR output goes high for one input clock cycle.

I'll suggest some components.

3. ### Laplace

1,252
184
Apr 4, 2010
Avoid the magnitude comparator with a pre-settable counter and using the carry-out for the pre-set. The divisor is the difference between the maximum count and the pre-set value.

KrisBlueNZ likes this.

8,393
1,271
Nov 28, 2011