1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +01:00

baseline calibration

This commit is contained in:
Hans R. Tanner 2022-11-02 09:40:36 -04:00
parent 9282d6a72f
commit fe6fe09ac8
3 changed files with 33 additions and 4 deletions

View File

@ -297,7 +297,11 @@ void DCCWaveform::setAckBaseline() {
if (isMainTrack) return;
int baseline=motorDriver->getCurrentRaw();
for (int i = 0; i < 32; i++)
<<<<<<< Updated upstream
baseline = max(baseline, motorDriver->getCurrentRaw());
=======
baseline=max(baseline, motorDriver->getCurrentRaw());
>>>>>>> Stashed changes
ackThreshold= baseline + motorDriver->mA2raw(ackLimitmA);
if (Diag::ACK) DIAG(F("ACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %uus and %uus"),
baseline,motorDriver->raw2mA(baseline),
@ -305,6 +309,32 @@ void DCCWaveform::setAckBaseline() {
minAckPulseDuration, maxAckPulseDuration);
}
/*
void DCCWaveform::setAckBaseline() {
if (isMainTrack) return;
int baseline = motorDriver->getCurrentRaw();
int baselinemin = baseline;
int baselinemax = baseline;
int newSample = 0;
for (int i = 0; i < 32; i++)
{
newSample = motorDriver->getCurrentRaw();
baselinemax = max(baselinemax, newSample);
baselinemin = min(baselinemin, newSample);
}
baseline = baselinemax;
ackThreshold= baseline + motorDriver->mA2raw(ackLimitmA);
if (Diag::ACK) DIAG(F("ACK min %d max %d"), baselinemin, baselinemax);
if (Diag::ACK) DIAG(F("ACK baseline=%d/%dmA Threshold=%d/%dmA Duration between %uus and %uus"),
baseline,motorDriver->raw2mA(baseline),
ackThreshold,motorDriver->raw2mA(ackThreshold),
minAckPulseDuration, maxAckPulseDuration);
}
*/
void DCCWaveform::setAckPending() {
if (isMainTrack) return;
ackMaxCurrent=0;

View File

@ -47,8 +47,8 @@
//
// Arduino standard Motor Shield
#define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \
new MotorDriver(3, 12, UNUSED_PIN, UNUSED_PIN, A0, 2.99, 2000, UNUSED_PIN), \
new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 2.99, 2000, UNUSED_PIN)
new MotorDriver(3, 12, UNUSED_PIN, UNUSED_PIN, A0, 41.54, 5000, UNUSED_PIN), \
new MotorDriver(11, 13, UNUSED_PIN, UNUSED_PIN, A1, 41.54, 5000, UNUSED_PIN)
// Pololu Motor Shield
#define POLOLU_MOTOR_SHIELD F("POLOLU_MOTOR_SHIELD"), \

View File

@ -29,13 +29,12 @@
#include "LCDDisplay.h"
bool Diag::ACK=false;
bool Diag::ACK=true;
bool Diag::CMD=false;
bool Diag::WIFI=false;
bool Diag::WITHROTTLE=false;
bool Diag::ETHERNET=false;
bool Diag::LCN=false;
void StringFormatter::diag( const FSH* input...) {
if (!diagSerial) return;