MARDEC, the Multifunctional Arduino DCC Decoder
In Mardec 7 is the DCC_library from Mynabay replaced by the NMRA DCC library.
That solves the Railcom problem. Previously it was not possible to use Railcom.
There are no other functional changes.
NEW in 6.0:
- The ‘bouncing’ of servos at the end of the rotation. The servo can bounce up to 4 times with angles of 1 to 9 degrees. This can be different for both angles.
- The test option for accessories has been changed. Instead of activating the accessory several times, the T-button can be used to turn the accessory on. This simulates the DCC signal.
- Buddy- and frogpoint ports can be chosen by yourself.
- The menu structure for changing accessories is simplified. Added the E-command; this is a combination of <enter> (=save) and the General E-command (=start of operating mode).
- The Single one shot can also be activated by a Down and/or an Up pulse.
- The two random functions are merged into one random function with on/off times from 20ms. to 600 sec.
It is also possible to set a fixed on or off time.
- An input now also has an inverted option.
- An individual port can now also be reset with the R command.
It is therefore no longer necessary to set the address to 0.
- Back to configuration state can now also be done with the P-command.
- The Quick-Config mode. This can be used to quickly make a change for a port.
With ‘P’ the configuration is started and the port number is requested immediately.
After the change you can immediately save the changes with ‘E’ and return to operating mode.
FIX: You can also use servo’s on ports 12 – 16
NOTE: because the storage of the configuration in EEPROM is changed Mardec must be reconfigured after updating from 4.0 to 6.0
MARDEC 6.1 contains a number bug fixes.
The double one shot did not work correctly
What is Mardec
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. Optionally you can also use analog switches to control accessories.
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 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 (1 sec.) to a configurable maximum value (1000 sec.) 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 (20 ms-600 sec.)
- 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
A print and the components (only €5,50!) can be ordered here. (Does NOT include an Arduino)
You can also use the DCCNext. The DCCNext combines an Arduino and the DCC shield on a single pcb. A separate Arduino is no longer required.
Addtional useful hardware:
When using the DCC shield 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.
Quite often you may need a relay for switching purposes. E.g. frog points
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.