$USD
  • EUR€
  • £GBP
  • $USD
PROJECTS Arduino

DMXino Handheld Tester

DFRobot Sep 13 2018 1165

*Created by KevinMcArthur

DMX512 tester display / receive or transmit the level of 1 of 512 DMX control channels.



Things used in this project

Hardware components

Arduino UNO & Genuino UNO×1

DFRobot Conceptinetics DMX Shield×1

DFRobot Hitachi 16 * 2 LCD Display Shield×1

DFRobot Screw Terminal Shield (pair)×1

Software apps and online services

MA Lighting onPC Software

Conceptinetics.h DMX library

Hand tools and fabrication machines

MA Lighting 2 port Node

MA Lighting GMA1 onPC Software

Cable, DMX 5M/3F XLR, Shielded

Cable, DMX 5F/3M XLR, Shielded



Story


DMX512 has proven a rugged, reliable serial data interface specification for two decades now. Adopted as a standard in the entertainment lighting industry, it is often the best and most convenient way to control OEM equipment.

Having a small handheld tester is crucial to troubleshooting any system.

This collection of shields and associated code provide the basis for a simple tester. The "Select" button toggles between the Transmit and Recieve modes of operation. The "UP" and "DOWN" buttons provide scrolling channel selection, while the "LEFT" and "RIGHT" keys provide adjustment of the selected channels intensity.

In some of the documentation, the 4 Relay Shield is shown, preparation for a future project.






Schematics




Code


 /*
 *******************************************************************************
    DMXino DMX512 Transmitter / Reciever
 ***************************************************************************** */

// set Variables used throughout program:

const int ledPin =  13; //non dim indicator of current channel status

// Variables that will change:

int dimmer_val;         //Value to be output in Transmit Mode
int CHNumber = 1;       //channel number in either mode
float  ChannelValuePER; //recieved channel value percent
int ChannelValuePERint; //recieved channel value percent integer
int TesterMode = 1;     // Mode Flag (Transmit/Recieve)`

#include 

// Select the pin used on LCD

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define the buttons;

int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5

//read the button value
int read_LCD_buttons()
{
  adc_key_in = analogRead(0);          // read analog A0 value
  // when read the 5 key values in the vicinity of the following0,144,329,504,741
  // By setting different threshold, you can read the one button

  if (adc_key_in < 50)   return btnRIGHT;
  if (adc_key_in < 250)  return btnUP;
  if (adc_key_in < 450)  return btnDOWN;
  if (adc_key_in < 650)  return btnLEFT;
  if (adc_key_in < 850)  return btnSELECT;
  return btnNONE;
}
#include 

//
// 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
//

//
//
//
#define DMX_SLAVE_CHANNELS   512
#define DMX_MASTER_CHANNELS  512
//
#define RXEN_PIN                2

//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 );

// Configure a DMX master controller, the master controller
// will use the RXEN_PIN to control its write operation
// on the bus
DMX_Master        dmx_master ( DMX_MASTER_CHANNELS, RXEN_PIN );




void setup()
{
   // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  
  // Enable DMX slave interface and start recording
  // DMX data


  // Set start address, this is also the default setting
  // You can change this address at any time during the program
  dmx_slave.setStartAddress (CHNumber);
  dmx_master.setChannelRange ( 1, 512, 00 );

  lcd.begin(16, 2);           //This routine initializes the display,
  lcd.setCursor(0, 0);        //
  lcd.print("DMXino TESTER");
  lcd.setCursor(0, 1);
  lcd.print("DMX512");
  delay(1000);
  // scroll 16 positions (string length) to the left
  // to move it offscreen left:
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayRight();
    // wait a bit:
    delay(30);

  }
  lcd.begin(16, 2);     //Start in recieve mode
  RecieveMode();
}


void loop()
{

  if (TesterMode == 1)
  {
    RecieveMode();
  }
  if (TesterMode == 0)
  {
    TransmitMode();
  }
  // ************LCD BUTTON INPUT************


  lcd_key = read_LCD_buttons();  // read key

  switch (lcd_key)               // display key
  {
    case btnRIGHT:
      {
        lcd.setCursor(13, 1);
        lcd.print("   " );
        dimmer_val++;
        delay (200);
        break;
      }
    case btnLEFT:
      {
        lcd.setCursor(13, 1);
        lcd.print("   " );
        dimmer_val--;
        delay (200);
        break;
      }
    case btnUP:
      {
        if   (CHNumber  < 512)
        {
          lcd.setCursor(5, 1);
          lcd.print("   " );
          CHNumber++;
        }
        delay (200);
        break;
      }
    case btnDOWN:
      {
        if   (CHNumber   > 1)
        {
          lcd.setCursor(5, 1);
          lcd.print("   " );
          CHNumber--;
        }
        delay (200);
        break;
      }

    case btnSELECT:
      {
        lcd.begin(16, 2);
        lcd.setCursor(0, 0);
        lcd.print(" TESTER MODE");
        delay (200);
        TesterMode = !TesterMode;

        break;
      }
    case btnNONE:
      {
        lcd.print("       ");
        break;
      }

  }
  // EXAMPLE DESCRIPTION
  //
  // If the selected 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 (CHNumber) > 127 )
    digitalWrite ( ledPin, HIGH );
  else
    digitalWrite ( ledPin, LOW );
}

void RecieveMode()
{
  dmx_slave.enable ();
  lcd.setCursor(0, 0);
  lcd.print("DMXino Recieve");
  lcd.setCursor(0, 1);
  lcd.print("CHAN#");
  lcd.setCursor(9, 1);
  lcd.print("LVL");
  lcd.setCursor(5, 1);
  lcd.print(CHNumber );
  lcd.setCursor(13, 1);
  //lcd.print ( dmx_slave.getChannelValue(CHNumber));
  ChannelValuePER = dmx_slave.getChannelValue(CHNumber) / 2.55;
  ChannelValuePERint = int( ChannelValuePER);
  lcd.print (ChannelValuePERint);

}

void TransmitMode()
{
  dmx_master.enable ();
  lcd.setCursor(0, 0);
  lcd.print("DMXino Transmit");
  lcd.setCursor(0, 1);
  lcd.print("CHAN#");
  lcd.setCursor(9, 1);
  lcd.print("LVL");

  lcd.setCursor(5, 1);
  lcd.print(CHNumber );
  lcd.setCursor(13, 1);
  lcd.print(dimmer_val);
  dmx_master.setChannelValue ( (CHNumber), dimmer_val );
}   
REVIEW