Thursday, January 17, 2013

Smart Outlet: ADE7753

After completing the first version of the smart outlet, I needed a better way to monitor current usage. Using an Hall Effect sensor with an Atmega 328p didn't work out so well. It was very difficult to get accurate calculations and it tied up the microcontroller from doing other tasks. Proper monitoring should take into account the AC voltage and zero wave crossing.

First version



First version where you can see the mistake in the design where I forgot the DC side power

In my research travels I came across this site, http://arduinopower.pbworks.com/w/page/10175892/FrontPage, which mentioned using the ADE7753 from Analog Digital. In theory this IC is great; it does all the hard work for you. You just talk to it over SPI and grab the data. After a lot of research on this IC, I think I was more confused than anything on how to implement it. It requires a lot of external components, mostly passive though. At this point I ended up subconsciously shelving the project.

After some time passed, I decided to hit this project head on. Since I have been doing more PCB design I decided to try to lay it out in Eagle and have it printed by OSHPark. (Great way to get small projects printed in the US and in a reasonable amount of time.) After many nights of research and reading different reference designs I came up with a working design.

Two weeks later version one arrived in my mailbox. That night I assembled the PCB and installed it in the  smart outlet in place of the Hall Effect sensor. I tried different codes examples from http://pingu98.wordpress.com/2011/07/27/arduinopower-source-code/ and http://www.olimex.cl/product_info.php?cPath=76_78&products_id=797&language=en. The second is pretty close to what I am designing but I want it to be all inclusive. Just hook up AC and DC along with SPI and you are good to go.

For the most part I was able to talk to the ADE7753 and get some data. If the values were right, I wasn't sure, but at least I had something working. Now off to update the board and print version two. In this version I moved the AC connections to the other side, removed the jumpers and reset button footprint. This gave me more room for spacing parts out and room for proper labeling, which the first version didn't have.

Another two weeks go by but by this time things didn't go so well. Soldered it up, wired it to the smart outlet and flicked the switch.... then poof! Magic blue smoke. Since I am working with Mains, it made me quickly jump and freak out. Time to check the damage. At first I thought it was just the resistor on the AC connection for the divider. Upon closer inspection pretty much everything on the board was fried. My oscilloscope showed the crystal acting really strangely. So what does that mean for the Arduino UNO I was using to test? Oops! It's a goner. The 328p just get hot when running. I wasn't happy. Then I realized that it was powered from my USB port. Oh no! I hope my computer is okay, I thought. To start, the USB port wouldn't recognize a device but luckily the USB protection works and clears up the port after a power off reset. Phew! That was close. Now to figure out what happened.

The first test where the short caused the jumper wire to burn off.

Second version after the second test where the metal of the test lead melted. 

To this day I still don't understand why it blew up in my face. I had tried it again before I realized most of it was bad by replacing the resistor and just hooking up AC no digital and it melted one of my test leads, so I had molten metal on my desk. Scary stuff. I decided to set it aside for awhile, Mains is not something to play with. This was about November of last year. As write this I think it's time to get back to it. I know the first thing I need is isolation on the AC input and then condition it before it goes to the input of the ADE7753. I hope this year I can complete this project as I think many people can benefit from it. Once it's working and tested safely, I plan to sell it on tindie.com. After which I can continue the smart outlet into a final product. I'd like to make it smaller and affordable enough to place one on every outlet in one's house.

If anyone has experience with this IC please contact me. I would like to see if someone can review the two designs to see what went wrong. Minus not having isolation, I am curious why the first one works. Only thing I can think of is the AC was too close to the ground plane since the first version didn't have a ground plane.

Update: Here is the design files: https://github.com/FriedCircuits/ADE7753

