Pulse generator

You may use this generator to wake up an Atmega-based external sensor. The external sensor should measure the value and output it to a UART port.

Pulse counter

It is a 32 bit counter with a configurable debounce interval (1, 3, 10, 20, 100, 1000 ms). Therefore the counter cannot be used for high-frequency signals.

If the “Interval” parameter is defined, the counter automatically resets after that interval and reports the counted values to a coordinator. If this parameter is zero, the counter increments indefinitely, and the firmware periodically reports a counter’s value.

Configuration example

The counter in the power saving mode (PSM)

The counter uses a hardware interrupt for a rising edge for a configured input. The chip wakes up with every interrupt and stays alive for three seconds. If incoming impulses are too frequent, the chip will never sleep and consume battery power. It is OK if you count a series of impulses for a short time interval.

Please, consider using a special external counter in this mode.

Zigbee2MQTT commands

read - immediately reads the counter value.
Topic: zigbee2mqtt/[friedly_name]/get/[channel]
Channel: l1, l2, l3 … l16
Payload: 1
Returns: The counter value {"[channel]": float_value}
write - resets the counter, or sets any initial value.
Topic: zigbee2mqtt/[friedly_name]/set
Payload: {"[channel]": value}
Channel: l1, l2, l3 … l16
Value: any positive number

Comments
Harvey Specter
Posted at 21:30 November 3, 2022
Niqu
Reply
Author

I have this counter but every couple of days they stop to counting pulses and not reporting. I try two diferen module but is “dead” any suggestion ?

    Harvey Specter
    Posted at 14:04 November 4, 2022
    Owner
    Reply
    Author

    Unfortunately, it do not have any suggestions. Do you have any other buttons on this device? If yes, does it work at that moment?

Harvey Specter
Posted at 14:34 September 23, 2022
Christian
Reply
Author

Hi!

Is the counter output from the 32bit internal counter able to be read by Z2M?

If yes: Is there a configuration needed to fetch the data sent?
Thanks!

    Harvey Specter
    Posted at 04:32 September 26, 2022
    Owner
    Reply
    Author

    The firmware does not use internal counters in a chip. The firmware implements a software counter with configurable debounce control. Of course, you can read this counter value from Z2M.

Harvey Specter
Posted at 08:10 May 22, 2022
SerDio
Reply
Author

Hi

Can you add a high frequency pulse counter based on Timer1?

“Timer 1 is a 16-bit timer with timer/counter/PWM functionality. It has a programmable prescaler, a 16-bit period value, and five individually programmable counter/capture channels, each with a 16-bit compare value. Each of the counter/capture channels can be used as a PWM output or to capture the timing of edges on input signals. It can also be configured in IR Generation Mode where it counts Timer 3 periods and the output is ANDed with the output of Timer 3 to generate modulated consumer IR signals with minimal CPU interaction”

Thank you

    Harvey Specter
    Posted at 11:03 May 26, 2022
    Owner
    Reply
    Author

    I use this timer for slow PWM only.

Harvey Specter
Posted at 07:39 January 11, 2022
Doublet
Reply
Author

For clarification: With the settings in the example above, is the maximum counter frequency 50 Hz? ( 10 ms pulse length & debounce filter so 1000ms/(2x10ms) = 50 ).

Can the frequency be increased to 100 hz by lowering the pulse length & debounce filter this frequency to 5 ms?

    Harvey Specter
    Posted at 07:52 January 11, 2022
    Owner
    Reply
    Author

    It is configurable. The minimum debounce interval is 1ms.

Harvey Specter
Posted at 14:51 November 23, 2021
kds
Reply
Author

Hi,
For counters, could you please elaborate a bit more on how debounce interval works?
Is it a low-pass or high-pass software filtering? = how long or how short the signal must be maintained.

    Harvey Specter
    Posted at 13:49 November 24, 2021
    Owner
    Reply
    Author

    The debounce filter is used to exclude noise on an input. It is a low-pass filter.

Harvey Specter
Posted at 18:28 October 24, 2021
Tim
Reply
Author

Hi !

I’m a bit confused by the screenshot above.
Why do you set-up the counters as output ? I would think it should be inputs ?

Other question: Is there a way to configure the value of each pulse ?

    Harvey Specter
    Posted at 03:29 October 25, 2021
    Owner
    Reply
    Author

    Hi! Please, ignore the place where you define a sensor or function. It is mainly related to GPIO.

Harvey Specter
Posted at 04:47 October 15, 2021
kds
Reply
Author

Hi,
Is there a way to connect to optical pulse sensor ?
For energy metering of course

    Harvey Specter
    Posted at 04:58 October 15, 2021
    Owner
    Reply
    Author

    No problems, but you cannot make it with a battery-powered Zigbee device.

Harvey Specter
Posted at 19:34 June 15, 2021
Felix Göhringer
Reply
Author

I want to monitor RPM on a motor with max 3000 RPM and 3 pulse per RPM. So max 9000 pulse per second.
Would this work with a PCF8583?

    Harvey Specter
    Posted at 03:40 June 16, 2021
    Owner
    Reply
    Author

    No, it will not work. You need a specialized counter or device for RPM measuring.

Harvey Specter
Posted at 18:18 June 1, 2021
Nobodyman
Reply
Author

Ok, I will try it.
What kind of CC2530 module do you prefer? I need one to operate at 3V battery power.

    Harvey Specter
    Posted at 03:30 June 2, 2021
    Owner
    Reply
    Author

    I use E18 MS1 modules from Ebyte.

Harvey Specter
Posted at 15:22 May 30, 2021
Nobodyman
Reply
Author

Is there any plan to support it? Or is it possible to implement it myself? I think this could be a simple solution to count pulses from gas meters and publish them to zigbee.

Harvey Specter
Posted at 08:56 May 30, 2021
Nobodyman
Reply
Author

Is it possible to use the DS1682?

    Harvey Specter
    Posted at 09:13 May 30, 2021
    Owner
    Reply
    Author

    The firmware does not support it.

Harvey Specter
Posted at 21:58 March 26, 2021
Damian
Reply
Author

It is possible to disable 3 seconds alive time in PSM mode after receiving impulse? I want to build battery powered pulse counter with impulse frequency about 1 impulse per 1-2 seconds.

    Harvey Specter
    Posted at 05:39 March 27, 2021
    Owner
    Reply
    Author

    No, it is not possible. Therefore my firmware is not acceptable for fast counters without an external hardware counter like pcf8583.

      Harvey Specter
      Posted at 17:53 March 27, 2021
      Damian
      Reply
      Author

      OK, thanks for suggestion, I can go that way, but I see pcf8583 is not supported by your generator, and it needs to by initialized to act as counter. Can I find an example for using custom i2c device with your firmware?

        Harvey Specter
        Posted at 11:11 March 28, 2021
        Owner
        Reply
        Author

        I’ll add it in the next version.

Leave a Reply to Tim
Cancel Reply