Author Topic: counter required to count to near 1 million  (Read 30559 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #25 on: March 18, 2013, 07:10:12 am »
the MCU is out, I'm getting fed up with MCU's at the moment as nothing about C is made simple and when you nearly have your problem solved but for a detail and ask a question on a forum you get told you missed some basic concept and have to go back to learning. Waste of time.

Sounds like you need to put in some time to learn how to write (C or asm) code.  The real waste of time happens when you refuse to learn.

I conclude my dyslexia must be worse than I realized as what seems simple to everyone else I am mystified by. I will go forth with the arduino for now (I never dreamt I'd ever have to say that) as at least stuff is plainly explained all in one place and I don't have to read books written for PC's to adapt to different hardware and try and understand how to use libraries.
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2797
  • Country: au
Re: counter required to count to near 1 million
« Reply #26 on: March 18, 2013, 08:07:45 am »
Honestly, some people poo-poo the Arduino but it really can help people get over that initial hurdle in programming.

I even used one recently to delve into the world of touch screens at short notice.  Thanks to the "sketches" available I had it running in minutes. That showed me that it should be equally doable on a PIC without reinventing the wheel.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #27 on: March 18, 2013, 08:14:08 am »
you may not be doing it on a pic as it is avr's that have built in touch sense interfaces. Unless your looking at a secondary unit dedicated to the touch bit
 

Offline David_AVD

  • Super Contributor
  • ***
  • Posts: 2797
  • Country: au
Re: counter required to count to near 1 million
« Reply #28 on: March 18, 2013, 08:20:21 am »
you may not be doing it on a pic as it is avr's that have built in touch sense interfaces. Unless your looking at a secondary unit dedicated to the touch bit

Almost all of the TFT screens with touch on eBay, etc come with the LCD controller and touch A2D chips.  The UTFT and UTouch libraries make it super simple on the Arduino and it shouldn't be too much harder on a PIC.   :)
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #29 on: March 18, 2013, 08:30:59 am »
So do I need to specifically look for a synchronized counter to make sure it does not drift off timing due to propagation delays ?

Anyone got an answer ?
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: counter required to count to near 1 million
« Reply #30 on: March 18, 2013, 09:21:35 am »
So do I need to specifically look for a synchronized counter to make sure it does not drift off timing due to propagation delays ?

Anyone got an answer ?
If my memory serves me well, the propagation delay issue was quite high in frequency, between 10 and 20 MHz.

Take a look at the 74HC4060 you can use a couple of those to divide the 32.768kHz down to 2 Hz (divide by 256 and divide 64). It has internal gates for hooking up a crystal- or rc-oscillator.
 

Offline marmad

  • Super Contributor
  • ***
  • Posts: 2979
  • Country: aq
    • DaysAlive
Re: counter required to count to near 1 million
« Reply #31 on: March 18, 2013, 09:32:38 am »
So do I need to specifically look for a synchronized counter to make sure it does not drift off timing due to propagation delays ?

It's not about drift but unstable outputs (since overflow ripples). For most uses (especially divide-by-n), it doesn't make any difference.

Take a look at the 74HC4060 you can use a couple of those to divide the 32.768kHz down to 2 Hz (divide by 256 and divide 64). It has internal gates for hooking up a crystal- or rc-oscillator.

As mentioned already, the 4541 is a better chip than the 4060 - and also has the built-in oscillator..
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: counter required to count to near 1 million
« Reply #32 on: March 18, 2013, 09:52:18 am »
how would it work?
32768Hz / 16384 = 2 second clock
2Hz / 60 = 33ms clock

Having a bad day Psi?
32768Hz / 16384 = 0.5 second
0.5 second / 60 = 30 second
Just saying...

lol, yeah, bad day  ::)
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #33 on: March 18, 2013, 10:08:56 am »
I think i may be getting confused between lack of synchronization between outputs and frequency error. I'll have a look at some of the suggested parts
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #34 on: March 18, 2013, 11:04:30 am »
The 4541 will not use a crystal and only has certain outputs available
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13695
  • Country: gb
    • Mike's Electric Stuff
Re: counter required to count to near 1 million
« Reply #35 on: March 18, 2013, 11:55:33 am »

 :-DD Then I guess my suggestion of PIC10F200 is way the hell out! With 384 bytes ROM and 16 bytes RAM, I don't think you'd have much luck programming it in anything but assembly.

It's entirely feasible to do C on the 10F200 (using the non-free version of the microchip compiler).
If written carefully, efficiency isn't that far off assembler.
For something a simple as this, probably even the free version and sloppy coding would still do the job
 
 
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #36 on: March 18, 2013, 11:58:18 am »
except I want to do this the old fashioned way. It will drive an old clock so still be in keeping ;)
 

