BetterDuino Firmware V4

Estimated reading time: 14 min

Original Github: https://github.com/RealNobser/BetterDuinoFirmwareV4
Please read there as it will always provide more updated information than here.

Important Disclaimer

BetterDuinoFirmwareV4 has nothing to do with the original firmware made by Marc nor with the spinoff made by Neil! So if you have any questions about BetterDuino Firmware V4 don’t ask any of them!

If you find any issues, please use the github “Issues” mechanism. When you are an experienced software developer please feel free to submit pull requests. This is a living repository and I appreciate any community input!

Please do not contact astromech.net or open up a discussion in the astromech.net forum. astromech.net is not in charge with BetterDuinoFirmwareV4. You will not get any support or help regarding BetterDuino. On the other side, if you have questions about the original firmware for MarcDuino boards, then you are fine in the astromech forum.

If there are still questions not anserwed here, feel free to visit Michael Baddeleys fantastic Printed Droid community here: https://www.facebook.com/groups/printeddroid/ or https://www.facebook.com/groups/MrBaddeley .
You will be treated in a fair and polite way and we will find a solution or answer to your questions!

Update: Now there also is a BetterDuino support thread on Astromech.net: https://astromech.net/forums/showthread.php?44309-MarcDuino-Replacement-Firmware

Nevertheless: Read and understand, how the boards work, why there is a master and a slave board, how the boards are connected ->

https://www.curiousmarc.com/r2-d2/marcduino-system

https://astromech.net/forums/showthread.php?28414-Support-Thread-for-MarcDuino-v1-5-s

As soon as you are familiar with MarcDuino, come back here and proceed!

Why a Replacement Firmware for MarcDuino boards?

The last update to the original firmware was in 2018. Neil’s last update was a minor change in mid-2022. His V3 software has about 80% of the original source in common, adding some features for the latest MarcDuino boards (servo controllers and EXT/AUX pin controllers). He also added the nice feature of saving settings to EEPROM at runtime. But the code also has some glitches and bugs and is based on outdated Arduino libraries. I started 2023 after the whole Arduino framework and community has made really great progress in the last 5 years.

