mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
OOps current detect wrong
This commit is contained in:
parent
505a8346d8
commit
53769205e4
|
@ -3,8 +3,8 @@
|
||||||
#include "DCCWaveform.h"
|
#include "DCCWaveform.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
|
|
||||||
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true, MAIN_MAX_MILLIAMPS* MAIN_SENSE_FACTOR);
|
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true, (int)(MAIN_MAX_MILLIAMPS / MAIN_SENSE_FACTOR));
|
||||||
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false, 250 * PROG_SENSE_FACTOR);
|
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false, (int)(PROG_MAX_MILLIAMPS / PROG_SENSE_FACTOR));
|
||||||
|
|
||||||
const int ACK_MIN_PULSE_RAW=65 / PROG_SENSE_FACTOR;
|
const int ACK_MIN_PULSE_RAW=65 / PROG_SENSE_FACTOR;
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ void DCCWaveform::checkPowerOverload() {
|
||||||
if (lastCurrent <= rawCurrentTripValue) sampleDelay = POWER_SAMPLE_ON_WAIT;
|
if (lastCurrent <= rawCurrentTripValue) sampleDelay = POWER_SAMPLE_ON_WAIT;
|
||||||
else {
|
else {
|
||||||
setPowerMode(POWERMODE::OVERLOAD);
|
setPowerMode(POWERMODE::OVERLOAD);
|
||||||
int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent);
|
unsigned int mA=Hardware::getCurrentMilliamps(isMainTrack,lastCurrent);
|
||||||
int maxmA=Hardware::getCurrentMilliamps(isMainTrack,rawCurrentTripValue);
|
unsigned int maxmA=Hardware::getCurrentMilliamps(isMainTrack,rawCurrentTripValue);
|
||||||
DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA);
|
DIAG(F("\n*** %S TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? F("MAIN") : F("PROG"), mA, maxmA);
|
||||||
sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT;
|
sampleDelay = POWER_SAMPLE_OVERLOAD_WAIT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ int Hardware::getCurrentRaw(bool isMainTrack) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) {
|
unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) {
|
||||||
return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR));
|
return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Hardware {
|
||||||
static void init();
|
static void init();
|
||||||
static void setPower(bool isMainTrack, bool on);
|
static void setPower(bool isMainTrack, bool on);
|
||||||
static void setSignal(bool isMainTrack, bool high);
|
static void setSignal(bool isMainTrack, bool high);
|
||||||
static int getCurrentMilliamps(bool isMainTrack, int rawValue);
|
static unsigned int getCurrentMilliamps(bool isMainTrack, int rawValue);
|
||||||
static int getCurrentRaw(bool isMainTrack);
|
static int getCurrentRaw(bool isMainTrack);
|
||||||
static void setBrake(bool isMainTrack, bool on);
|
static void setBrake(bool isMainTrack, bool on);
|
||||||
static void setCallback(int duration, void (*isr)());
|
static void setCallback(int duration, void (*isr)());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user