I still have a few minor issues to work out with the ADE7763, but now I have my eyes back to the system design. I need to figure out how to build 30+ of the sensors and connect them up to a master data logging station.Hand building 30 circuits does not sound feasible. I think I will have to have some boards made. Someplace like ExpressPCB might work but the cost seems high. I think I will look into BatchPCB from Sparkfun. Here you buy spare board space on panels that Sparkfun is having built. Wait times are high, but the cost is very low.
Now the question is what to put on each sensor node. The basic items needed are:
- ADE7763
- Crystal for ADE7763
- Anti aliasing filter for CT and voltage sensor
- Decoupling caps
- Status LED(s)
- Connectors for CT, Voltage Sense, SPI, and power
First question is how to connect 30 boards together. Point to point wiring would be absurd. I think that board to board connectors like the Arduino’s stackable header is the way to go. Then I can stack up two sets of 15 boards (one set for each power phase) and only have to wire each stack the master computer.
So going with stackable headers means all the interconnects must be bussed and not chained. This presents a small problem with the ADE7763 chip select (CS) line and interrupt (INT) lines. How to bus unique CD and INT to each board and how does a master not need a ton of IO pins to support 60 CS and INT pins?
Well the interrupts pin is not too bad. The ADE7763 only pulls the line low allowing many interrupt pins to be wire ORed together. If the ADE7763 had its interrupts disabled except when that chip had the focus, then you could get by with just one INT line.
The next problem is controlling each chip select line. Normally in the SPI code, you would assert the correct CS and then clock out/in the data and then deassert the CS. But with 30+ chips the number of IO pins needed would prevent a small micro from being the master. There are lots of port expansion solutions (shift registers and what not) that could give you all those bits, but it still becomes a problem on how to get a unique CS to each board on a bus.
One recommendation was to have each board take in a data line a clock to a simple flip-flop. The output of the flip flop and the clock line goes to the next board. This way you can clock out a bit and have it show up at the board you want. The issue here is that this does not work on a bus as it needs daisy chaining.
My next solution was to place down a small micro on each sensor board that would take in I2C commands (works great on a bus) and convert to SPI instructions for the ADE. This requires extra complexity and multidrop I2C may be just as much a challenge. It was then I realized that SPI was bus friendly as well. If the CS is not asserted, all the SPI bus lines are tri-stated on the ADE side. So we are back to how to get a unique CS to each ADE.
I think that the solution will likely be to place a small micro down on each board. It would take in a data and a clock line from the master. The master would clock in an address that would be compared to dip switches on the micros GPIO. If the addresses match, an output from the micro would enable a transceiver on the sensor board to allow the CS signal to get to the ADE7763. Now I am in search of a suitable micro (PIC?) and a bus switch.
Can you share the Arduino code you are using to read the ADE7763?
I can indeed. Since the code is not cleaned up for “production” I will send it to you via email. In a month or so, I should be ready to post the code for real.
Although I never did mention this in the blog, I did find that some of the time my engery would be positive and other times it would be negative. In those cases, it was indeed because I had the current probe on backwards. But at other times, the apparent and active engery were of different signs. This is still puzzling, but has dropped of my radar. With the current system design, I am more interested in Prms rather than the integral (energy).
Hi, good like you are making good progress with this chip. I’d like to ask if you can send me a copy of your source code. I’ve been trying to get this chip to work too; having a hard time so-far. Thanks.
You are the second request. I think I will clean up the code and post an initial version. Stay tuned.
Sounds like your current/voltage signlas are in phase (did you check on scope?) and Irms/Vrms readings from the ADE are what you expect (both positive?), but anyway here’s a random thought did you check if the current coil sensors are the right way around your mains? I know some or maybe all current sensors have to be placed in a certain way (some have arrows to indicate which side towards load) to give you the expected reading.