xx4059 divider + shift register

Thread Starter

bribri

Joined Feb 20, 2011
143
hey so, I want to count some clock pulses,
1084 of them for example,
and I was thinking, with a 74HC4040 i could take the ÷1024 output, and then with some gates get the ÷32, ÷16, ÷8, ÷4 to make up the remaining 60 pulses.

but from reading the forums here, it seems the 74hc4059 ÷ by n counter might be the way to go...
to use the ÷10 mode and make up the remaining 024 counts all on the same chip without a bunch of external gates.

so here's my questions. if I wanted to count to 1084 with a hc4059, and then count to, say, 41 immediately after (before looping back to a 1084 count),
would there be a trick for using remaining flip-flops on the chip to achieve that?
or might one be able to periodically change the jam programming of the 4059 with some kind of shift-register?
and if so, what kind of shift-register might i be looking at?
i'm assuming some kind of parallel-in-parallel-out arrangement, but i'm a bit lost as to the details there.
and also, if it's possible in a more or less routine kind of way,
what about stringing together, say, 4 or 5 different pulse counts into a loop?
 

djsfantasi

Joined Apr 11, 2010
9,163
An ATTiny85 is $1.25 or less. Sparkfun has a USB programmer for it at $17.95. The latter can be used for ATTiny’s in your future. One pin for the clock input. Two pins for the divide by 1084 & 41. You can sequence the counts in the code.

If I get a chance, I’ll post some code to get you started.
 

Thread Starter

bribri

Joined Feb 20, 2011
143
An ATTiny85 is $1.25 or less. Sparkfun has a USB programmer for it at $17.95. The latter can be used for ATTiny’s in your future. One pin for the clock input. Two pins for the divide by 1084 & 41. You can sequence the counts in the code.

If I get a chance, I’ll post some code to get you started.
ah this is very interesting : )
and some starter code would be most welcome (thanks!)

should i assume 1 clock cycle per instruction with this approach?
i'm tempted to dispose of a oneshot chip i've planned on using for this project also,
and just do that part with the micro controller also...
but i guess i'd need a higher clock frequency and divide it down.
there's a few simultaneous changes should really be synchronous (but maybe almost synchronous is good enough)
 

Thread Starter

bribri

Joined Feb 20, 2011
143
You can program an ATTINY85 with a $4 Arduino UNO board.

You can also do a lot with mBlock or Ardublock if you are not a programmer -

https://forum.allaboutcircuits.com/threads/visual-programming.157949/#post-1370895

https://forum.allaboutcircuits.com/...with-component-selection.158302/#post-1375383 see post #9


Regards, Dana.
also most interesting... thanks also.
i'm not a programmer however i think coding (if it's anything resembling something like pbasic) would be easier for me
 

djsfantasi

Joined Apr 11, 2010
9,163
ah this is very interesting : )
and some starter code would be most welcome (thanks!)

should i assume 1 clock cycle per instruction with this approach?
i'm tempted to dispose of a oneshot chip i've planned on using for this project also,
and just do that part with the micro controller also...
but i guess i'd need a higher clock frequency and divide it down.
there's a few simultaneous changes should really be synchronous (but maybe almost synchronous is good enough)
No, don’t assume anything.

You have an external clock providing pulses, correct?

This would be input to the μP (the ATTiny85). The μP would count these pulses up to 1084, and provide one output pulse on a GPIO pin.

Then the μP would count the pulses to 41 and provide an output pulse on another pin. Or if your design calls for it, on the same output pin. You’d have to let me know.

Then what? Do you want the sequence to repeat?

BTW, the input clock should output a 5V signal. And the output(s) will also be 5V. The ATTiny will need a 5VDC power supply. (it actually has a broader range; check the datasheet!)

In the off chance that you’re counting all these pulses just to implement two different delays, that can be done internally to the μP without any clock input. I mention this because you haven’t stated what the clock is being used for nor what is the purpose of the output(s).
 

djsfantasi

Joined Apr 11, 2010
9,163
Another thing...

Take a look at this link to the Arduino C variant reference page.

You might find it instructive. The ATTiny supports this language, and is in fact programmed through the Arduino IDE. When you purchase the Sparkfun programmer, it’s tutorial contains a link to the libraries necessary.
 

Thread Starter

bribri

Joined Feb 20, 2011
143
No, don’t assume anything.

You have an external clock providing pulses, correct?

This would be input to the μP (the ATTiny85). The μP would count these pulses up to 1084, and provide one output pulse on a GPIO pin.

