MARDEC, the Multifunctional Arduino DCC Decoder
* The restore of servo’s at startup to its last position did not work properly (Thanks Ruud Boer)
* The servo position was not saved in configure mode when a + or – command was the last command before saving.
* Putty speed set to 57600 baud
* When displaying an adress/pin it is always showed as A<address>/P<pin>
E.g ‘Servo on A15/P15 set to 108 degrees’ or ‘Specify action for servo on A2/P3’
* Added a generic option to detach a servo or not.
* Added an option to set startup mode (Last, Config or Normal mode)
* Added the generic I-command. This command let you change:
the Mardec number, Roco offset, Startup mode, Default servo speed, detach servo option
* Added the I-command for Accessories. This inverts the output. E.g. a led is turned off instead of turned on and vice versa.
* Added better support for MEGA2560.
On a MEGA the (logical) pins 14 to 19 controls the (physical) pins 54 to 59
* The default rotation speed is now part of the generic I-command.
* Some minor display enhancements.
MARDEC is a program(aka a sketch) for the Arduino microcomputer. It uses the DCC-signal from the DCC-central to control all kinds of accessories on your model railway.
Two modes of operation
MARDEC runs in two different modes. A configure mode and a run time mode.
In configure mode you specify for each pin of the Arduino the DCC address and the required action to perform.
The Arduino is connected via USB to your computer. With only your keyboard and monitor you can easily, with a simple question and answer ‘game’, specify all the functions that you want to perform with MARDEC. Therefore MARDEC uses one-character commands. See the manual for examples. It communicates with you by using a terminal emulator program called Putty.
No complex puzzling with CV’s!
With the E-command (Exit) you change to run time mode.
In run time mode MARDEC ‘listens’ to the DCC signals on your track.
If an address passes by that you have configured for one of the Arduino pins, MARDEC will execute the action that was configured for it in configure mode.
All MARDEC features one by one
- Controlling up to 12 servos for turnouts without frog point polarization or up to 8 servos with frog point polarization. The frog point polarization is realized by means of an external relay. Of course you can use a servo also for other purposes like opening and closing doors or signal arms
- The control of accessories in 10 different ways, including activating turnout coils and variable PWM control.
- An Arduino pin can also be configured as an input. By triggering an input three other (output) pins can be activated. Two of them with a time delay.
- Interactive, so via monitor and keyboard, configure the servos and accessories.
That is completely independent of the used DCC Central. The Arduino software is not necessary.
- Of each servo the start and end angle can be set accurately on the degree.
- A random DCC address (1-2048) can be assigned to each servo and accessory.
- Each servo (max. 8) can be coupled with a relay for frog point polarization.
When rotating the servo, halfway through the twisting, this relay will be converted.
- For each servo a separate rotation speed can be set. This enables servos easier for other purposes than just turnouts
- A test option. All the servos will rotate twice. The accessories are also activated.
- Capture of ‘ inversion ‘. With this option you can set whether a turnout is set to straight or rounded when the servo rotates to either angle. This is required because the servo can be mounted in several ways.
- A documentation option to show all settings.
- Assign an administrative number to each connected device
- A reset option to clear all settings from the MARDEC memory.
- Adjustable default speed of the servo (5-50 ms. per degree). But each servo can be set separately.
- After a restart the servo’s and accessories are restored to the last settings
- Return to configuration mode by connecting the USB cable, start configuration program and press ‘C’.
- Option to correct the address offset of Roco command stations (MM, z21, Z21)
- Accessories have the following options:
- Single steady. Sets an output pin permanent high or low.
- Double steady. Same as single steady, however a second pin has the inverted value.
- Single flashing. A pin switches continuously between high and low. The high and low times can be set separately.
- Double flashing. Same as single double, however a second pin has the inverted value.
- Single one shot. An output pin is activated for a short, configurable, time on the low to high transition of the DCC signal.
- Double one shot. Same as Single one shot. But a second output is also activated on the high to low transition of the DCC signal. This can used for turnouts with coils
- Analoge (PWM=Pulse Width Modulation) An output pin is set from a configurable minimum value to a configurable maximum value in a configurable time on the low to high transition of the DCC signal and from the maximum value to the minimum value on the high to low transition of the DCC signal.
- Flicker mode. A connected led can flicker to simulate fire or welding.
- Random on/off. A connected led goes continuously on and off. The on/off times are randomly chosen between two configurable values (2-500 sec.)
- Disco lights. A connected led goes continuously on and off. The on/off times are randomly chosen between two configurable values (2-500 millisec.) .
Same as Random on/off but 1000 times faster.
- A Help option shows all the availabale commands for configuring Mardec
- A log option saves all configure and run time actions on disk.
- Independant of used bus structure (LocoNet, S88 etc).
But the input for Mardec is always DCC.
The standard DCC signal can’t be used directly to an Arduino.
A small electronic circuit is required to adapt the DCC signal for the Arduino:
You can make this circuit yourself on a piece of veroboard.
But it is much more convenient to use a dedicated shield for the Arduino UNO:
This shield contains the DCC-circuit and also a 9 Volt power supply for the Arduino and an additional 5 Volt for e.g. leds, relays or servo’s. However it is strongly advised that you use an external 5 Volt power supply for multiple relays and servo’s.
The same shield is used for the Arsigdec
How to connect:
Addtional useful hardware:
Of course you need an Arduino: Get your Arduino’s here
If you need more power to switch an accessory (e.g. a turnout coil or led strip) you can use a MOSFET transistor. A simple and cheap solution is a complete print like this:
You can get them here
You can connect them directly to your Arduino.
Quit often you may need a relay for switching purposes. E.g. frogpoints
Here is an other simple and cheap solution:
You can get them here
They are also available with 4 and 8 relays on a single print.
You can connect them directly to your Arduino.