DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Config.h
1 /**********************************************************************
2 
3 Config.h
4 COPYRIGHT (c) 2013-2016 Gregg E. Berman
5 Adapted for DcDcc by Thierry PARIS
6 
7 Part of DCC++ BASE STATION for the Arduino
8 
9 **********************************************************************/
10 #ifndef __config_h
11 #define __config_h
12 
13 #include "arduino.h"
14 
16 //
17 // DEFINE MOTOR_SHIELD_TYPE ACCORDING TO THE FOLLOWING TABLE:
18 //
19 // 0 = ARDUINO MOTOR SHIELD (MAX 18V/2A PER CHANNEL)
20 // 1 = POLOLU MC33926 MOTOR SHIELD (MAX 28V/3A PER CHANNEL)
21 
22 //#define MOTOR_SHIELD_TYPE 0
23 
25 //
26 // DEFINE NUMBER OF MAIN TRACK REGISTER
27 
28 #define MAX_MAIN_REGISTERS 12
29 
31 //
32 // DEFINE COMMUNICATIONS INTERFACE
33 //
34 // 0 = Built-in Serial Port
35 // 1 = Arduino.cc Ethernet/SD-Card Shield
36 // 2 = Arduino.org Ethernet/SD-Card Shield
37 // 3 = Seeed Studio Ethernet/SD-Card Shield W5200
38 
39 //#define COMM_INTERFACE 0
40 
42 //
43 // DEFINE STATIC IP ADDRESS *OR* COMMENT OUT TO USE DHCP
44 //
45 
46 //#define IP_ADDRESS { 192, 168, 1, 200 }
47 
49 //
50 // DEFINE PORT TO USE FOR ETHERNET COMMUNICATIONS INTERFACE
51 //
52 
53 //#define ETHERNET_PORT 2560
54 
56 //
57 // DEFINE MAC ADDRESS ARRAY FOR ETHERNET COMMUNICATIONS INTERFACE
58 //
59 
60 //#define MAC_ADDRESS { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF }
61 
63 //
64 // DEFINE PINS ACCORDING TO MOTOR SHIELD MODEL
65 //
66 
67 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) // Configuration for UNO
68 
69 #define DCC_SIGNAL_PIN_MAIN 10 // Ardunio Uno - uses OC1B
70 #define DCC_SIGNAL_PIN_PROG 5 // Arduino Uno - uses OC0B
71 
72 #elif defined(ARDUINO_AVR_MEGA2560)
73 
74 #define DCC_SIGNAL_PIN_MAIN 12 // Arduino Mega - uses OC1B
75 #define DCC_SIGNAL_PIN_PROG 2 // Arduino Mega - uses OC3B
76 
77 #endif
78 
80 // SELECT MOTOR SHIELD
82 
83 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_MAIN 3
84 #define MOTOR_SHIELD_SIGNAL_ENABLE_PIN_PROG 11
85 
86 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_MAIN A0
87 #define MOTOR_SHIELD_CURRENT_MONITOR_PIN_PROG A1
88 
89 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_A 12
90 #define MOTOR_SHIELD_DIRECTION_MOTOR_CHANNEL_PIN_B 13
91 
92 #define POLOLU_SIGNAL_ENABLE_PIN_MAIN 9
93 #define POLOLU_SIGNAL_ENABLE_PIN_PROG 11
94 
95 #define POLOLU_CURRENT_MONITOR_PIN_MAIN A0
96 #define POLOLU_CURRENT_MONITOR_PIN_PROG A1
97 
98 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_A 7
99 #define POLOLU_DIRECTION_MOTOR_CHANNEL_PIN_B 8
100 
102 {
103 #ifdef USE_ETHERNET
104  static uint8_t EthernetIp[4];
105  static uint8_t EthernetMac[6];
106  static int EthernetPort;
107 #endif
108 
109  static byte SignalEnablePinMain;// PWM : *_SIGNAL_ENABLE_PIN_MAIN
110  static byte CurrentMonitorMain; // Current sensor : *_CURRENT_MONITOR_PIN_MAIN
111 
112  static byte SignalEnablePinProg;
113  static byte CurrentMonitorProg;
114 
115  // Only for shields : indirection of the signal from SignalPinMain to DirectionMotor of the shield
116  static byte DirectionMotorA; // *_DIRECTION_MOTOR_CHANNEL_PIN_A
117  static byte DirectionMotorB; // *_DIRECTION_MOTOR_CHANNEL_PIN_B
118 };
119 
121 
122 #endif