The BetterDuino Firmware V4 code has completely been rewritten from scratch. I took Neils idea of the EEPROM storage a step further, so nearly any setting is stored there. Including per-servo position settings. I also added the new panel animation of Tim Hebel who is also using a modified MarcDuino V3 firmware (https://github.com/Eebel/SHADOW_MD_EEBEL).

What is the MarcDuino system?

(from https://www.curiousmarc.com/r2-d2/marcduino-system):

“The MarcDuino system controls the animatronics of an R2 (dome panels, light and sound). It currently controls 10 dome panels, an “MP3 Trigger” sound board, dome “Teeces” lights and holoprojectors light and movements, and I2C gizmos you can add-in yourself. It has lots of pre-programmed effects making all these act together.

The system is centered around the MarcDuino boards which sit in the R2. There are two kinds, the Master and the Slave board, which are very similar to each other.” – CuriousMarc

What is BetterDuino Firmware V4?

The BetterDuinoFirmwareV4 software is a firmware replacement for the original MarcDuino V1.5Rev3 boards.

Details about the boards can be found here:

https://www.curiousmarc.com/r2-d2/marcduino-system/marcduino-boards/marcduino-v1-5

https://astromech.net/forums/showthread.php?28414-Support-Thread-for-MarcDuino-v1-5-s

The original firmware can be found here:

https://www.curiousmarc.com/r2-d2/marcduino-system/marcduino-software-reference

There also is a spinoff of Marcs firmware also known as MarcDuinoMain V3 and MarcDuinoClient V3:

https://github.com/nhutchison/MarcDuinoMain

https://github.com/nhutchison/MarcDuinoClient

New Features (excerpt)

  • Support for MP3 Trigger, DF Mini Player and R2-D2 / Astromech Vocalizer (https://humancyborgrelations.com/)
  • Identical firmware for Master and Slave
  • Automatic configuration of Master and Slave at first startup
  • per servo runtime settings for min/max and open/close positions
  • switch to modern OOP software design and use of most recent common Arduino libraries
  • fixed a lot of bugs at least of the V3 spinoff

Betterduino Firmware differences:

  1. BetterDuinoVxxx.hex
    BetterDuino for Master, Client (Slave) and Body. New I2C slave mode. DomeLift port is Master TX.
    Firmware for all modules, but I2C slave (original has I2C master). DomeLift commands go out via TX.
  2. BetterDuinoVxxx_DL_AUX.hex
    BetterDuino for Master, Client (Slave) and Body. DomeLift port is Master AUX instead of Master TX.
    Firmware for all modules, but I2C slave (original has I2C master). DomeLift commands go out via AUX.
    For Domelift usage with Astrocomms
  3. BetterDuinoVxxx_Master+Client_ClassicI2C.hex
    BetterDuino for Master and Client (Slave), Classic I2C Master Mode. No Dome Lift Support.
    Like 1, but with the old I2C master mode. Because of the memory, there is only space for the dome master and slave. Exists for backwards compatibility. This basically corresponds to the original MarcDuino concept. For Body Master you have to take 1 or 2.
  4. BetterDuinoVxxx_Master+Client_NeoPixel.hex
    BetterDuino for Master and Client (Slave). DomeLift port is Master TX. NeoPixel support for Holo Lights.
    Same as 1, but with NeoPixel support Due to memory, there is only space for the dome master and slave. For Body Master you have to take 1 or 2.

Lets get started:

Revision History

DateRevDescription
2024-04-05V1.0.12Additional BT-1 Sequence
2024-04-04V1.0.11Sound Hotfix
2024-04-03V1.0.10Random Sound fixes, BT-1 Sequence
2024-03-20V1.0.9EEPROM protection, Brownout Setting
2024-03-20V1.0.8Added Dome Lift integration
2024-03-17V1.0.7removed R2Touch Keepalives, fixed DFMini command sequences
2024-03-09V1.0.6NeoPixelHolo configuration
2024-03-08V1.0.5NeoPixelHolo-Integration, Bugfix Servo 12/13
2024-01-30V1.0.4First Chopper Integration
2024-01-17V1.0.3Added free panel positioning to panel sequences 0% = closed / 100% = open
2024-01-15V1.0.2BugFix-Release
2024-01-13V1.0.1Classic Master I2C and new I2C slave mode
2023-12-30V1.0.0First stable public version
2023-12-11V0.9.1 RCBugfixes from closed beta test group
2023-10-23V0.9.0 RC1First version for closed beta test group

Known MISSING functionality compared to the original source (will be released in the future):

  • RC-IN support

Known ISSUES:

  • MP3-Trigger: stopping only pauses, workaround pending (playing an empty soundfile).

Supported Boards

BoardSupportRemark
MarcDuino V1.5 Rev3YES
MarcDuino V1.5 Rev2YESServo 11 = Master AUX2
Servo 12 = Slave ML
Servo 13 = Slave AUX2
Magic Panel = Slave “To Slave”
Printed Droid AIO2.0
YESServo 11 = Master A2
Servo 12 = Slave ML
Servo 13 = Slave A2
Magic Panel = Slave2
BenDuino boards (https://www.printed-droid.com/kb/benduino-system/)YESServo 11 = Master A2
Servo 12 = Slave ML
Servo 13 = Slave A2
Magic Panel = Slave2
MarcDuino V1NO
MarcDuino V2NO

Compatibility Matrix

Master/Salve1.83.x4.x
1.8YESYESYES
3.xYESYESYES
4.xYESYESYES

Uploading firmware using *.hex files

Development Environment

Building and uploading firmware using Visual Studio Code

Clone the GitHub repository using Visual Studio Code (Source Control / Clone Repository)

Open local folder

Edit the file “platformio.ini” to match the serial port of your programmer:
upload_port = /dev/cu.usbmodem141201 (example)

build the code (PlatformIO / ATmega328P / General / Build)

upload the code (PlatformIO / ATmega328P / General / Upload)

Compiler defines in include/config.h

Normally you do not need to change the defines, but, for experienced users, some instructions:

DefineFunctionRemarkDefault
R2D2build standard R2D2 MarcDuino compatible firmwareOnly choose one, R2D2 or Chopperon
CHOPPERBETA build new Chopper compatible firmwareOnly choose one, R2D2 or Chopperoff
DEBUG_MSGactivate additional debug messages on the USB/Serial-Portprogram size will exceed, so you can only use that in combination with the DEDICATED_FIRMWARE flagoff
INCLUDE_CLASSIC_I2C_SUPPORTactivate support for the classic MarcDuino I2C commandsprogram size will exceed, so you can only use that in combination with the DEDICATED_FIRMWARE flagoff
INCLUDE_I2C_SLAVEactivate support for the ne I2C Slave supporton
DEDICATED_FIRMWAREwhen dedicated hex-files for Dome Master, Dome Slave and Body Master are needed, activate this setting with one of the following settingsneeded, when programm size in combined mode will be exceededoff
DEDICATED_MASTERgenerates hex file with Dome Master code onlyMust be set in combination with DEDICATED_FIRMWAREoff
DEDICATED_SLAVEgenerates hex file with Dome Salve code onlyMust be set in combination with DEDICATED_FIRMWAREoff
DEDICATED_BODYgenerates hex file with Body Master code onlyMust be set in combination with DEDICATED_FIRMWAREoff

…more to follow…

Do not touch any other of the defines.

Connecting Servos R2D2 (common way)

Master:

ServoFunctionRemark
Servo 1Panel 1Lower Panel
Servo 2Panel 2Lower Panel
Servo 3Panel 3Lower Panel
Servo 4Panel 4Lower Panel
Servo 5Panel 5Lower Panel
Servo 6Panel 6Lower Panel
Servo 7Panel 7Upper Panel
Servo 8Panel 8Upper Panel
Servo 9Panel 9Upper Panel
Servo 10Panel 10Upper Panel
Servo 11unused
AUXunused

Client:

ServoFunctionRemark
Servo 1Front Holo, V-Servo
Servo 2Front Holo, H-Servo
Servo 3Rear Holo, V-Servo
Servo 4Rear Holo, H-Servo
Servo 5Top Holo, V-Servo
Servo 6Top Holo, H-Servo
Servo 7Front Holo Light
Servo 8Rear Holo Light
Servo 9Top Holo Light
Servo 10=12unusedControlled as Servo 12 via Master
Servo 11=13unusedControlled as Servo 13 via Master
AUXunused

Body:

ServoFunctionRemark
Servo 1DPL – DataPanel Door
Servo 2UtlArmU – Upper Utility Arm
Servo 3UtlArmL – Lower Utility Arm
Servo 4LBdyDr – Left BreadPan Door
Servo 5LArm – Left Arm Raise/Lower
Servo 6LArmTool – Left Arm Tool
Servo 7ToolRBdyDr – Right BreadPan Door
Servo 8RArm – Right Arm Raise/Lower
Servo 9RArmTool – Right Arm Tool
Servo 10unusedFuture Charge Bay Door servo
Servo 11unused
AUXunused

Connecting Servos Chopper

Master:

ServoFunctionRemark
Servo 1Left Dome Door
Servo 2Left Dome Arm
Servo 3Left Dome Gripper
Servo 4Left Dome Arm TurnTim Hebel Mod
Servo 5Right Dome Door
Servo 6Right Dome Arm
Servo 7Right Dome Gripper
Servo 8Right Dome Arm TurnTim Hebel Mod
Servo 9Periscope Lift
Servo 10Periscope Turn
Servo 11unusedPeriscope LED?
AUXunused

Connecting Servos BT1

Master:

ServoFunctionRemark
Servo 1Launcher 1Left Launcher Panel
Servo 2Launcher 2Right Launcher Panel
Servo 3Rockets 1Left Rockets Firing
Servo 4Rockets 2Right Rockets Firing
Servo 5unused
Servo 6unused
Servo 7unused
Servo 8unused
Servo 9unused
Servo 10unused
Servo 11unused
AUXunused

Slave:

ServoFunctionRemark
Servo 1Front Holo, V-Servo
Servo 2Front Holo, H-Servo
Servo 3unused
Servo 4unused
Servo 5unused
Servo 6unused
Servo 7Front Holo Light
Servo 8unused
Servo 9unused
Servo 10 = 12unusedControlled as Servo 12 via Master
Servo 11 = 13unusedControlled as Servo 13 via Master
AUXunused

Body:

ServoFunctionRemark
Servo 1DPL – DataPanel Door
Servo 2UtlArmU – Upper Utility Arm
Servo 3UtlArmL – Lower Utility Arm
Servo 4LBdyDr – Left BreadPan Door
Servo 5LArm – Left Arm Raise/Lower
Servo 6LArmTool – Left Arm Tool
Servo 7ToolRBdyDr – Right BreadPan Door
Servo 8RArm – Right Arm Raise/Lower
Servo 9RArmTool – Right Arm Tool
Servo 10Charge Bay Door
Servo 11unused
AUXunused

Assigning Roles

The same version of BetterDuino firmware will be used for MarcDuinos Master, Slave and Body Master. For the newly flashed MarcDuinos to know their role, we have to assign them to each one.

To do so, you will have to establish a Serial Monitor connection to your new flashed MarcDuino. You could you the Serial Monitor inbuild into ArduinoIDE or add the Serial Monitor Extension to Visual Studio Code.

You will have to set the baud-rate to 9600 to be able to establish a communication.

When connecting via the Serial Terminal, you should be welcomed with a message similar to:

To assign the needed role to your MarcDuino, you need to enter one of the following commands, depending on the role that you want this MarcDuino to have:

  • #MD00 for MarcDuino Dome Master
  • #MD01 for MarcDuino Dome Slave
  • #MD02 for MarcDuino Body Master

MarcDuino will reboot immediately after setup and start up in new mode.

Hint: Default config after factory reset is MarcDuino Dome Master. A board connected to the slave port of the MarcDuino Master will automatically be configured as Dome Slave. A Body Master has either to be configured manually or by an additional startup command “#MD02”, sent only to the Body Controller.

MarcDuino/BetterDuino Commands

Unsupported original MarcDuino features:

· no Panel/Servo RC_IN support

· some configuration commands are not supported / necessary due to cleaned command processing / storage

Commands

Routing

All commands are sent to the master board. The slave board is always connected to the master board. Slave boards are not running in stand-alone mode. So the master board decides what to do with the commands. It might process or even omit the command.

Format

Every command must start with one of these special characters (defined in the header file). The start character is recognized in the main loop:

Command processing

Start CmdFunctionMaster processMaster InterfaceSlave processSlave InterfaceRemark
:Pie panel commandsPROCESSED

FORWARDED TO SLAVE P12/P13
Servos

Serial_Slave
PROCESSEDServosSlave is only responsible for panel 12/13
*Holo Projector (HP) commandsNOT PROCESSED

FORWARDED TO SLAVE
Serial_SlavePROCESSEDServos
@Display commandsNOT PROCESSED

FORWARDED TO SLAVE
Serial_SlavePROCESSEDSerial_Teeces
$Sound commandsPROCESSED

NOT FORWARDED
Serial_MP3NOT AVAILABLE
! (Master)Alt1 alternate sound commands, passed to Serial_MP3 after stripping start command characterPROCESSED

NOT FORWARDED
Serial_MP3NOT AVAILABLE
! (Slave)Alt1 alternate display commands, passed to Serial_Teeces after stripping start command characterPROCESSEDSerial_TeecesIn normal use the Master MarcDuino catches these, so we don’t see them
%Alt2 alternate Holo Projector board commands, passed to Serial_Slave without stripping start command characterNOT PROCESSED

FORWARDED TO SLAVE
Serial_SlavePROCESSEDSerial_Magic
#Setup CommandsPROCESSED

FORWARDED TO SLAVE
EEPROM

Serial_Slave
PROCESSEDEEPROM#MDxx command (MarcDuino mode) will not be forwarded to slave
&I2C-CommandsPROCESSED

FORWARDED TO SLAVE
I2C

Serial_Slave
PROCESSEDI2C

Panel Commands

They must follow the syntax “:CCxx\r” where CC=command , xx= two digit decimal number, \r is carriage return.

CommandFunctionMasterSlaveRemark
:SExxlaunches sequences, see belowYESYES
:OPxxopen panel number xx=01-13. If xx=00, opens all panels (12/13 Slave only)YESYES
:OP14open top panelsYESNOtbd
:OP15open bottom panelsYESNOtbd
:CLxxclose panel number xx=01-13, removes from RC if it was, stops servo. If xx=00, all panels, slow close.YESYES
:LKxxlock panel number xx=01-13, lock current position to avoid problems with DomeLift. If xx=00, locks all panels (12/13 Slave only)YESYES
:ULxxunlock panel number xx=01-13, unlocks panel, normal mode. If xx=00, unlocks all panels (12/13 Slave only)YESYES
:RCxxplaces panel xx=01-13 under RC input control. If xx=00, all panels placed on RC.YESNO
:STxxbuzz kill/soft hold: removes panel from RC control AND shuts servo off to eliminate buzz. xx=00 all panels off RC servos off.YESYES
:HDxxRC hold: removes from RC, but does not turn servo off, keeps at last position. xx=00 all panels hold.YESNO
:MVxxddddmove panel xx=01-13 to position yyyy. If xx=00, opens all panels (12/13 Slave only), dddd=0000-0180 deg, dddd > 0544 MicrosecondsYESYES

Sequence Command Details

See sequence_command, panel sequence matrices defined in panel_sequences.h

CommandFunctionRemark
Full (Move, Sound, Display…)
:SE00Close all panels (full speed), servo off – use as init only. Use CL00 for all soft close.
:SE01Scream, with all panels open
:SE02Wave, one panel at a time
:SE03Fast (Smirk) back and forth wave
:SE04Wave 2 (open progressively all panels, then close one by one)
:SE05Beep Cantina (with marching ants panel action)
:SE06Faint/Short Circuit
:SE07Cantina dance (orchestral, rythmic panel dance)
:SE08Leia
:SE09Disco
:SE10Quite Mode reset (panel close, stop holos, stop sounds)
:SE11Full Awake Mode reset (panel close, random sound, holo movement, no holo lights)
:SE12Top Panels to RC
:SE13Mid Awake Mode reset (panel close, random sound, stop holos)
:SE14Awake+ Mode reset ((panel close, random sound, holo movement, lights on)
:SE15Screams no panels
:SE16Panel Wiggle
Body Sequences
:SE30Utility ARM open and close sequence
:SE31All Body Panels open and close sequence
:SE32All Body Doors open and wiggle close sequence
:SE33Body – Use Gripper
:SE34Body – Use Interface Tool
:SE35Body – Ping Pong Body Doors
:SE36Body – BT-1 Two gripper SequenceThanks to David Steinke
Move Panels only
:SE51Scream, with all panels open
:SE52Wave, one panel at a time
:SE53Fast (Smirk) back and forth wave
:SE54Wave 2 (open progressively all panels, then close one by one)
:SE55Marching ants
:SE56Faint/Short Circuit
:SE57Rhythmic panel dance
:SE58Panel Wave Bye Bye

Holo Projector Commands

These commands are only processed by the MarcDuino Slave module

CommandFunctionRemark
*RDxxRandom Holo movement (xx=01 to 03). xx=00 and >3 all random.
*ONxxTurns Holo Light on (xx=01 to 03). xx=00 or >3 all lights on
*OFxxTurns Holo Lights off (xx=01 to 03). xx=00 turns all lights off
*ONxxaaabbbcccdddTurns RGB Holo Light on (xx=01 to 03). xx=00 or >3 all lights on.
aaa – decimal R value (0-255)
bbb – decimal G value (0-255)
ccc – decimal B value(0-255)
ddd – brightness (0-255)
*COxxaaabbbcccdddSets color for RGB Holo Light (xx=01 to 03). xx=00 or >3 all lights on.
aaa – decimal R value (0-255)
bbb – decimal G value (0-255)
ccc – decimal B value(0-255)
ddd – brightness (0-255)
*RCxxHolo vertical movement under RC control, horizontal centered (xx=01-03). 00 or >3 all RC
*TExxHolo movement test (xx=01-03). Goes through a loop of holo movements to assist in adjusting holo servos mechanical setup. 00 or >3 all HPs to test
*STxxstop/reset Holos random movement, turns lights off, and RC off. 00=all off
*HDxxhold: stop holo, do not change light level. 00=all stopped
*MOxxmagic panel on. xx=01 to 98, on from 1 to 98 seconds.

· xx = 99 is on permanently

· xx = 00 is off
*MFxxmagic panel flicker xx=1 to 99 flicker for 1 to 99 seconds. 00= off.
*H1xx

*H2xx

*H3xx

*H0xx
Will turn on-board HP1, 2, 3, and all (HP0xx) for xx seconds.

· xx = 99 is on permanently

· xx = 00 is off
*HzxxaaabbbcccdddSee “*H0”-”*H3”
aaa – decimal R value (0-255)
bbb – decimal G value (0-255)
ccc – decimal B value(0-255)
ddd – brightness (0-255)
*F1xx

*F2xx

*F3xx

*F0xx
Will flicker on-board HP1, 2, 3, and all (F0xx) for xx seconds.

· xx = 99 is on permanently

· xx = 00 is off
 *Fzxxaaabbbcccddd See “*F0”-”*F3”
aaa – decimal R value (0-255)
bbb – decimal G value (0-255)
ccc – decimal B value(0-255)
ddd – brightness (0-255)
 
*CHxxCenter Holo Nr xx

Sound Commands

These commands are only processed by the MarcDuino Master module

CommandFunctionRemark
$xyyPlay sound command by bank/sound numbers

* x=bank number

* yy=sound number. If none, next sound is played in.
$xyPlay sound command by bank/sound numbers, short version

* x=bank number

* y=sound number. If none, next sound is played in.
$Crandom from 4 first banks
$Osound off
$LLeia message (bank 7 sound 1)
$CCantina music (bank 9 sound 5)
$cBeep cantina (bank 9 sound 1)
$SScream (bank 6 sound 1)
$FFaint/Short Circuit (bank 6 sound 3)
$DDisco (bank 9 sound 6)
$sstop sounds
$+volume up
$-volume down
$mvolume mid
$fvolume max
$pvolume min
$WStar Wars music (bank 9 sound 2)
$wBeep Star Wars music (bank 9 sound 7)
$MImperial March (bank 9 sound 3)
$iBeep Imperial March (bank 9 sound 8)
$BStartup Sound

Special Features

CommandFunctionRemark
*EOxx

TO SLAVE
Pull pin high/low on AUX1. Can be used to trigger a smoke machine as an example.

xx is the time in seconds.

* 00 – off

* 01-98 is the time in seconds (don’t use values >10 for smoke machines!)

* 99 on permanently (again don’t use for smoke machines)
will be executed on SLAVE only
:EOxxPull pin high/low on AUX1. Can be used to trigger a smoke machine as an example.

xx is the time in seconds.

* 00 – off

* 01-98 is the time in seconds (don’t use values >10 for smoke machines!)

* 99 on permanently (again don’t use for smoke machines)
will be executed on MASTER only

BetterDuino Firmware V4 and greater

Setup Commands

CommandFunctionRemark
Servo Controls
#SOxxddddSet Servo xx Degrees/Microseconds for Panel Open, dddd=0000-0180 deg, dddd > 0544 Microseconds
#SCxxddddSet Servo xx Degrees/Microseconds for Panel Closed dddd=0000-0180 deg, dddd > 0544 Microseconds
#SPxxdddSet Servo xx Speed, ddd=0-255
#SWxxSwap Panel xx Open<->Close valueDon’t use as the classic “reverse servo” command. Don’t call it at every boot, just use it in adjustment process.
Startup Sound Controls
#SSxxxSet startup sound

· #SS000 : Disable Startup Sound, and remove startup sound delay for fast boot of R2

· #SSxxx : Set Startup Sound in file xxx
#SQxxChatty / Silent mode

· #SQ00 : Default Chatty Mode

· #SQ01 : Silent on startup
#SMxxDisable Random Sound

· #SM00 : Random Sound on

· #SM01 : No Random Sound + Volume off

· #SM02 : No Random Sound
#SXxxSet Max Random Pause in seconds – Maximum timespan between two random sounds
#SYxxSet Min Random Pause in seconds – Minimum timespan between two random sounds
Panel Sequencer Controls
#STxxxSetup Delay time between Master and Slave Panel Sequence. Use this if the Slave panels are starting too soon. Values up to 255 are supported. Values are in ms.maybe depricated
System Configuration and Management
#MDxxSet MarcDuino Mode

· #MD00 : MarcDuino Dome Master

· #MD01 : MarcDuino Dome Slave

· #MD02 : MarcDuino Body Master

MarcDuino will reboot immediately after setup and start up in new mode.
#MPxxSet MP3-Player Type

· #MP00 : SparkFun MP3 Trigger

· #MP01 : DFPlayer

· #MP02 : Vocalizer
#MSxyySet maximum sounds per soundbank. x=1-9 (Soundbank), y=0-25 (max. Sounds)
Holo Projector Configuration
#HLxySet HoloLight x to High Active (y=1) or Low Active (y=0). x=0 → All Holo LightsReset board afterwards to take effect
#HNxySet HoloLight x to NeoPixel (y=1) or Standard-LED (y=0). x=0 → All Holo LightsReset board afterwards to take effect
#HXxxyyConfigure number of LEDs (yy) for HoloLight xx.Will only be used, if HoloLight xx is set to NeoPixel, Reset board afterwards to take effect
#HOxxddddSet Holo HServo Degrees/Microseconds Max, dddd=0000-0180 deg, dddd > 0544 Microseconds
#HCxxddddSet Holo HServo Degrees/Microseconds Min, dddd=0000-0180 deg, dddd > 0544 Microseconds
#HPxxdddSet Holo HServo Speed, ddd=0-255
#VOxxddddSet Holo VServo Degrees/Microseconds Max, dddd=0000-0180 deg, dddd > 0544 Microseconds
#VCxxddddSet Holo VServo Degrees/Microseconds Min, dddd=0000-0180 deg, dddd > 0544 Microseconds
#VPxxdddSet Holo VServo Speed, ddd=0-255
#DUxxDump EEPORM to serial

· #DUxx : value at address xx

· #DUMP : dump complete EEPROM content
DEACTIVATED AT THE MOMENT, UNDER REVISON
#RSETRestart MarcDuino
#ADxxAdjustment Mode: When setting up individual Servo settings, servo will positioned immediately

· #AD00 : Adjustment Mode Off

· #AD01 : Adjustment Mode On

I2C Commands (Classic, Master-Mode)

Source:

https://www.curiousmarc.com/r2-d2/marcduino-system/marcduino-software-reference/marcduino-command-reference#h.p_EQOGPlR2RuOk

If you send a command following the format:

*&I2Caddress, data, data, data…

an I2C write command will be generated on all the I2C ports in the MarcDuino chain (master and all slaves). The write command will be addressed to the device at I2Caddress and will write all the data bytes provided in order.

Data can be decimal numbers, hex bytes, characters or strings, depending on the prefix appended to the data, as follows.

Decimals need no prefix. Valid range is -128 to 255. For example, to send command 2 (decimal) to an I2C device at address 25:

*&25,2

To send an hex byte, add x as a prefix. To send the hex byte 0xFF to device 25:

&25,xFF

To send a single character, use the ‘ prefix

&25,’c

To send a string, use the ” prefix. Don’t put another ” at the end or it will be transmitted as part of the string…

&25,”Hello World (note: there is no second ” at the end of the string)

And of course you can mix everything:

&25,2,xFF,’c,”Hello World

I2C Commands (New, Slave-Mode)

MarcDuino boards with NewDuino firmware are enabled to receive any serial command also as I2C slave via the I2C interface. So other componetes beside the main control system (ShadowMD etc.) are able to execute commands or start sequences (e.g. dome lift). The protocol is pretty simple, just send an I2C message to one of the following slave addresses with data payload identical to one of the commands described above (don’t forget dto finalise the command with 0x0a = ‘\r’ = Carriage Return.

I2C-Address (dec/hex)Type
50/0x32MarcDuino Dome Master
51/0x33MarcDuino Dome Slave
52/0x34MarcDuino Body Master

I2C addresses can be changed in include/config.h if needed.

Best practice panel adjustment

  • Connect a serial interface to the “XBEE/SERIAL IN” port of your board
  • Open a serial terminal program and connect via 9600 Baud, 8N1. Activate character echo in your terminal program.
  • Use the new “Move Panel” (:MVxxdddd) command to get a feeling, which is the area, the servo moves within.
  • If you find a valid position for “open”, store it with the command “Store Open” (#SOxxdddd)
  • If you find a valid position for “closed”, store it with the command “Store Closed” (#SCxxdddd)

Example:

  • If you think, “:MV010900” moves panel/servo #1 to a valid open position, store the setting with “#SO010900”
  • If you think, “:MV011750” moves panel/servo #1 to a valid closed position, store the setting with “#SC011750”
  • :MVxxdddd does not store any position, it just moves the servo to the PWM/degree value

Shortcut

  • If the default positions are fine but swapped (:OP01 closes the panel and :CL01 opens it), just use “#SW01” to swap the values for open and closed position. The values are automatically stored. Important: That command is not identical to the “Reverse Servo” command. Just use the swap command while calibrating your servos, not at every startup. Otherwise it will always toggle the settings on every startup.
  • Repeat all the steps until each servo is calibrated

Connection Dome Lift to MarcDuino boards

Please use BetterDuino firmware V1.0.8 or higher. New I2C slave mode must be activated (standard in BetterDuino, classic I2C Master mode also available in dedicated firmware, see config.h).

  • Connect Master InterCom-TX to Dome Lift RX0
  • Connect I2C bus from MarcDuino board to Dome Lift Board
  • Use modified dome lift firmware (https://github.com/RealNobser/DomeLiftMechanism/tree/main)
  • New MarcDuino comand is :LIxx. To be compatible with the R2Touch-App the command mapping is as follows:
CmdAction
:LI07Bad Motivator
:LI08Dome Zapper
:LI09Lightsaber
:LI10Life Form
:LI11Periscope

EEPROM Memory Map

All the settings of the “Setup Commands” are stored in EEPROM. The corresponding Memory Map is described here. Default settings when EEPROM is empty are written in bold letter.

AddressTypeContentDefaultDescription
0x00byteSW-/Config-VersionVersion 4.0.x = 40, Version 4.1.x = 41, …
0x01byteMarcDuinoType0 = DomeMaster0 = DomeMaster

1 = DomeSlave

2 = BodyMaster
0x02byteDEPRICATED
0x03byteChatty/Silent Mode0 = Chatty0 = Chatty

1 = Silent
0x04byteMP3-Player-Type0 = SparkFun MP3-Trigger0 = SparkFun MP3-Trigger

1 = DF-Mini Player

2 = Vocalizer
0x05byteDisable Random Sound0 = Random Sound0 = Random Sound

1 = No Random Sound + Volume off

2 = No Random Sound
0x06byteSlave Delay0 = 0ms delaySequence Delay for Slave Sequence Start in ms, 0-255
0x07byteDEPRICATED (Slave Delay 2. Byte)
0x08byteNumber of Servos13 = 13 Servos (Master + Slave)
0x09byteStartup Sound Nr255 = Sound #255Startup Sound Number, 0 = Disable Startup Sound and remove startup sound delay for fast boot of R2
0x0abyteMinRandomPause in seconds6 = 6s PauseMinimal Pause between two Random sounds played
0x0bbyteMaxRandomPause in seconds12 = 12s PauseMaximal Pause between two Random sounds played
0x0cbyteDEPRICATED
0x0dbyteAdjustment Mode0 = offAdjustment Mode active (0 = off, 1 = on)
0x11 – 0x19bytesMax Sound Bank 1-9Standard SD-Card-Layout:

Bank 1: 0x11 = 19
Bank 2: 0x12 = 18
Bank 3: 0x13 = 7
Bank 4: 0x14 = 4
Bank 5: 0x15 = 3
Bank 6: 0x16 = 3
Bank 7: 0x17 = 3
Bank 8: 0x18 = 6
Bank 9: 0x19 = 8
Bank 1-9, Number of Sounds 1-25
0x20-0x2ffreed
0x30freed
0x31-0x3dbytesServo1-Servo13 Servo Speed255 = max Speed0 = Minimum

255 = Maximum
0x40-0x41freed
0x42-0x5awordsServo1-Servo13 Servo Open Position Degrees / PWM1000 = 1000 Microseconds Pulse WidthDegrees/Microseconds for Panel Open 0-360=deg, values greater 544 are microseconds
0x60-0x61freed
0x62-0x7awordsServo1-Servo13 Servo Close Position Degrees / PWM2000 = 2000 Microseconds Pulse WidthDegrees/Microseconds for Panel Closed 0-360=deg, values greater 544 are microseconds
0x80-0xaffreed
0xb0-0xb3freed
0xb4-0xbewordsServo1 Holo1-Servo-H Min Position Degree / PWM
Servo2 Holo1-Servo-V Min Position Degree / PWM

Servo3 Holo2-Servo-H Min Position Degree / PWM
Servo4 Holo2-Servo-V Min Position Degree / PWM

Servo5 Holo3-Servo-H Min Position Degree / PWM
Servo6 Holo3-Servo-V Min Position Degree / PWM
1000 = 1000 Microseconds Pulse WidthDegrees/Microseconds for Holo Min Position 0-360=deg, values greater 544 are microseconds
0xc0-0xc3freed
0xc4-0xcewordsServo1 Holo1-Servo-H Max Position Degree / PWM
Servo2 Holo1-Servo-V Max Position Degree / PWM

Servo3 Holo2-Servo-H Max Position Degree / PWM
Servo4 Holo2-Servo-V Max Position Degree / PWM

Servo5 Holo3-Servo-H Max Position Degree / PWM
Servo6 Holo3-Servo-V Max Position Degree / PWM
2000 = 2000 Microseconds Pulse WidthDegrees/Microseconds for Holo Max Position, 0-360=deg, values greater 544 are microseconds
0xd1-0xd3bytesHolo 1-3 Light High- or Low-Active1 = High-ActiveHolo Light High- or Low-Active, 0 = LowActive / 1 = HighActive
0xe0-0xe1freed
0xe2-0xe7Servo1 Holo1-Servo-H Speed (0-255)

Servo2 Holo1-Servo-V Speed (0-255)

Servo3 Holo2-Servo-H Speed (0-255)

Servo4 Holo2-Servo-V Speed (0-255)

Servo5 Holo3-Servo-H Speed (0-255)

Servo6 Holo4-Servo-V Speed (0-255)
255 = max Speed0 = Minimum

255 = Maximum
Tags:
Was this article helpful?
Dislike 0 0 of 0 found this article helpful.
Views: 686
Previous: AstroCan Control System
Next: AstroCan Pro Dual Shield