Triggering on leading and trailing edge of a pulse. Possible?

I just checked my water meter and it has a magnet on the least significant digit which will switch on a reed relay twice per rotation.
The least significant digit is single litres, 10 litres per rotation.
With the relay switching on and of twice per rotation i get a resolution of 5 litres per pulse logged by the FLM.
If the FLM could trigger on both the leading and trailing edge then this would double the resolution to 2.5 litres per pulse.

Would this be possible?
Would it be a software only change or would hardware changes be required?

If this could be done i imagine it would provide the same doubling of resolution to gas meters that have magnets on the dials.

Here is a crude diagram of what happens to the reed relay as the magnet rotates.

  1.       ______         ______         ______         ______
  2. _____|      |_______|      |_______|      |_______|      |
  3. 1  2  3  4  5  6  7  8  9  0  1  2  3  4  5  6  7  8  9  0
  4.      on    off      on    off      on    off      on    off

Is this set up similar to other users?
Would many other FLM water and gas loggers benefit from this resolution doubling?

If this is not possible then i imagine i could cobble together some sort of frequency doubling pre conditioning circuit to process the pulses before they reached the FLM.
Something like the attached image.

AttachmentSize
frequencydoubler.png13 KB
gebhardm's picture

Would be a software only change:
The AVR's interrupt could be reconfigured to react "on logical change" instead of "falling edge"; for the FLM02A see https://github.com/flukso/flm02/blob/develop/avr/a/main.c -->

  1. void setup_pulse_input(void)
  2. {
  3.         // PD2=INT0 and PD3=INT1 configuration
  4.         // set as input pin with 20k pull-up enabled
  5.         PORTD |= (1<<PD2) | (1<<PD3);
  6.         // INT0 and INT1 to trigger an interrupt on a falling edge
  7.         // EICRA = (1<<ISC01) | (1<<ISC11);
  8.         // INT0 and INT1 to trigger an interrupt on logical change
  9.         EICRA = (1<<ISC00) | (1<<ISC10);
  10.         // enable INT0 and INT1 interrupts
  11.         EIMSK = (1<<INT0) | (1<<INT1);
  12. }

Use at own risk... See http://web.alfredstate.edu/weimandn/miscellaneous/atmega_subsystem/ATmeg... for interrupt configuration

gebhardm's picture

Note: It's possible, but if it is also feasible, I don't argue...

fusionpower's picture

It sounds promising that the micro controller input interrupt can be easily changed in software.
I was curious to find out if other FLM users that use a magnet triggered reed relay input for their water or gas also have a similar make/break pattern. Or if they might have only a single momentary closing of the reed relay once per rotation and so would not see a benefit of the input using logical interrupts as opposed to single edge triggered interrupts.
If the pattern i get is not common then i may have to look at what is involved in changing the source code, recompiling and updating my own FLM. But if it is a common pattern then maybe the option to change the triggering could be incorporated as a standard option on the sensor config page?

gebhardm's picture

I doubt the "common pattern" as the intention of any "pulse output" is a well-defined impulse for a well-defined quantity of something. That the "on/off"-pattern of your meter matches "a half of an impulse quantity" I regard as by coincidence only.

fusionpower's picture

I will do a sample of the water meter outputs at some of the in-laws houses the next time i visit each of them and see if any others have the same "pattern". It may be just my meter, or it may be one water supply authority's meters or it may even be an Aussie thing. Have to do some checking. I am sure i will get some queer looks from the in-laws when i hook the multimeter up to their water meter. :)
My gas meter doesn't have a magnet so i can't check it's "pattern". However the expiry date on the meter has been reached so maybe they will swap it for a different one, fingers crossed for a magnet in that one. Or maybe they will just come out and give it a kick and say, "Looks ok" and put a new expiry date on it. I have never heard anyone talk about their meter being replaced due to an expiry date. Then again i didn't even realise the meters have an expiry date till i noticed the label whilst testing for a magnet.
Makes sense though, they couldn't just rely on customers reporting faults when their ancient meter starts leaking cubic meters of gas.
I would have liked to get a bit better resolution on the water meter as 5 litres per pulse will make identifying water users a little difficult. Low flush toilets being about 6 litres would be hard to distinguish from the other low volume events, hand washing kettle filling etc. It should still clearly show higher volume users such as washing machine, baths, showers, etc.
Maybe i am hoping for too much from a basic water meter, maybe i should look at adding a second higher pulse count meter. Its a pity because a software change would be a much lower cost path than a plumbers hourly rate.
I think i will finish setting up the meter as is and see what i can see with the 5 litre resolution and then look at the options again if i need to.

bazzle's picture

Cant you change the multiplication factor on the setup page?

fusionpower's picture

I don't think that would do it.
At the moment the single edge triggered input will only trigger twice per rotation of the 10 litre dial. So 5 litres per pulse. So although the total is correct (within 5 litres), for every 5 litres of water used i get one pulse, it limits the resolution to 5 litres. With triggering on both edges of the incoming signal the figure will still be accurate (to within 2.5 litres) but the resolution is doubled to 2.5 litres per pulse.
Its sort of like on the electrical pulse sensors only getting two pulses per kilowatt (chart will have 500watt steps in it) compared to getting 4 pulses per kilowatt (chart will have 250 watt steps).
The better the resolution the easier it is to identify the appliance/activity consuming. Therefore you can work out the consumption for different appliances/activities.