Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

DMX512 on a Industrial Shields' PLC Arduino

Industrial Shields' Library

Introduction

On this post, we are going to work with lights using the DMX512 Industrial Shields Library. With this library, we can work easily with the DMX protocol and work up to 512 different channels.

The DMX512  (Known as DMX) protocol is used in professional lightning systems and smoke or special effects machines.

Thanks to this communication, we can send to each of the 512 addresses a number between 0 and 255. Using this control, and knowing that some system could have more than one address, we can work with a wide range of systems.

Previous reading

We recommend you to read the following blogs in order to understand the program of this blog. We used the following blog posts in order to do this example:

Requeriments

In order to work with a DMX512 protocol, you will need the next following things:

Connecting the DMX512 decoder to the industrial controller Arduino

The first thing we must do is connecting the RS485 bus to the  decoder. We must keep in mind to put in the correct position the RS485 switch:

DMX512 decoder with Industrial Arduino controller

 Once the Programmable Logic Controller is correctly configured, we must connect the pins to the DMX encoder:

Industrial Arduino controller

Remember to configure each DMX encoder with the correct address. Usually there is a switch in the decoder. This configuration will be important because with that we will be able to set the address range will have this encoder:

DMX Encoder Industrial Arduino PLC

Software

The first thing we must do is including the Arduino library that includes the DMX512 functions:

#include <DMX512.h>

Remember to initialize the DMX library:

DMX512.begin();

Before sending anything through this library, we will need to ask if the bus is free. The next function returns TRUE if the bus is idle. FALSE if is still working:

DMX512.idle();

Finally, with the next function we will be able to send information to the DMX addresses. Keep in mind this function need a pointer to a variable uint8_t with the power level (channels), and a variable const uint16_t with the number of total channels (numChannels):

DMX512.write(channels, numChannels);

Example

The example below sends information to the DMX addresses 1, 2 and 3. If we put a DMX encoder working with these addresses, we will see a light blinking slowly:

// DMX512 library example
// by Industrial Shields

// Include the DMX512 library #include <DMX512.h>
// Define the variables for work with the addresses uint8_t channels[] = {0, 80, 160}; const uint16_t numChannels = sizeof(channels) / sizeof(uint8_t); // Setup function void setup()
{
    DMX512.begin(); } // Loop function void loop()
{
    // Ask if the DMX bus is busy
    if (DMX512.idle())
    {         // Wait some time between commands         delay(100);     // Update channels brightness     for (uint16_t i = 0; i < numChannels; ++i)
        {
            // Increase the power value of the channels
            channels[i] += 5;
        } // Update channels DMX512.write(channels, numChannels); } }


Do you want more information?

Open Source technology allows you to develop your installations.

Just fill the form and we will contact you as soon as we can.

Send