27 comments:

  1. We have a working current sensor design good for at least 15 amps, which I'd be happy to share. It does use a sensing coil which I think yours does also. Does not use ADE7753. Ping me back if you are interested.

    ReplyDelete
    Replies
    1. I am very interested! Send me an email, its under contributors.

      Delete
    2. I'd also be very interested in that current sensor design. I'd be very grateful if you could also send it to me. :)

      Delete
    3. can i have the design? i am interested with it

      Delete
  2. IMO, the main problem (without seeing your schematic) is that the 7753 needs to sense AC voltage, and hence you need to couple 7753 ground to the neutral of your AC supply. The live of the AC supply is dropped through some high value resistors before going into the 7753 and so no significant current can flow through that path.

    What likely happened during the bang moments is that your arduino ground is real earth (through the USB cable) and current flowed between your neutral connection (...which maybe was live by mistake?) and the ground connection from your PC. Bang, at the thinnest wire in the chain.

    The easiest way to get this working safely is to power the 7753 from a neutral-tied supply (usb charger, with the ground side of the output coupled to neutral - chargers are isolated, so you can do this to simulate a non-isolated supply), and then optocouple the *output* of the 7753 - or the serial bus - to the arduino. The 7753 then runs in its own island, and no current can flow between that and the arduino.

    For reference, here's the board I build with the 7953 and an electric imp: http://devwiki.electricimp.com/doku.php?id=becky

    This wasn't isolated, but wifi is at least as good as optoisolation, electrically ;)

    ReplyDelete
  3. http://shaddack.twibright.com/projects/hw_wattmeterhack/

    Here is my take at the problem - using a commercially available wattmeter with ADE7755 chip. The chip itself is powered directly from mains and provides pulses per consumed power unit, which is easy to separate with an optocoupler. (Same approach can be done with SPI, you just need three optos that are suitably fast - the cheapest ones are nauseatingly lazy).

    Check out the power supply circuitry of the commercial solution; the Lin acts as the shared system ground (floats on the AC waveform), the 4-5V for the chip are made by current-limiter with the 150-ohm resistor in series with a 680nF capacitor, rectified with two diodes, voltage-limited with a Zener diode, and filtered with capacitors scattered around the board. The logic board (schematics not shown) power has a battery backup, made from a small Li-ion cell charged through a current-limiting resistor. Simple and brutally effective.

    For working with mains, you may also like these two devices:
    http://shaddack.twibright.com/projects/hw_LightbulbLimiter/
    http://shaddack.twibright.com/projects/hw_IsolatedMainsPowerSupply/
    The former is a current limiter to keep the magic smoke in. The latter is an intentionally wimpy isolation transformer with switchable output voltage, good for testing of low-power devices (e.g. phone chargers, or various sensors); output voltage will sag at higher than low load.

    ReplyDelete
  4. Check out a solid state relay. It made controlling mains voltage from a raspberry pi very simple.

    ReplyDelete
    Replies
    1. I did but the cost was too high. I am using one for controlling the reflow oven.
      http://www.mobilewill.us/2013/07/another-toaster-reflow-oven-part-one.html

      I wish I could find a low cost one and small. My goal for this is to be cheap enough to build one for every outlet, and possible with a duel outlet design.

      Delete
  5. If you're interested, I've got a fully functional test-board what uses a CS5490 energy meter IC, together with an ATxmega32A4U for processing, and a nRF24L01+ for comms (it also has USB).

    It's properly isolated for safety and everything too.

    I'm actually collaborating with a few people on building a truly cost-competitive wireless plug-power-monitor. Realistically, even the Power-monitor IC is a bit much (we're targetting a total BOM cost of <5$), so I have a rev planned that uses the ATxmega's ADCs directly. That's a bit of a bear to work with, though, since you need an isolation transformer to do anything with it without exposing yourself to line voltage, though.

    Anyways, the whole project is open-source.

    www.imaginaryindustries.com

    ReplyDelete
    Replies
    1. Anyways, I have the initial prototype working quite well, it's just too expensive (~$15 parts cost) to be commercially viable.

      On the other hand, it's much more accessible for hackers, because I have optoisolated the mains-connected bits.

      Connor

      Delete
    2. Wow that is pretty much what I was going for. Maybe you can email me and we can talk further? My email is under contributors.

      I will check out your site, really interested to see your design.

      Delete
    3. You still have the project docs published somewhere?

      Delete
  6. Anyways, the probable reason your circuit failed is that you are treating mains neutral as a ground.

    THIS IS NOT SAFE. Mains neutral IS NOT a ground. Generally, the neutral floats a few volts above actual ground.

    As such, if you connected the neutral input to your USB ground (the arduino ground is coupled to the real ground, through the computer's USB interface), you'd get a LOT of current flow, and things would probably get hot in a hurry.

    Anyways, if you have ANYTHING mains-connected, it pretty much CANNOT be connected to ANYTHING else. You have to use optoisolators, or some other form of isolator.

    ----

    Other comments:
    You look to be using a single 1206 SMT resistor for your line voltage dropper. This is also a bad idea, as any board pollution or flux can easily cause a breakdown across the small gap between the SMT pads. This should really be either a large (1/2W) through-hole resistor, or a series of 1206 resistors in series (3-4 is a good safe number).
    You should also check the voltage rating of your resistors. Some are not up to withstanding line-voltage across them.

    I'd strongly recommend you go study the evaluation boards for some of these power-monitoring ICs a bit. Analog Devices, Cirrus and probably many other companies produce eval boards for companies looking to use their products. While the eval boards themselves are expensive, the documentation is generally freely available, and it usually includes a complete schematic and board printout. You can learn a lot from reading those.

    ReplyDelete
    Replies
    1. Yeah I studied the eval designs over and over and there is even and Arduino shield around this IC. I think if I go back to it now I can make some progress.

      Thanks for all the help, I am looking forward to getting this off the ground. I have the same goals you do as far as a low cost wireless outlet for monitoring, but with switch control, and temp\light level of the room. Everything adds to the cost though. Having humidity would be great too.

      So basically a smart outlet doubled as a environmental node.

      Delete
    2. Hi.Please help me! ade7753 with Arduino Mega2560
      #define DATAOUT 48
      #define DATAIN 51
      #define SPICLOCK 50
      #define CS 53
      #define RS 46

      Delete
  7. First off get some ark fault breakers they will flip really quick for this kinda failure. Or gfi at least.Also i believe ul spec says 2mm is recomended for 120v mains circuitry so the smds wont cut it.(i know its just hobby/hacker stuff but you may as well follow it) In addiction to the flux possible circuit and bypassing the resistor.

    http://www.smps.us/pcbtracespacing.html


    Also find a community to review your board it helps a lot.

    MY mains ac connected project non-isolated. I had a ton of help might be some usefull info in there. Also the NRF wireless modules and transformerless supply may also be of intrest.
    http://doityourselfchristmas.com/forums/showthread.php?24162-Hackable-Cheap-Walmart-quot-Pixels-quot-an-exlectronic-puzzle&highlight=wallmart+pixles

    Oh for failing often check out elecrow.com extremity cheap pcbs, mfg+shpping is equal or faster than oshpark.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. You should have connected the neutral line to ground of R5 only. While all the rest of the GND's should have been connected to USB's GND.Then it would have worked. Since you shorted these two GND's during negative cycle the GND for the IC's etc was at 156V!!!

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Dont give up. Use a AC transformer for Voltage sensing. Any 110V to 5AC should do the trick and keep it safe to handle.

    ReplyDelete
  12. Have you already fiures how to solve this? Please contact me if you are still interested

    ReplyDelete
  13. Hi.Please help me! ade7753 with Arduino Mega2560
    #define DATAOUT 48
    #define DATAIN 51
    #define SPICLOCK 50
    #define CS 53
    #define RS 46

    ReplyDelete
  14. Hi.Please help me! ade7753 with Arduino Mega2560
    #define DATAOUT 48
    #define DATAIN 51
    #define SPICLOCK 50
    #define CS 53
    #define RS 46
    Mail : damhung92@gmail.com

    ReplyDelete
    Replies
    1. I used it with the UNO, but should be the standard SPI pins. Do you have more info on your project?

      Delete
  15. Hi,your project is really helpful.Can you give me the layout of this board.I use altium.
    Thankyou very much!

    ReplyDelete