A note on what this document covers
The main thing that’s being added here to the wealth of information on the internet about pulse counting is how to count pulses from more than two pulse outputs sources (up to 12 sources) using a continuos sampling and direct port manipulation Arduino sketch as opposed to interrupt driven counting.
In the case of counting pulses from one or two pulse output meters it is best to use the interrupt method. There are only two interrupt pins on the Arduino, if you wish to count pulses from more than two sources then please read on!
There is also information here on how to interface with wired / switched pulse outputs.
Many meters have pulse outputs, including electricity meters: single phase, 3-phase, import, export.. Gas meters, Water flow meters etc
The pulse output may be a flashing LED or a switching relay (usually solid state) or both.
In the case of an electricity meter a pulse output corresponds to a certain amount of energy passing through the meter (Kwhr/Wh). For single-phase domestic electricity meters (eg. Elster A100c) each pulse usually corresponds to 1 Wh (1000 pulses per kwh). For the case of higher power meters (often three-phase) each pulse corresponds to a greater amount of energy eg. 2whr per pulse or even 10whr per pulse.
Figure 1 illustrates a pulse output. The pulse width T_high varies depending on the pulse output meter. Some pulse output meters allow T_high to be set. T_high remains constant during operation. For the A100c pulse output meter T_high is 50ms. The time between the pulses T_low is what indicates the power being measured by the meter.
3600 seconds per hour = 3600J per pulse ie. 1 Whr= 3600J
therefore instantaneous power P=3600/T where T is the time between the falling edge of each pulse.
Optical Pulse Counting: Flashing LEDs
Many electricity meters do not have pulse output connections or the connections are not accessible due to restrictions imposed by the utility company. All modern meters have an optical pulse output LED. In such cases an optical sensor can be used to interface with the meter.
The red pulse-output LED can be seen in the A100c picture above. To detect the pulses from the LED, you need a light sensor, such as [link to shop page]. This is supplied complete with a RJ45 plug to give an easy connection to the pulse input of an emonTx or emonPi.
Inside the sensor is a small p.c.b. carrying a photo-diode and a two-transistor amplifier-driver circuit:
The circuit generally works well, but has a few shortcomings: it is susceptible to ambient light, so it should be shielded from bright lights; the green LED does not accurately reflect the state of the output, so there can be a logic high output without the green LED lighting.
The pulse input of the emonTx and emonPi is configured with the internal pull-up active (to prevent spurious pulses being counted when nothing is connected) but this is quite weak and the resistor R4 is able to pull the output down when the transistor turns off. It should not be necessary to supplement the pull-up resistor, nor to add an external pull-down. If severe interference is experienced, a moderately low-valued capacitor may be connected between the pulse output and GND. Its value will be determined by the pulse width and maximum pulse rate, 100 nF would be a good starting value.
Other sensors that operate in the visible and infra-red ranges should be usable. A photo-diode or photo-transistor will be suitable, and you will need a similar interface circuit to give a usable pulse output. A light-dependent resistor is unlikely to be satisfactory due to its very slow response time.
Many meters have a wired pulse output. Often, this will be labelled or described in the documentation as “S0”. The S0 interface is a standardised hardware interface, defined in EN62053-31. Inside the meter, there is a switch – possibly a reed relay but more likely an optically isolated transistor. The operating voltage must be supplied by the emonTx or emonPi.
The meter’s “S0-” terminal should connect to GND, and the “S0+” terminal to the pulse input. The internal pull-up might not be strong enough, and in that case a 1 kΩ resistor must be connected between the 3.3 V terminal and the pulse input to provide adequate current.
If the meter’s pulse output is NOT labelled as “S0”, then you should assume that it cannot be directly connected to an Arduino, emonTx or emonPi and you need to determine exactly what it is. It is possibly a connection at line voltage and isolation will be required.
Wired / Switched Output Supply Voltage
From what I understand, 24V is a fairly standard supply for such meter systems, but other voltages can usually be used. Meters often have a fairly wide pulse output supply voltage range of 3 to 35V. So the 5V supply from an Arduino could be used. Higher voltages are desirable when there is more noise in the environment and the cable runs are longer.
Watch out for mains connected pulse outputs: Make sure your meter’s pulse output is not connected to the high voltage mains (within the meter). Some meters have one of the pulse output connectors connected to neutral. If your meter is one of these you will need isolation circuitry to interface with an Arduino.
Live wire proximity: The pulse outputs are usually very close to live wires, so watch out for those too!
- Single optical pulse counting using a JeeNode board and a Hope RFM12 RF module
- Application instructions energy meter Topic: S0-pulse interface
For more detail: Reading pulses from meters with pulse outputs..
This Post / Project can also be found using search terms:
- arduino pulse meter
- EVCS energy pulse output