How to count pulses per second ?

Hi, I'm hoping someone could help me create a very basic circuit which would:

Count the number of pulses it receives per second (from a 555 timer, or a switch, for example) and if the number of pulses per second is equal to, or greater than 10 it turns on a transistor.

So basically it should check every second if a clock frequency of 10Hz is being met - if so, a transistor should turn an LED on and keep it on for as long as 10Hz a second is hitting the circuit. As soon as the clock stops, or the frequency goes below 10Hz, it should turn off the LED.

Thanks so much for your help !

MC

Reply to
Mike C
Loading thread data ...

Microcontroller sounds like the best bet. A PIC 16F628 would be ideal for this. Much easier than messing about with lots of inflexible logic. Also a good grounding too for future projects. With a 4Mhz 628 you could realistically count upto about 100Khz with some decision making in there too. (actually runs at 1MIPS though).

A programmer (suitable for the 628) will set you back say £20 tops. One of the easier chips to program. MPLAB is also free.

Lots of examples on PICLIST (type it into Google)

Reply to
Aly

Thanks for your help. I actually considered that option, but I was under the impression that a simpler circuit could do this job.

o a

e of

Reply to
Mike C

--
That can be very easily done with a single retriggerable one-shot
with a 100 millisecond timeout.  What\'s your application and what
 Click to see the full signature
Reply to
John Fields

JF:

I dont need this to be too accurate... I'm collecting the number of times an IR beam gets broken, and if it gets broken faster than 10 times a second, I need to trigger a transistor and keep it on for as long as the beam is broken at a rate of 10Hz or above.. (this beam gets broken with human intervention, so freq could be variable, anywhere from 0Hz to 20Hz, and may not necessarily have an even duty- cycle)

Thanks so much for your help !! MC

Reply to
Mike C

--
Nonsense. I can do it with one chip, one resistor, one capacitor, no
programmer and no learning curve. 
 Click to see the full signature
Reply to
John Fields

:)

I'd have to agree w/ JF. Learning curve would be big (at least for me).. the "one-chip in a few hours" would just work so much better :) JF: would you be able to shed some light on what I should do. (A schematic would be simply amazing)

MC

Reply to
Mike C

--
Basically, what you do is set up a retriggerable monostable
multivibrator (one-shot) so that as long as the edges which trigger
 Click to see the full signature
Reply to
John Fields

I learned to program PICs _once_, it took every bit of a few days. I don't understand why the "PIC haters" all use this as their primary argument; as if it's something you go thru for every project. Electrical theory is way harder IMO.

The OP said that you can't depend upon duty cycle or pulse regularity. Sounds like the circuit will literally have to count the actual number of pulses that occur in one second to meet his requirements. The OP hasn't stated if this kind of latency would be acceptible, but he didn't say it wasn't either.

I could have working code to do this in about 1 hour. Given that, I'm going with the micro on this one for a solution with the smallest number of parts (1 PIC, some juice and an input buffer (a resistor may be more than enough). AFAIK, a discrete solution to do the above described work would require allot more parts (a one second clock, resettable decade counter, output compare and latch).

OTOH, if a 100mS retriggerable timer will do, then you win. Or I could just change the code. ;-)

Reply to
Anthony Fremont

Yes but an 8 pin PIC could do this without a timing resistor and capacitor and do it in an absolute counting way that handles irregualr pulse timing like from a person pushing a switch. It would require writing some simple code and programing, of course, but would be cheaper and more stable and have a lower parts count and a smaller footprint than the one shot. The 25mA output current will drive LED's better than a one-shot. The clock is internal, no other parts required except a bypass cap and LED resistor that you have to have anyway. The one shot is OK for a do it once solution but is not the best for even moderate production of a few units. Besides, once one learns how to program and blow parts, there is no limit to what else can be done. That's a much more valuable learning curve than screwing with a one-shot.

Reply to
Bob Eld

Guys, thanks alot for your responses, all excellent & informative posts. I will most definately attempt this solution with a pic at a later time, convincing arguments in favor of the pic... and any suggestions with regards to obtaining a good and relatively inexpensive pic starter kit are definately appreciated.