Offline marmad

  • Super Contributor
  • ***
  • Posts: 2979
  • Country: aq
    • DaysAlive
Re: counter required to count to near 1 million
« Reply #37 on: March 18, 2013, 12:36:18 pm »
The 4541 will not use a crystal and only has certain outputs available

True - I've always had an external clock available when I used it - although I do wonder if hooking a crystal up to the RC pins (as shown for a 4060) wouldn't work just fine - I'll have to breadboard that if I get a chance. As far has only having certain outputs available, for high counts (like one million) the salient point is the highest division output - with a 32kHz frequency, the 4060 divides down to a minimum of 2Hz; the 4541 down to .5Hz - which just means 4 bits more needed to get to .033Hz (30 seconds) - instead of 6.

But in any case, if you use a divide-by-n counter as the final stage you can avoid extra decode logic. So if you combine a 4060 (2Hz frequency at it's 2^14 output) with, for example, a MC14569B (which is a divide-by-n dual 4-bit counter), you can have any timing period between 1 - 127.5 seconds (in .5 second increments) - settable with switches if desired.
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #38 on: March 18, 2013, 12:41:31 pm »
yes that is true
 

Offline olsenn

  • Frequent Contributor
  • **
  • Posts: 993
Re: counter required to count to near 1 million
« Reply #39 on: March 18, 2013, 12:44:05 pm »
I just finished making a frequency counter with the Timer/Counter1 module of a Atmel Atmega328P. Technically the counter is 16-bit, but by incrementing a variable on overflow, you can keep track of as many counts as you'd like.

I'm not sure if this helps?
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #40 on: March 18, 2013, 12:45:06 pm »
well I'm going to avoid an MCU on this one
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13695
  • Country: gb
    • Mike's Electric Stuff
Re: counter required to count to near 1 million
« Reply #41 on: March 18, 2013, 01:45:50 pm »
In terms of cost vs. division ratio, the (74hc)4020,40 and 60 are hard to beat if you can live with binary ratio. The HC4060 has an oscillator as well, so probably a very cheap 2-chip solution.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #42 on: March 18, 2013, 03:07:17 pm »
what do you mean by binary ratio ? like 1000 versus 1024 ?
 

Offline marmad

  • Super Contributor
  • ***
  • Posts: 2979
  • Country: aq
    • DaysAlive
Re: counter required to count to near 1 million
« Reply #43 on: March 18, 2013, 03:40:00 pm »
what do you mean by binary ratio ? like 1000 versus 1024 ?

Most discrete chips which can count very high are binary counters, so they do binary division - divide by 2, 4, 8, 16, etc; i.e. 2^n.  This matters when you consider what frequency you are starting with - and what frequency you want to end up with. In your case, starting with 32.768kHz and wanting to end with .033Hz means that you can't do it with a simple binary divide. OTOH, if you wanted to end up with a 32 second pulse, this would be easy to do with a single chip (like the MC14536B) since .03125Hz is 32768 divided by 2^20.

Since you want a final frequency which is not evenly divisible (from 32768) by a power of 2 (and you don't want to use an MCU), you have to use a minimum of two discrete chips - either two counters or a counter and decode logic. In binary terms (or hex for easier writing), you want to divide 8000h by F0000h.
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16272
  • Country: za
Re: counter required to count to near 1 million
« Reply #44 on: March 18, 2013, 03:49:59 pm »
Divide by 2 instead of divide by ten. Much simpler with the logic, as there is only one pin to decode. With divide by 10 you need to decode a few pins to get the terminal count and use that to reset the counter.

As to ripple counters having issues, it is only if you are using them and decoding the outputs, which can very briefly have invalid counts as the counters change state, the count ripples down the chain from the fastest to the slowest. Only an issue if you are latching the outputs, if you are going to just decode to get the TC to reset you just add a RC delay to the comparator output to both ignore these very short duration pulses and to get a long enough reset pulse so the counters are going to be reset correctly ( nothing worse than having half the counters being reset by a too short pulse, it just needs to be less in time than a half of your clock, at 32kHz that will be pretty long).

If you are using a clock crystal drive it with a 4007 uncommitted gate, there is a 32kHz oscillator in the appnotes that has both low drift and low drive so it has best accuracy.

Otherwise just take a clock module and power it off 1V5 from a red LED, and use the drive pulses to clock a pair of 4017 chips arranged as a divide by 3 and the other as divide by 10 ( no jumpers at all) and use either the carry out to give a 15s pulse or one of the count outputs to give a 3s clock.
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: counter required to count to near 1 million
« Reply #45 on: March 18, 2013, 04:24:58 pm »
I think Sean has covered most of it.
I would just point out that the internal oscillator of the '4060 can drive a 32768Hz crystal e.g. http://www.doctronics.co.uk/4060.htm.

Turn away now Simon. :)

As an idea of what can be done with a PIC see http://www.leapsecond.com/tools/PPSDIV.ASM
9 simultaneous square wave outputs -- one for each frequency decade from 100 kHz to 0.001 Hz (1000 s) from a 10MHz clock!

Jim
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #46 on: March 18, 2013, 04:36:22 pm »


Turn away now Simon. :)

