Giter Club home page Giter Club logo

power_meter_cs5460a's Introduction

power_meter_cs5460a

Arduino sketch for reading CS5460A-based digital power meter.

![Image of Power meter banggood SKU089379](http://img.banggood.com/thumb/large/upload/2012/jiangjunchao/SKU089379/yuan/SKU089379 (1).jpg)

Warning

Ground reference of PCB inside meter is tied to HOT (Line). It is at mains level. Use galvanic isolation, e.g. optocouplers, etc if you want to wire this up directly to something else. Be sure you know what your are doing around potentially lethal mains-level voltages. Use at your own risk!

hardware

analysis

Analysis of SPI communication between oem mcu and CS5460A chip.

  • Saleae Logic (highly recommended!) was used to analyze the communication between original mcu and CS5460A chip.
  • Some captures of startup and running/recurring signals are in logic_analyzer_captures folder.
  • Refer to datasheet for complete understanding of registers and formatting of values.
  • In annotations below mcu->cs5460 (SDI) is > while cs5460->mcu (SDO) is <

startup

> A0        (power-up/halt)
> 00        (reg read: config)
< 00 00 01  (config reg: DCLK=MCLK/1)
> 40 01 00 61 (reg write: config. PGA Gain 50x, IHPF=1, VHPF=1)
> 44 4A 32 DF (reg write: Ign [current chan gain]. value: 1.15935)
> 48 3E 9B 5A (reg write: Vgn [voltage chan gain]. value: 0.97823)
> 00        (reg read: config)
< 01 00 61
> 04        (reg read: Ign)
< 4A 32 DF
> 08        (reg read: Vgn)    
< 3E 9B 5A
> 0A        (reg read: Cycle Count)
< 00 0F A0  (4000 = 1/sec)
> E8        (start conversion, continuous)

repeating 1 second loop

> 1E        (reg read: status)
< 10 03 C1  (DRDY=0)

... repeats query until conversion is done (DRDY=1)...

> 1E
< 90 03 C1  (DRDY=1)
> 5E 80 00 00  (reg write: status - clear DRDY)
> 18        (reg read: Vrms
< 2C CA 01
> 16        (reg read: Irms)
< 00 2B 7A  
> 14        (reg read: E [energy])
< FF FE 26

references

Karl Hagstrom's article

CS5460A Datasheet

power_meter_cs5460a's People

Contributors

zerog2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.