ksangeelee
Posts: 192
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK
Contact: Website

Re: 12x S0 kWh-reader

Sun Dec 09, 2012 7:26 pm

techpaul wrote:Using no doubt one input directly on GPIO, this other method is up to 12 inputs asynchronously via an I2C 16 bit port.
In the suggestion to use the Pi, I was referring more to using the Pi to read 12 GPIO pins directly (no additional I2C devices) so that, at the very least, the code to count (and possibly buffer) the pulses could be developed on the Pi and eventually ported to the PIC.

In this case, reading 1, 12, or 32 GPIO inputs would make little difference in terms of processing requirement.

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

Re: 12x S0 kWh-reader

Fri Dec 14, 2012 12:09 am

My solution would be to use counter ICs with "dirty" (diode mixing) output enable/multiplexing, using diodes as a cheap chip select. The RPi would need 1 output (chip select) per channel (or could be binary then de-multiplex chip) and as many inputs as each channels' counter has.
For a 4 bit counter eg:74393 (£0.25 GBP each) (dual 4 bit counter) with circuit load = 4kW, thats 2.2 pulses per second, you would need to poll each channel at least every 7.2 seconds.
Note: these are ripple counters, not so significant since you wont be able to latch the input, so you must calculate whether the received value is sensible or victim of a ripple count (keep reading a channel as fast as possible and wait till 2 successive vales are the same).
For diode chip select connect each counter output to a resistor, then to the anode of 2 diodes. Connect cathode of one diode to an enable signal (when low this will mimic a low output), connect the other cathode to a common point for all similar counter outputs (all Q0, all Q1 etc...), this point then needs a pull down resistor (and probably some level conversion to RPi GPIO input levels)
>)))'><'(((<

Mysh
Posts: 13
Joined: Tue Jan 08, 2013 2:24 pm

Re: 12x S0 kWh-reader

Wed Jan 09, 2013 2:57 pm

Hi, any update on this project? I am really interrested in this since I need to count about 10 S0 impulses on each of my 7 RPis.

necc
Posts: 25
Joined: Thu Aug 30, 2012 10:55 pm

Re: 12x S0 kWh-reader

Wed Jan 09, 2013 3:15 pm

I'm using an OWL Intuition-lc to read my energy consumption and reading it's multicast on raspie as described here: http://www.raspberrypi.org/phpBB3/viewt ... 37&t=28998 seems like a lot easier (and safer) solution ;)

mmaes
Posts: 17
Joined: Wed Nov 07, 2012 8:28 pm

Re: 12x S0 kWh-reader

Wed Jan 09, 2013 7:10 pm

Yes, I've been inactive on the board. I was already wondering why you were visiting my homesite so often... :-)
In the meanwhile, I've been studying a lot of options - mainly involving Microchip PICs. Currently I'm trying to put together an intermediate version, to find out if I can get the basics working.
In general, the idea is hook the pulses from the S0s to the MCP23017 via opto's. A PIC MCU - possibly the 18F26K22 will pick up the pulse-interrupts via I2C, then read date/time from a RTC.
The MCU could then be read by a Raspi. Another tempting option is to use the Ethernet chip from Microchip and have a complete networked solution.
This chip uses SPI as serial connection to the MCU. The Raspi would not be needed in this scenario. I'm planning to include the RPI-pinheader anyway.
I will try to keep you posted more regularly.

Regards, Marc

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: 12x S0 kWh-reader

Thu Jan 10, 2013 1:02 pm

Had to skip a bit near the end of this thread. If the number of pulses is a problem, just use a binary counter IC to divide the frequency by 16, or 256.

Hoagie
Posts: 119
Joined: Sun Sep 23, 2012 7:19 pm

Re: 12x S0 kWh-reader

Fri Jan 11, 2013 8:16 am

Hoagie wrote:Had to skip a bit near the end of this thread. If the number of pulses is a problem, just use a binary counter IC to divide the frequency by 16, or 256.
Let me just expand on that a bit.
Feed 5V through a resistor into the meter. When the transistor in the meter pulses, it'll pull it down and there's a detectable pulse.

Feed those pulses to binary counter ICs. The 4020 counter IC should do the job and is 79p from Maplin - almost certainly cheaper elsewhere. Now you have pins going up and down at the input frequency divided by 2, 4, 8, 16 etc. I'd try to aim for something like 1 pulse per second at normal load. If you can't get the frequency down to that, you may need a second counter IC, fed from the slowest output of the first.

NOTE: The signals are still at 5V and would kill the Pi if you miss the next step.

Now you need to step the signal voltage down to 3.3v. I'm sure there are chips to do this, or you could use a simple two resistor potential divider wired something like this.
Counter output - 2k resistor - GPIO PIN - 3.3k resistor - GND.
That will give just under 3.3v at the input to the Pi.

Use the excellent WiringPi library to look after the GPIO and either set interrupt triggering on each pin and use 12 threads waiting on those interrupts, or just poll each pin every 100ms in one thread. If your input frequencies are still high, go for every 10ms. Sleep between reads and the CPU shouldn;t be hit too hard. Count the low to high transitions to get an idea of the power in use. Keep the absolute counts in a 32 bit unsigned int variable for the next step.

I'd use RRDTool to make graphs of the power usage. Here's my house usage from a while ago. The dark part is economy seven. Image
To make that graph I just need to feed the count into RRDTool every minute. RRDTool handles the time part of the calculation and just needs a bit of scaling applied to the graph to get kW in use at any particular time.

So, there's one solution with a total parts cost of about a £10 at a guess.

mmaes
Posts: 17
Joined: Wed Nov 07, 2012 8:28 pm

Re: 12x S0 kWh-reader

Fri Jan 11, 2013 10:24 pm

Here's another question (or two, actuallly).
If I want to connect my board (which has its own power supply) to the Raspberry (via I2C or SPI), do I need to isolate the bus? Or can I just connect the two circuits?
I'm looking at the ISO1541 from Texas Instruments to completely isolate the two circuits, but I'm wondering if it's necessary. Here is a link to the ISO1541 page from TI.
By the way, the also offer the ISO1540, which also supports bidirectional CLK for multi-master.

The second question: on the rev.2 board the P5-header offers I2C-0 via GPIO's 28/29. Is there already software for the Raspberry that uses the I2C on the P5-header?

Regards, Marc

tickett
Posts: 15
Joined: Sun Feb 12, 2012 6:09 pm
Contact: Website

Re: 12x S0 kWh-reader

Tue Sep 17, 2013 10:17 am

Any update?

I'm really interested in doing something similar. I'm really interested to see your consumer unit with the din meters / monitors mounted / wired first and foremost (despite finding the devices available to buy i haven't found a single wiring diagram, blog, photo etc).

I only will only have 5 pulses to keep track of initially so was considering 2x something like: rfxmeter, openenergymonitor, flukso but now looking at something a little more flexible/expandable.

I'm a keen user of jeenodes- and stumbled on this: http://jeelabs.net/boards/6/topics/728 still waiting for a response.

Thanks!

mmaes
Posts: 17
Joined: Wed Nov 07, 2012 8:28 pm

Re: 12x S0 kWh-reader

Thu Nov 27, 2014 9:38 pm

It has been a while, but I've resumed work on this. Solution will be based on a PIC18F26K22 microntroller, MCP23017 GPIO extender with optocouplers and a ENC28J60 ethernet module. Further a DS1307 RTC and I2C EEPROMS. Don't know why I am posting this on the Raspberry forum actually, apart from the fact that the I2C bus will be extendable to the Raspi, and monitoring will have to done from a(n) (embedded) computer.
If interested, I'm willing to share schemas an PCB designs I have so far.

jerry314
Posts: 1
Joined: Thu Mar 03, 2016 10:53 pm

Re: 12x S0 kWh-reader

Thu Mar 03, 2016 10:59 pm

Hello mmaes,

I would be very interested in the PCB design you mentioned. Could you share it with us or send it to me, please? Also, could you tell me the final result of your project? Did you finish it successfully?

TIA, Jerry

Return to “Automation, sensing and robotics”