As an idea of what can be done with a PIC see http://www.leapsecond.com/tools/PPSDIV.ASM
9 simultaneous square wave outputs -- one for each frequency decade from 100 kHz to 0.001 Hz (1000 s) from a 10MHz clock!

Jim

The sort of thing I'd have been doing as a full version but not right now. I just need to get this thing ticking every 30s
 

Offline marmad

  • Super Contributor
  • ***
  • Posts: 2979
  • Country: aq
    • DaysAlive
Re: counter required to count to near 1 million
« Reply #47 on: March 18, 2013, 04:39:29 pm »
If you are using a clock crystal drive it with a 4007 uncommitted gate, there is a 32kHz oscillator in the appnotes that has both low drift and low drive so it has best accuracy.

As many people already pointed out here, you can hook a 32kHz crystal directly to a 4060 - so why would you need a 4007?

Quote
Otherwise just take a clock module and power it off 1V5 from a red LED, and use the drive pulses to clock a pair of 4017 chips arranged as a divide by 3 and the other as divide by 10 ( no jumpers at all) and use either the carry out to give a 15s pulse or one of the count outputs to give a 3s clock.

Not sure what you mean by 'clock module', but this solution seems odd to say the least. The frequency he's after is not evenly divisible by 10 either, so why use decade counters? It's less counting in the same package size - and even with two of them cascaded the lowest frequency you could get from 32.768kHz is 327Hz - far from what he's after. This makes no sense - in less, by 'clock module' you mean a NON-discrete logic chip - which seems to defeat the point of the discussion - I thought we were talking about how to accomplish it with a couple of discrete chips.
« Last Edit: March 18, 2013, 04:42:23 pm by marmad »
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: counter required to count to near 1 million
« Reply #48 on: March 18, 2013, 04:42:29 pm »
At the moment I'm looking at a 4541 followed by any other counter that will finish it off right. As I'll have logic gates knocking around anyway I can use one or two to make the clock gen
 

Offline marmad

  • Super Contributor
  • ***
  • Posts: 2979
  • Country: aq
    • DaysAlive
Re: counter required to count to near 1 million
« Reply #49 on: March 18, 2013, 04:52:11 pm »
At the moment I'm looking at a 4541 followed by any other counter that will finish it off right. As I'll have logic gates knocking around anyway I can use one or two to make the clock gen

What are your parameters for the output pulse (I mean, aside from the 30s frequency)? Is there a minimum or maximum pulse length?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf