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

gradually improving config

This commit is contained in:
Asbelos 2020-08-15 14:10:56 +01:00
parent cdcb01d300
commit 7a4fcd228d
3 changed files with 17 additions and 25 deletions

View File

@ -82,9 +82,7 @@ void setup() {
// Standard supported devices have pre-configured macros but custome hardware installations require
// detailed pin mappings and may also require modified subclasses of the MotorDriver to implement specialist logic.
DCC::begin(new MotorDriver(MAIN_POWER_PIN,MAIN_SIGNAL_PIN,MAIN_SIGNAL_PIN_ALT,MAIN_BRAKE_PIN,MAIN_SENSE_PIN,MAIN_SENSE_FACTOR, MAIN_MAX_MILLIAMPS,MAIN_FAULT_PIN),
new MotorDriver(PROG_POWER_PIN,PROG_SIGNAL_PIN,PROG_SIGNAL_PIN_ALT,PROG_BRAKE_PIN,PROG_SENSE_PIN,PROG_SENSE_FACTOR, PROG_MAX_MILLIAMPS,PROG_FAULT_PIN));
DCC::begin(STANDARD_MOTOR_SHIELD);
// Responsibility 3: Optionally Start the WiFi interface if required.
// NOTE: On a Uno you will have to provide a SoftwareSerial

View File

@ -1,34 +1,28 @@
#ifndef Config_h
#define Config_h
// *** PLEASE NOTE *** THIS FILE IS **NOT** INTENDED TO BE EDITED WHEN CONFIGURING A SYSTEM.
// It will be overwritten if the library is updated.
// This file contains configurations for known/supported motor shields.
// A configuration defined by macro here can be used in your sketch.
// A custom hardware setup will require your sketch to create MotorDriver instances
// similar to those defined here, WITHOUT editing this file.
// Define these if you have a WiFi board on Serial1
#define WIFI
#define WIFI_CONNECT_TO_SSID "RPi-JMRI"
#define WIFI_CONNECT_PASSWORD "rpI-jmri"
// This hardware configuration would normally be setup using a bunch of #ifdefs.
const byte UNUSED_PIN = 255;
const byte MAIN_POWER_PIN = 3;
const byte MAIN_SIGNAL_PIN = 12;
const byte MAIN_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins
const byte MAIN_SENSE_PIN = A0;
const byte MAIN_BRAKE_PIN = 9;
const byte MAIN_FAULT_PIN = UNUSED_PIN;
// MotorDriver(byte power_pin, byte signal_pin, byte signal_pin2, byte brake_pin, byte current_pin, float senseFactor, unsigned int tripMilliamps, byte faultPin);
// Arduino standard Motor Shield
#define STANDARD_MOTOR_SHIELD \
new MotorDriver(3 , 12, UNUSED_PIN, 9, A0, 2.99, 2000, UNUSED_PIN), \
new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 2.99, 250 , UNUSED_PIN)
const int MAIN_MAX_MILLIAMPS=2000;
const float MAIN_SENSE_FACTOR=2.99; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps
const byte PROG_POWER_PIN = 11;
const byte PROG_SIGNAL_PIN = 13;
const byte PROG_SIGNAL_PIN_ALT = UNUSED_PIN; // for hardware that flipflops signal pins
const byte PROG_SENSE_PIN = A1;
const byte PROG_BRAKE_PIN = 8;
const byte PROG_FAULT_PIN = UNUSED_PIN;
const int PROG_MAX_MILLIAMPS=250;
const float PROG_SENSE_FACTOR=2.99; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps
// Allocations with memory implications..!
// Base system takes approx 900 bytes + 8 per loco. Turnouts, Sensors etc are dynamically created

View File

@ -26,7 +26,7 @@
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
const int ACK_MIN_PULSE_RAW=65 / PROG_SENSE_FACTOR;
//const int ACK_MIN_PULSE_RAW=65 / PROG_SENSE_FACTOR;
bool DCCWaveform::progTrackSyncMain=false;
@ -265,7 +265,7 @@ int DCCWaveform::getLastCurrent() {
void DCCWaveform::setAckBaseline(bool debug) {
if (isMainTrack) return;
ackThreshold=motorDriver->getCurrentRaw() + ACK_MIN_PULSE_RAW;
ackThreshold=motorDriver->getCurrentRaw() + (int)(65 / motorDriver->senseFactor);
if (debug) DIAG(F("\nACK-BASELINE %d/%dmA"),ackThreshold,motorDriver->convertToMilliamps(ackThreshold));
}