Pulse Counter, does not reset to zero - help

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Pulse Counter, does not reset to zero - help

#1 Post by nick-head » 07 Nov 2020, 16:15

Hi all,
I have been at this problem for months and cannot sort it.

I have two pulse-counters, one for House Power and one for Solar Power.

When either supply drops to zero, the readings always stay at the last power.
The input is via an optical sensor counting the flashing pulses.
This pulse, when the error occurs, lights the LED and it stays ON.

I require a timeout or something to return the power to zero and wait for another pulse when it start back up again.

I am rubbish at describing and hope some one can help.
I have tried writing rules for this using the Timer,1,0 etc but still cannot sort it.

Does the Pulse Counter have any time out options I can use

Regards

nick
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

User avatar
Ath
Normal user
Posts: 3506
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Pulse Counter, does not reset to zero - help

#2 Post by Ath » 07 Nov 2020, 17:19

We need more info to be able to help you
- what release of ESPEasy do you have installed? (Name of the .bin file please)
- configuration of your pulse counter devices
- rules?
- hardware schematics
/Ton (PayPal.me)

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#3 Post by nick-head » 07 Nov 2020, 22:52

Sorry about that:

No hardware circuit diagram as it is a standard wiring.
The circuit works, pulse count is spot on with input pulses
No other problems other than the output kWh stays at the last power
and does not change to zero if pulse is removed, hence i asked about timeout.

ESPEasy_mega-20200913_normal_ESP8266_4M.bin

Sensor used for light/pulse detection - Photodiode (4 terminal module )

there are no rules set either

power.JPG
power.JPG (127.06 KiB) Viewed 11042 times
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

TD-er
Core team member
Posts: 8747
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Pulse Counter, does not reset to zero - help

#4 Post by TD-er » 07 Nov 2020, 23:15

It is a known issue that the count values may not be persistent on a reboot, when you use formula.

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#5 Post by nick-head » 07 Nov 2020, 23:24

It is not on a re-boot though.

If I stop the pulse, the output does not follow, it stays the same value as the last pulses it counted.

effectively, the pulse is a continuous low/high, wherever it stopped at that time.

So, all I can think of is that a time-out after, say 30 seconds , being about 3 watts maybe, not calculated,
the output calculation would be reset to zero.

i know what I want it to do but for me to write a timeout into the plug-in would be impossible.
The plugin seems to stick in interrupt forever and not do a reset on the output,

Sorry but I cannot describe what I require / need.

If I am having this problem somebody else must be.

I monitor the output of espeasy in domoticz and the "stuck" value caused havoc in the log as it becomes a straight line at the last power.
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#6 Post by nick-head » 07 Nov 2020, 23:33

Below shows Domoticz and ESPEasy
Solar-Power kWh is different as I have been removing the input to see if it changes
p2.JPG
p2.JPG (70.11 KiB) Viewed 11037 times
p1.JPG
p1.JPG (47.57 KiB) Viewed 11037 times
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Pulse Counter, does not reset to zero - help

#7 Post by ThomasB » 08 Nov 2020, 00:25

There's a command to clear a pulse counter task. Syntax is as follows: resetpulsecounter,taskindex

Here is an untested rule file example that should clear either wattage counter if it hasn't changed value in 30 seconds:

Code: Select all

On House-Power#Watts do  // New watts count, prolong timeount.
  timerSet,1,30
endon

On Solar-Power#Watts do  // New watts count, prolong timeount.
  timerSet,4,30
endon

On Rules#Timer=1 do
  resetpulsecounter,1    // Clear task 1 counter
endon

On Rules#Timer=4 do
  resetpulsecounter,4   // Clear task 4 counter
endon
BTW, I get nervous when I see names and/or values with a hyphen in them. I suggest changing all references of House-Power to House_Power and Solar-Power to Solar_Power. This avoids parser confusion (hyphen could be interpreted as negation/subtraction).

- Thomas

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#8 Post by nick-head » 08 Nov 2020, 09:58

Hi Thomas,

Thanks for the reply.

I tried the above, did not change a thing.
I found that the value in the devices display is 0, but the output of the log is still the last power that was received.

I also tried putting it in a Dummy Value, as below,, this is the last one I tried, and I tried a few combinations, still the same. This is odd.

Code: Select all

on System#Boot do
 TaskValueSet 2,1,0
endon

On House_Power#Watts do
 if [House_Power#Watts] = inf // tried other values , on no pulse inf is shown, this was to test
  TaskValueSet 2,1,0
  ResetPulseCounter,1
  SetPulseCounterTotal,0,1
 endif
 TaskValueSet 2,1,[House_Power#Watts]
endon
I may get it one day
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#9 Post by nick-head » 08 Nov 2020, 10:26

Seems like I cannot detect / act on a value of " inf " when the pulse stops.

The log shows inf but the devices displays 0, neither can be used in a formula for some reason
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Pulse Counter, does not reset to zero - help

#10 Post by ThomasB » 08 Nov 2020, 18:14

The log shows inf but the devices displays 0, neither can be used in a formula for some reason
The infinite ("inf") value might be due to a divide-by-zero error. Your Watts formula could be causing this.

For example, when %value% = 0 there is a divide-by-zero condition. Reference your formula:

Code: Select all

3600000.0/%value%
I suggest removing the formula (use %value% instead) and then retest. If the crazy things go away then I suspect the Watts conversion will need to be done differently. For example, perform the conversion using rules.
Seems like I cannot detect / act on a value of " inf " when the pulse stops.
It is not presently allowed to compare a value to "inf" string, at least not that I am aware of. As an unproven workaround, I suggest using rules that check if the value exceeds unusually big positive or negative numbers (>99999999, <-99999999).
I found that the value in the devices display is 0, but the output of the log is still the last power that was received.
If the value is displayed as zero, but the value sent by the task's controller isn't zero, then try using a rule to send the value instead of allowing the plugin's controller setting do it.

- Thomas

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: Pulse Counter, does not reset to zero - help

#11 Post by nick-head » 10 Nov 2020, 14:39

Thanks Thomas, I will look into this.

i just felt a bit stupid as ESP has been about for a few years and no-one has ever complained about this.

So I thought it was just me, but I will give it a go and see what happens,

Regards

nick
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 52 guests