wjw
Posts: 9
Joined: Thu Oct 18, 2012 8:38 am
Location: Christchurch, New Zealand

Reading Pulse Input

Sun Jul 07, 2013 8:29 pm

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 6138 times
Pulse Output 2.PNG
Pulse Output 2.PNG (20.54 KiB) Viewed 6138 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

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Reading Pulse Input

Sun Jul 07, 2013 8:33 pm

How are you feeding the signal into the Pi? The gpios only handle 3.3V.

wjw
Posts: 9
Joined: Thu Oct 18, 2012 8:38 am
Location: Christchurch, New Zealand

Re: Reading Pulse Input

Sun Jul 07, 2013 8:43 pm

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.

User avatar
aTao
Posts: 1093
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: Reading Pulse Input

Sun Jul 07, 2013 9:32 pm

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.
>)))'><'(((<

wjw
Posts: 9
Joined: Thu Oct 18, 2012 8:38 am
Location: Christchurch, New Zealand

Re: Reading Pulse Input

Sun Jul 07, 2013 9:49 pm

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

User avatar
rpdom
Posts: 17174
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Reading Pulse Input

Mon Jul 08, 2013 5:15 am

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.

wjw
Posts: 9
Joined: Thu Oct 18, 2012 8:38 am
Location: Christchurch, New Zealand

Re: Reading Pulse Input

Mon Jul 08, 2013 7:29 am

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

PiGraham
Posts: 3939
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Reading Pulse Input

Mon Jul 08, 2013 7:37 am

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.

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Reading Pulse Input

Mon Jul 08, 2013 7:40 am

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.

PiGraham
Posts: 3939
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Reading Pulse Input

Mon Jul 08, 2013 8:19 am

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.

wjw
Posts: 9
Joined: Thu Oct 18, 2012 8:38 am
Location: Christchurch, New Zealand

Re: Reading Pulse Input

Tue Jul 09, 2013 8:34 am

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....

pedromiravaz
Posts: 1
Joined: Wed Dec 10, 2014 12:42 am

Re: Reading Pulse Input

Wed Dec 10, 2014 12:44 am

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

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13100
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Reading Pulse Input

Sat Jan 03, 2015 11:56 pm

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!

Return to “General programming discussion”