Then the μP would count the pulses to 41 and provide an output pulse on another pin. Or if your design calls for it, on the same output pin. You’d have to let me know.

Then what? Do you want the sequence to repeat?

BTW, the input clock should output a 5V signal. And the output(s) will also be 5V. The ATTiny will need a 5VDC power supply. (it actually has a broader range; check the datasheet!)

In the off chance that you’re counting all these pulses just to implement two different delays, that can be done internally to the μP without any clock input. I mention this because you haven’t stated what the clock is being used for nor what is the purpose of the output(s).
for the sake of getting started with a ATTiny i'm looking at an external clock (TTL in the KHz range)
either a short pulse or a 50% duty cycle, not sure yet.
output should be 2 different pins, one for each delay.
then the routine loops.

i do want to try a number of different approaches.
this would include clocking the ATTiny internally with a crystal,
but in the MHz fq range... so that instead of an external VCO
...and then using a 3rd GPIO as my clock source for the rest of circuit and dividing that down to the values I need.
i'm not sure how much jitter i can get away with, but prudence says (or implies) i'll get less jitter in the KHz range by dividing a higher fq clock source.

to be honest i'm still not sure what approach to VCO i need to follow.
some kind of a fixed frequency oscillator..

ultimately i'm trying to cook up a few different video-sync processing circuits to try out some ideas
 

djsfantasi

Joined Apr 11, 2010
9,163
for the sake of getting started with a ATTiny i'm looking at an external clock (TTL in the KHz range)
either a short pulse or a 50% duty cycle, not sure yet.
output should be 2 different pins, one for each delay.
then the routine loops.

i do want to try a number of different approaches.
this would include clocking the ATTiny internally with a crystal,
but in the MHz fq range... so that instead of an external VCO
...and then using a 3rd GPIO as my clock source for the rest of circuit and dividing that down to the values I need.
i'm not sure how much jitter i can get away with, but prudence says (or implies) i'll get less jitter in the KHz range by dividing a higher fq clock source.

to be honest i'm still not sure what approach to VCO i need to follow.
some kind of a fixed frequency oscillator..

ultimately i'm trying to cook up a few different video-sync processing circuits to try out some ideas
Ok, I’ll see what I can do to whip up some sample code. But here’s a pseudo-code description.

What I’ll do is plan on connecting the clock to an interrupt pin. Then, an ISR simply increments a counter, which will be defined as a global unsigned integer.

The setup will define pins 1 & 2 as outputs. It’ll define pin 7 (INT0) as an input and attach the ISR to it.

The main loop will define a Boolean variable, longCount, initializing it to be true.

Then if longCount && counter==1084,
Output a pulse on pin 0,
reset counter to 0,
invert longCount​
Then if not longCount && counter==41
Output a pulse on pin 1,
Reset counter to 0,
Invert longCount​
If counter == someValue (length of output pulse)
Output a low signal to both output pins.
That should do it for you! Anything else is ‘gravy’.
 

Thread Starter

bribri

Joined Feb 20, 2011
143
also in the meantime I'm still going to mess around with the HEF4059,
because reasons.
since i can't think of a (simple) way to change 16 jam inputs plus 3 preset pins on the go...
it will be just one count for now.

my chosen clock oscillator is 74HC4060 with a crystal. (17MHz)

the chip is producing my intended frequencies,
and rock-solid at that : )
but I'm confused because measuring q7 or q8 or whatever suggests a
17MHz crystal oscillator is running at double the speed...
...so unless i've managed to confuse myself about the 4060's outputs ...

anyway i better measure again... I'm assuming now that pin9 on the 4060
is a buffered output of the oscillator, so i can measure there without messing up the load capacitance yes?
 

Thread Starter

bribri

Joined Feb 20, 2011
143
HEF4059BP

i really can't get this chip to behave : (
input is really perfect i think (signal comes from 74HC4060)
but the 4059 is very unstable.

anyone have any tips on working with this chip?
 

Thread Starter

bribri

Joined Feb 20, 2011
143
wait, solved it i think.... seems output pulse was too narrow for my frequency counter...

maybe some other weird breadboard related issues also, not sure

but it works :)
 

Thread Starter

bribri

Joined Feb 20, 2011
143
i've seen schematics where people are putting a resistor between the jam-inputs (which are connected to logic high) and GND... but i'm assuming this is because they are programming with DIP switches ––– so optional i guess?
 
Top