Sketch not running after restarting Arduino (DMX)

I'm working on a project using the CQ Robot DMX shield and the Conceptinetics DMX library. I'm having a problem with one of the examples from the library.

If I upload it to the Arduino it runs fine and it turns an LED on/off based on the DMX value as expected.

But if I unplug the Arduino from power and plug it back in, the sketch doesn't seem to work anymore. The LED light doesn't respond to the DMX value.

Any idea what could cause this?

Here's the example sketch.

/*
  DMX_Slave.ino - Example code for using the Conceptinetics DMX library
  Copyright (c) 2013 W.A. van der Meeren <danny@illogic.nl>.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 3 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


#include <Conceptinetics.h>

//
// CTC-DRA-13-1 ISOLATED DMX-RDM SHIELD JUMPER INSTRUCTIONS
//
// If you are using the above mentioned shield you should 
// place the RXEN jumper towards G (Ground), This will turn
// the shield into read mode without using up an IO pin
//
// The !EN Jumper should be either placed in the G (GROUND) 
// position to enable the shield circuitry 
//   OR
// if one of the pins is selected the selected pin should be
// set to OUTPUT mode and set to LOGIC LOW in order for the 
// shield to work
//

//
// The slave device will use a block of 10 channels counting from
// its start address.
//
// If the start address is for example 56, then the channels kept
// by the dmx_slave object is channel 56-66
//
#define DMX_SLAVE_CHANNELS   10 

//
// Pin number to change read or write mode on the shield
// Uncomment the following line if you choose to control 
// read and write via a pin
//
// On the CTC-DRA-13-1 shield this will always be pin 2,
// if you are using other shields you should look it up 
// yourself
//
///// #define RXEN_PIN                2


// Configure a DMX slave controller
DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS );

// If you are using an IO pin to control the shields RXEN
// the use the following line instead
///// DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS , RXEN_PIN );

const int ledPin = 13;

// the setup routine runs once when you press reset:
void setup() {             
  
  // Enable DMX slave interface and start recording
  // DMX data
  dmx_slave.enable ();  
  
  // Set start address to 1, this is also the default setting
  // You can change this address at any time during the program
  dmx_slave.setStartAddress (1);
  
  // Set led pin as output pin
  pinMode ( ledPin, OUTPUT );
}

// the loop routine runs over and over again forever:
void loop() 
{
  //
  // EXAMPLE DESCRIPTION
  //
  // If the first channel comes above 50% the led will switch on
  // and below 50% the led will be turned off
  
  // NOTE:
  // getChannelValue is relative to the configured startaddress
  if ( dmx_slave.getChannelValue (1) > 127 )
    digitalWrite ( ledPin, HIGH );
  else
    digitalWrite ( ledPin, LOW );
    
  
}

what if master device powered after Arduino?

Post an annotated schematic showing how this is put together. Be sure to show all power, ground and power sources.

That seems to work! So, anytime I use this, I just have to make sure the master device/DMX controller starts after the slave device.

That's definitely something I could live with. But is there any way around that? I can't think of anything I could do in the sketch that would force the master to turn off and on again.

There is no schematic. It's just the shield attached to the Uno lighting up the on-board led. I have my DMX controller (PC running Freestyle) plugged into the DMX input on the shield. That's all there is to this.

i suppose the master serial buffer is overflow and stuck before slave is started

how about 120Ω resistor?

Is there any way to clear it?

Where? For this example sketch, it's just lighting the onboard led. I could try it with an external LED. Would adding a resistor help with the power cycling issue?

reset master? force to wait until send buffer is empty before send next command ? idk

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.