Skip to content

Commit

Permalink
Update powerSupplies.cpp (#22)
Browse files Browse the repository at this point in the history
adding "0x000" to make it work also with DPS5020  (also tested on DPS5005)
  • Loading branch information
austrisv authored May 20, 2021
1 parent f215753 commit 3ba7ec3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/MPPTLib/powerSupplies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool DPS::begin() {
bool DPS::doUpdate() {
//read a range of 16-bit registers starting at register 0 to 10
try {
if (bus_->readHoldingRegisters(0, 10) == bus_->ku8MBSuccess) {
if (bus_->readHoldingRegisters(0x0000, 10) == bus_->ku8MBSuccess) {
outVolt_ = ((float)bus_->getResponseBuffer(2) / 100 );
outCurr_ = ((float)bus_->getResponseBuffer(3) / 1000 );
inputVolts_ = ((float)bus_->getResponseBuffer(5) / 100 );
Expand All @@ -184,14 +184,14 @@ bool DPS::doUpdate() {
return false;
}
bool DPS::enableOutput(bool en) {
return bus_->writeSingleRegister(9, en) == bus_->ku8MBSuccess;
return bus_->writeSingleRegister(0x0009, en) == bus_->ku8MBSuccess;
}

bool DPS::setVoltage(float v) {
return bus_->writeSingleRegister(0, ((limitVolt_ = v)) * 100) == bus_->ku8MBSuccess;
return bus_->writeSingleRegister(0x0000, ((limitVolt_ = v)) * 100) == bus_->ku8MBSuccess;
}
bool DPS::setCurrent(float c) {
return bus_->writeSingleRegister(1, ((limitCurr_ = c)) * 1000) == bus_->ku8MBSuccess;
return bus_->writeSingleRegister(0x0001, ((limitCurr_ = c)) * 1000) == bus_->ku8MBSuccess;
}

bool DPS::isCC() const { return cc_; }
Expand Down

0 comments on commit 3ba7ec3

Please sign in to comment.