Author Topic: Pulse counting IC with i2c interface or similar  (Read 18082 times)

0 Members and 1 Guest are viewing this topic.

Offline whiskeyjackTopic starter

  • Contributor
  • Posts: 10
  • Country: in
Pulse counting IC with i2c interface or similar
« on: November 21, 2015, 12:21:12 pm »
I am working on a project where I am using a microcontroller just for counting pulses on a digital pin. I am using Atmega328 with arduino bootloader. Is there a cheaper solution available for this? I particularly need an IC which counts rising pulses and increases a counter. I should be able to use other microcontroller (esp8266) to access that stored variable via i2c preferably and erase it once I have read that value.

EDIT:
Thanks all for the responses. I'd like to explain the use case. (Sorry I didn't do it earlier). I am using BL0921 real time energy measurement IC to monitor energy consumption by a device. This IC gives HIGH pulses at certain delay. Delay decreases as the power consumption increases. In worst case, I might be getting 10 counts or so per second. I am using arduino Esp on the esp side. I read that in the bootloader itself, there is an internal delay of 50 ms after each loop in order to keep the wifi stack running comfortably. So, I didn't want to destroy the communication anyhow by throwing too many interrupts at it. Also I was not sure how it'd behave when an interrupt is received during that internal 50ms delay period. To save myself from trouble, I chose to use atmega328 with UNO bootloader to do the job. It does the counting and every minute, it passes the count to esp via i2c and resets the count in it's memory. I was planning to save some money there.  :)
« Last Edit: November 21, 2015, 02:02:09 pm by whiskeyjack »
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1483
  • Country: 00
Re: Pulse counting IC with i2c interface or similar
« Reply #1 on: November 21, 2015, 12:25:54 pm »
There are some older I2C RTCs which could probably be abused for this, e.g. PCF8583 and similar ICs.

But they're generally more expensive than a cheap MCU.
,
 

Offline nowlan

  • Frequent Contributor
  • **
  • Posts: 649
  • Country: au
Re: Pulse counting IC with i2c interface or similar
« Reply #2 on: November 21, 2015, 12:46:40 pm »
Cmos counter?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3240
  • Country: gb
Re: Pulse counting IC with i2c interface or similar
« Reply #3 on: November 21, 2015, 01:08:15 pm »
Why not use the ESP8266 to do the counting?  It has GPIO pins that can be configured as external interrupts. 

If it has to be external with an I2C interface, then one of the cheap 8 pin PICs or AVRs would do the job e.g. PIC12LF1552 or ATtiny25.  The NXP PCF8593 calender IC can be configured as a 6 digit event counter, but not as cheap as a small micro.
 

Offline technix

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Pulse counting IC with i2c interface or similar
« Reply #4 on: November 21, 2015, 04:42:29 pm »
You can use the one of the Timer/Counter module as a dedicated counter for this, at the cost of losing a few PWM outputs.

You can even use two Timer/Counters to operate in fractional frequency counting (e.g. whatever input signal that chip generates, and a 32768Hz reference clock from a DS3231 DTCXO RTC chip) And if you step up from ATmega328P to something that can be operated that fast a reference clock, you can use a 10MHz reference signal and commence timenutting (e.g. Rubidium standards)
 

Offline Berni

  • Super Contributor
  • ***
  • Posts: 4955
  • Country: si
Re: Pulse counting IC with i2c interface or similar
« Reply #5 on: November 21, 2015, 05:40:15 pm »
Use the MCUs built in timer as a counter. You can set it up so that the timer counts up by 1 every time there is a pulse on a certain pin. That way you only need to check it before the timer overflows in value and that should take a pretty long time.

If you don't want to step out of the arduino safe zone to actually touch a hardware register, then put a 74HC590 on there and have it count for you.
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16665
  • Country: 00
Re: Pulse counting IC with i2c interface or similar
« Reply #6 on: November 21, 2015, 07:10:24 pm »
I am working on a project where I am using a microcontroller just for counting pulses on a digital pin. I am using Atmega328 with arduino bootloader. Is there a cheaper solution available for this?

ATTiny85? Atmel makes a lot of smaller chips, they can all work with the Arduino IDE. Bare chips are less than $1 or you can get "digispark" devices (which are easier to program).

http://www.ebay.com/sch/i.html?_nkw=attiny85
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3383
  • Country: us
Re: Pulse counting IC with i2c interface or similar
« Reply #7 on: November 21, 2015, 07:22:20 pm »
I am working on a project where I am using a microcontroller just for counting pulses on a digital pin. I am using Atmega328 with arduino bootloader. Is there a cheaper solution available for this?

ATTiny85? Atmel makes a lot of smaller chips, they can all work with the Arduino IDE. Bare chips are less than $1 or you can get "digispark" devices (which are easier to program).

http://www.ebay.com/sch/i.html?_nkw=attiny85

What's the point, when an Atmega328 is only around $1.30?
 

Online Fungus

  • Super Contributor
  • ***
  • Posts: 16665
  • Country: 00
Re: Pulse counting IC with i2c interface or similar
« Reply #8 on: November 21, 2015, 09:50:27 pm »
ATTiny85? Atmel makes a lot of smaller chips
What's the point, when an Atmega328 is only around $1.30?
Depends on the quantity.

If you're buying so many Atmega328s that they're only costing you $1.30 then the Tiny85 will be a few cents.

And if it's very small quantities then having it on a PCB is a big plus (but if it's very small then you can get Mega328s on PCBs for about $2.50  :-// ).
 
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3383
  • Country: us
Re: Pulse counting IC with i2c interface or similar
« Reply #9 on: November 21, 2015, 10:01:40 pm »
ATTiny85? Atmel makes a lot of smaller chips
What's the point, when an Atmega328 is only around $1.30?
Depends on the quantity.

Quantity 1, from AliExpress (vs about $0.70 for Attiny85s).
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2549
  • Country: us
Re: Pulse counting IC with i2c interface or similar
« Reply #10 on: November 22, 2015, 05:05:33 am »
I would use an eight pin PIC12F1840.  The interrupt pin can trigger on a positive or negative edge.  Use the Interrupt Service Routine to count the edges.  The main loop can send the current count via the I2C interface and reset the count once sent.  The through hole package is $1.42 from Mouser.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf