Page 1 of 1

Reading Pulse Input

Posted: Sun Jul 07, 2013 8:29 pm
by wjw
I really hate to post this as I should be able to find the answer online, but I am getting lost in all the different ways to do it.

I have a Sontex Supercal 539 heat meter for our Central heating system that gives out a pulse for every Kilowatt used. The output is as follows:
Pulse Output.PNG
Pulse Output.PNG (32.26 KiB) Viewed 6137 times
Pulse Output 2.PNG
Pulse Output 2.PNG (20.54 KiB) Viewed 6137 times
I have tried a few different options for reading this, both Python and Perl, but the best I seem to manage is to have the Pi crash when the pulse is received.

TIA,

Bill

Re: Reading Pulse Input

Posted: Sun Jul 07, 2013 8:33 pm
by joan
How are you feeding the signal into the Pi? The gpios only handle 3.3V.

Re: Reading Pulse Input

Posted: Sun Jul 07, 2013 8:43 pm
by wjw
My understanding was I had to supply power via VCC, which I am doing from the 3.3V output on the Pi, with a 10K resistor between it and the GPIO pin.

Re: Reading Pulse Input

Posted: Sun Jul 07, 2013 9:32 pm
by aTao
Am I right in thinking you said you connect 3V3 to the heat meter, no series resistor? If that is the case then every time there is a signal pulse you short out the RPi power supply, good way to crash it.

Re: Reading Pulse Input

Posted: Sun Jul 07, 2013 9:49 pm
by wjw
aTao wrote:Am I right in thinking you said you connect 3V3 to the heat meter, no series resistor? If that is the case then every time there is a signal pulse you short out the RPi power supply, good way to crash it.
As per the diagram I have supplied 3.3V to the signal line via a 10K resistor.

The signal line is connected to one of the GPIO Pins on the Pi, 17 from memory

The 0V is connected to GND on the Pi

Re: Reading Pulse Input

Posted: Mon Jul 08, 2013 5:15 am
by rpdom
wjw wrote:
aTao wrote:Am I right in thinking you said you connect 3V3 to the heat meter, no series resistor? If that is the case then every time there is a signal pulse you short out the RPi power supply, good way to crash it.
As per the diagram I have supplied 3.3V to the signal line via a 10K resistor.

The signal line is connected to one of the GPIO Pins on the Pi, 17 from memory

The 0V is connected to GND on the Pi
Is that pin 17 on the connector, or GPIO 17 on pin 11 of the connector?
Pin 17 is 3.3v, so that would still cause the Pi supply to short to ground every time a pulse is received.

I'd also put a 1K resistor between the signal line and the GPIO connection, just to protect against shorts and things.

Re: Reading Pulse Input

Posted: Mon Jul 08, 2013 7:29 am
by wjw
rpdom wrote:
wjw wrote:
aTao wrote:Am I right in thinking you said you connect 3V3 to the heat meter, no series resistor? If that is the case then every time there is a signal pulse you short out the RPi power supply, good way to crash it.
As per the diagram I have supplied 3.3V to the signal line via a 10K resistor.

The signal line is connected to one of the GPIO Pins on the Pi, 17 from memory

The 0V is connected to GND on the Pi
Is that pin 17 on the connector, or GPIO 17 on pin 11 of the connector?
Pin 17 is 3.3v, so that would still cause the Pi supply to short to ground every time a pulse is received. Thanks

I'd also put a 1K resistor between the signal line and the GPIO connection, just to protect against shorts and things.
It's GPIO 17. I'll go grab some 1k's tomorrow and try again. Thanks

Re: Reading Pulse Input

Posted: Mon Jul 08, 2013 7:37 am
by PiGraham
According to the circuit diagram the device has an open drain output that pulls to ground. A pullup to 3.3 on the "signal" terminal, as shown, should be fine. A series 330R to 1k resistor from GPIO to "signal" terminal will protect the Pi in case it's pin is programmed to an output at any time. GPIO high output into a transistor to ground is a short that may blow the chip or cause a dip in the 3.3V supply resulting in a reset or spurious behaviour.

Re: Reading Pulse Input

Posted: Mon Jul 08, 2013 7:40 am
by joan
To sum up.

You apply a short pulse at 3.3V to gpio17 (P1-11) every time some unit of kWh is consumed?

That should be OK.

How are you reading the pulse?

edited to add: or a short pulse to ground from 3.3V as PiGraham suggests.

Re: Reading Pulse Input

Posted: Mon Jul 08, 2013 8:19 am
by PiGraham
wjw wrote:I have tried a few different options for reading this, both Python and Perl, but the best I seem to manage is to have the Pi crash when the pulse is received.

TIA,

Bill
Is it crashing when it gets to some part of your code, or merely when the signal pulls down (after your GPIO configuration is done)?
Post the code for configuration and responding to the pulse.

Re: Reading Pulse Input

Posted: Tue Jul 09, 2013 8:34 am
by wjw
Thanks guys, since putting in the 1K resistor it's stopped crashing, prior to this it would crash with a gpio wfi. I will leave this bash script running for a few days to make sure its stable before I do anything else:

#!/bin/bash
SUBJECT="Kilowatt"
EMAIL="bill@xxx.xxxx"

while true; do
gpio wfi 1 rising
EMAILMESSAGE="/tmp/emailmessage.txt"
echo "used a kw"> $EMAILMESSAGE
echo "" >>$EMAILMESSAGE
mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
echo "Used a KW and sent an email"
done

Once stable I need to write something to feed the data into MRTG....

Re: Reading Pulse Input

Posted: Wed Dec 10, 2014 12:44 am
by pedromiravaz
Hi jwj,

I'm trying to accomplish the same thing with a Schneider iEM 3110. Output of the pulse is 30VCC. Are you putting the 1k resistor in series with the positive pulse?

Thanks
Pedro

Re: Reading Pulse Input

Posted: Sat Jan 03, 2015 11:56 pm
by mahjongg
pedromiravaz wrote:Hi jwj,

I'm trying to accomplish the same thing with a Schneider iEM 3110. Output of the pulse is 30VCC. Are you putting the 1k resistor in series with the positive pulse?

Thanks
Pedro
That is only true when VCC = 30V, but as OP said he is supplying 3.3V to VCC, which would be fine!