1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 12:51:24 +01:00

4.2.19 sensorOffset bugfix

This commit is contained in:
Asbelos 2023-03-02 10:45:39 +00:00
parent ca4592dc3e
commit f0c1ea958c
2 changed files with 12 additions and 6 deletions

View File

@ -90,9 +90,8 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
else brakePin=UNUSED_PIN;
currentPin=current_pin;
if (currentPin!=UNUSED_PIN) {
senseOffset = ADCee::init(currentPin);
}
if (currentPin!=UNUSED_PIN) ADCee::init(currentPin);
senseOffset=0; // value can not be obtained until waveform is activated
faultPin=fault_pin;
if (faultPin != UNUSED_PIN) {
@ -121,8 +120,8 @@ MotorDriver::MotorDriver(int16_t power_pin, byte signal_pin, byte signal_pin2, i
if (currentPin==UNUSED_PIN)
DIAG(F("** WARNING ** No current or short detection"));
else {
DIAG(F("CurrentPin=A%d, Offset=%d, TripValue=%d"),
currentPin-A0, senseOffset,rawCurrentTripValue);
DIAG(F("CurrentPin=A%d, TripValue=%d"),
currentPin-A0, rawCurrentTripValue);
// self testing diagnostic for the non-float converters... may be removed when happy
// DIAG(F("senseFactorInternal=%d raw2mA(1000)=%d mA2Raw(1000)=%d"),
@ -144,6 +143,12 @@ bool MotorDriver::isPWMCapable() {
void MotorDriver::setPower(POWERMODE mode) {
bool on=mode==POWERMODE::ON;
if (on) {
// when switching a track On, we need to check the crrentOffset with the pin OFF
if (powerMode==POWERMODE::OFF && currentPin!=UNUSED_PIN) {
senseOffset = ADCee::read(currentPin);
DIAG(F("CurrentPin A%d sensOffset=%d"),currentPin-A0,senseOffset);
}
IODevice::write(powerPin,invertPower ? LOW : HIGH);
if (isProgTrack)
DCCWaveform::progTrack.clearResets();

View File

@ -4,7 +4,8 @@
#include "StringFormatter.h"
#define VERSION "4.2.18"
#define VERSION "4.2.19"
// 4.2.19 - Bugfix for analog reading of track current sensor offeset.
// 4.2.18 - I2C Multiplexer support through Extended Addresses,
// added for Wire, 4209 and AVR I2C drivers.
// - I2C retries when an operation fails.