Skip to content

Driver implementation of CS5463 PowerMonitor chip to interface with Raspberry PI boards

Notifications You must be signed in to change notification settings

robotics-4-all/cs5463-pi

Repository files navigation

cs5463-pi

C Library for CS5463 PowerMonitor IC to interface with Raspberry PI boards. Tested with Pi Zero, Pi Zero W, Pi 3 Model b+

Perform Calibration

First build the calibration program.

make calibration

Run calibration with given number of CycleCounts. The calibration algorithms are depended on the value of CycleCounts. As the number increases, the accuracy of calibration results will increase.

For example, the below example will perform calibration with CycleCounts=32000

./calibration 32000

The output should look something like this:

[*] - Starting Calibration Process with CycleCount=512000
[*] - This might take a while, depending of the value of CycleCount...
[*] - Starting DC Offset Calibration process...
[*] - Finish DC Offset Calibration process.
[*] - Starting AC Offset Calibration process...
[*] - Finish AC Offset Calibration process.

Cycle Count: 512000
Current Gain: 1.000000
Voltage Gain: 1.000000
Current DC Offset: 0.984063
Voltage DC Offset: 17.413815
Current AC Offset: 110.240279
Voltage AC Offset: 0.000000

Calibration Parameters:
- Current DC Offset: 16643528
- Voltage DC Offset: 491844
- Current AC Offset: 16776330
- Voltage AC Offset: 0

Take the values of Calibration Parameters and place them in the calibration cfg file at ~/.config/cs5463/calibration.txt.

A sample calibration.txt file would look like below:

CurrentOffsetDC=16643505
VoltageOffsetDC=491583
CurrentOffsetAC=16776330
VoltageOffsetAC=0

Define VFactor and IFactor Values

In order to measure proper Voltage and Current values in SI (Volt/Ampere) the VFactor and IFactor constants have to be defined. These constants are unique per device and depend on the hardware setup (R_shunt, R1_divider, R2_divider, etc). In order to properly transform obtained measurements to SI, the values should be placed in the configuration file located at ~/.config/cs5463/config.txt

A sample config.txt file would look like below:

VFactor=292
IFactor=77.94

Development Status

Implemented Features

Measurements

  • getIstantaneusCurrent
  • getIstantaneusVolt
  • getIstantaneusPower
  • getRealPower
  • getInstantaneousReactivePower
  • getAverageReactivePower
  • getPeakCurrent
  • getPeakVoltage
  • getReactivePower
  • getPowerFactor
  • getApparentPower
  • getRMSVolt
  • getRMSCurrent

Calibration (Offset & Gain)

  • getCurrentOffset
  • getCurrentOffsetInt
  • setCurrentOffset
  • getVoltageOffset
  • getVoltageOffsetInt
  • setVoltageOffset
  • getCurrentACOffset
  • getCurrentACOffsetInt
  • setCurrentACOffset
  • getVoltageACOffset
  • getVoltageACOffsetInt
  • setVoltageACOffset
  • getCurrentGain
  • setCurrentGain
  • getVoltageGain
  • setVoltageGain
  • getPowerOffset
  • readCalibrationParams
  • calibrationOffsetDC
  • calibrationOffsetAC

Functional

  • getCycleCount
  • setCycleCount
  • getEpsilon
  • getStatus
  • getStatusMask
  • getOperationMode
  • getTemperature
  • performSingleComputation
  • performContinuousComputation
  • setIGain50
  • setIGain10
  • enableHighPassFilter
  • clearStatusRegister

Roadmap

TODO

Contributors

About

Driver implementation of CS5463 PowerMonitor chip to interface with Raspberry PI boards

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published