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.
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
Niqu
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 ?
Owner
Unfortunately, it do not have any suggestions. Do you have any other buttons on this device? If yes, does it work at that moment?
Christian
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!
Owner
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.
SerDio
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
Owner
I use this timer for slow PWM only.
Doublet
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?
Owner
It is configurable. The minimum debounce interval is 1ms.
kds
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.
Owner
The debounce filter is used to exclude noise on an input. It is a low-pass filter.
Tim
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 ?
Owner
Hi! Please, ignore the place where you define a sensor or function. It is mainly related to GPIO.
kds
Hi,
Is there a way to connect to optical pulse sensor ?
For energy metering of course
Owner
No problems, but you cannot make it with a battery-powered Zigbee device.
Felix Göhringer
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?
Owner
No, it will not work. You need a specialized counter or device for RPM measuring.
Nobodyman
Ok, I will try it.
What kind of CC2530 module do you prefer? I need one to operate at 3V battery power.
Owner
I use E18 MS1 modules from Ebyte.
Nobodyman
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.
Owner
Will PCF8583 work for you?
https://ptvo.info/zigbee-configurable-firmware-features/external-sensors/pcf8583-zigbee-counter/
Nobodyman
Is it possible to use the DS1682?
Owner
The firmware does not support it.
Damian
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.
Owner
No, it is not possible. Therefore my firmware is not acceptable for fast counters without an external hardware counter like pcf8583.
Damian
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?
Owner
I’ll add it in the next version.