In the meantime, I'd like to attempt a temporary quick-fix to my problem, as i'm working with limited components in a relatively short time-frame.

JF: I'm not sure if a monostable would fix the problem (but correct me if im wrong) Two conditions need to be met:

  1. If and only if the pulse train coming in >=10Hz (10 "up" cycles per second with no particular duty-cycle pattern) only then turn on a transistor.
  2. Otherwise, if the pulse train count goes below 10 cycles at any point, turn off the transistor at once.

So the output should be HIGH only if 10 cycles per second (or higher) are counted, otherwise output is LOW.

I'm afraid I still dont have a working solution (PIC programming aside :)

Guys, thanks for all your help again.

Reply to
Mike C

If available, there is an 8 pin chip called the 567 that is a tone decoder. It doesn't count pulses it compares frequencies. Might be of use. bg

Reply to
bg

--
Please bottom post.

That\'s a horse of a different color, I think.
 Click to see the full signature
Reply to
John Fields

JF: Correct, i need to "detect the occurrence of 10 or more pulses in one second regardless of the pulse width and separation between pulses", and the LED to "come back on automatically if it subsequently rose to >= 10pps" .... so the only time the LED would be off if pps

Reply to
Mike C

--
Try this (View in Courier)

Vcc--------------------+--------+------+
 Click to see the full signature
Reply to
John Fields

--
I just noticed on sed that you\'ve multiposted this thread instead of
crossposting. It would be better if you crossposted, since that way
 Click to see the full signature
Reply to
John Fields

JH: Excellent suggestion. I truly appreciate all your help, especially the schematic. I will be ordering the HC4017 to do the trick.. hopefully it'll be here in a few days... in the meantime, i'm trying to simulate in orcad pspice and cant find the an HC4017 equivalent in the library, what did you use to simulate (if anything) ?

many thanks again.

MC

Reply to
Mike C

Does someone sell a pic-for-beginners kit?

I'd like to get into it but I really don't want to take the time to build my own cable and put together my own programmer....

(It's not that I am lazy; I literally don't have the time. I am an embedded programmer by profession and do this all the time at work - so I don't want to spend my hobby time building cables and debugging the development environment; I want to be able to program the thing....)

I am really looking for a linux-based solution as well.

I am willing to buy a homegrown kit - if an individual has one to sell or if someone is building these semi-commercially.

Thanks,

--Yan

Reply to
CptDondo

--
I didn\'t, but I think your library has a 4017 in it, no?
Reply to
John Fields

If I can throw in my two cents, I'd recommend checking out the AVR series of microcontrollers by Atmel. They are in a similar price range, are much faster, have a greater feature set and are much easier to program. Atmel's own high quality development environment AVR Studio is free, along with a complete suite of open source stuff including the GCC C / C++ compiler.

The best part is that AVRs can be programmed in circuit with a parallel port cable and a pair of wire cutters. If you don't want to mess around with that you can get some cheap programmers at

formatting link
but I prefer the slightly more expensive AVRISP Mk II from Atmel, which is about $30 from Digikey. It's USB and is supported by AVR Studio and all the open source programmers.

I like the ATMega8 as a good starting point and prototyping microcontroller. It's got 8K of program Flash, 1K of SRAM and 512 bytes of EEPROM along with a ton of peripheral features. A simple circuit to get one running requires only power, ground and a 10k pullup on reset. The ATMega8 has a built in RC oscillator up to 8MHz (8 MIPS!) and you can get em for a few bucks on Digikey.

I hate to sound like an advertisement but I used to work with PICs and then I found AVRs. When I was working with PICs (about 4 years ago) they were a big pain in the butt. Programmers were complicated, there was no good, free C compiler and Internet resources were limited. Maybe the PIC scene has gotten better but AVRs just keep getting nicer and I see no reason to go back to using PICs.

Here's an instructable on getting started:

formatting link
Don't know if it's any good or not but it looks like it covers the basics.

Jason von Nieda

Reply to
Jason von Nieda

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.