DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Configuration Lines

This is the 'begin' lines for some common configurations. Note that for LMD18200, the two final arguments must be adapted to your need... The wiring for these configurations is visible here : http://www.locoduino.org/spip.php?article187 . The text is in French, but schema can be understood !

For Arduino or Pololu shields, signalPinMain must be connected to Direction motor A, and signalPinProg to Direction motor B If a track is not connected, main or programming, the signalPin should stay to default at 255 (UNDEFINED_PIN). For H bridge connected directly to the pins, like LMD18200, signalPin and Direction motor should have the same pin number, or directions can be set to UNDEFINED_PIN.

Arduino Uno + LMD18200 + MAX471
DCCpp::beginMain(UNDEFINED_PIN, DCC_SIGNAL_PIN_MAIN, 3, A0);
Arduino Uno + 2 LMD18200 + 2 MAX471
DCCpp::beginMain(UNDEFINED_PIN, DCC_SIGNAL_PIN_MAIN, 3, A0);
DCCpp::beginProg(UNDEFINED_PIN, DCC_SIGNAL_PIN_PROG, 5, A1);
Arduino Mega2560 + LMD18200 + MAX471
DCCpp::beginMain(UNDEFINED_PIN, DCC_SIGNAL_PIN_MAIN, 3, A0);
Arduino Mega2560 + 2 LMD18200 + 2 MAX471
DCCpp::beginMain(UNDEFINED_PIN, DCC_SIGNAL_PIN_MAIN, 3, A0);
DCCpp::beginProg(UNDEFINED_PIN, DCC_SIGNAL_PIN_PROG, 11, A1);
Arduino Uno or Mega2560 + Arduino Motor Shield
DCCpp::beginMainMotorShield();
DCCpp::beginProgMotorShield();

or

DCCpp::beginMain(MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_A, DCC_SIGNAL_PIN_MAIN, MOTOR_SHIELD_SIGNAL_ENABLE_PIN_MAIN, MOTOR_SHIELD_CURRENT_MONITOR_PIN_MAIN);
DCCpp::beginProg(MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_B, DCC_SIGNAL_PIN_PROG, MOTOR_SHIELD_SIGNAL_ENABLE_PIN_PROG, MOTOR_SHIELD_CURRENT_MONITOR_PIN_PROG);
Arduino Uno or Mega2560 + Pololu MC33926 Motor Shield
DCCpp::beginMainPololu();
DCCpp::beginProgPololu();

or

DCCpp::beginMain(POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_A, DCC_SIGNAL_PIN_MAIN, POLOLU_SIGNAL_ENABLE_PIN_MAIN, POLOLU_CURRENT_MONITOR_PIN_MAIN);
DCCpp::beginProg(POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_B, DCC_SIGNAL_PIN_PROG, POLOLU_SIGNAL_ENABLE_PIN_PROG, POLOLU_CURRENT_MONITOR_PIN_PROG);
Ethernet Usage

To activate an Ethernet connection, one of the four ethernet defines must be activated :

  • USE_ETHERNET_WIZNET_5100 for Wiznet 5100 chip, present on the Arduino Ethernet Shield V1 and other shields.
  • USE_ETHERNET_WIZNET_5500 for Wiznet 5500 chip, present on the Arduino Ethernet Shield V2 and other shields.
  • USE_ETHERNET_WIZNET_5200 for Wiznet 5200 chip, present on the Arduino Ethernet Shield from Seeed and other shields.
  • USE_ETHERNET_ENC28J60 for cheap ENC28J60 chip, present on a lot of chinese Ethernet shields.

If one of these defines is activated, a line must be present somewhere in your code, defining an Ethernet server :

EthernetServer DCCPP_INTERFACE(NumPort);                  // Create and instance of an EthernetServer

where NumPort is a port number.

WARNING: if this line is not present, some errors will be raised during compilation, like "undefined reference to `eServer'" !