Hello, I had recently found online, simple code for an 8 channel dmx relay setup created by wavestorm systems for Nano. However, their website is no longer active, and I did not get a chance to copy the code. I was hoping someone had saved it and can pass it on. Appreciate the help. Thanks. www.wavestormsystems.com, the URL that is no longer active. Quite frustrating as the site was online 4 days ago, in retrospect, I should have copied the code then.
Hello...
I would really like to request help on some simple coding. I have programmed PLC's using ladder logic for years, but I have no coding experience. After a couple days of research and initial learning, I can see there is a lot to learn even for a simple application, in regards to coding. So, honestly, I was hoping someone here could or would help me out with a simple sketch.
I have not been able to find anything online that I can just copy and paste. Most projects similar to what I need are far more complex than I need. This is the best example I have found so far, and I believe this is quite close to what I need. Arduino Playground - Ardmx
I will use Arduino Nano and MAX485 module. 3 relays connected to any output pins (the only function of the Arduino will be for these 3 dmx relays, so all resources are available). The DMX address will be defined in the code, I do not need an external device to change/set the DMX address, nor do I need an external display for the preset DMX address.
I am quite capable of the hardware setup, connection, wiring, etc..., I just need some help with the coding. I have attached a image of the general hardware setup I found online. Thanks in advance. Any help is much appreciated...
I actually found a simple, pre coded script online, for 8 DMX relay output, coded for Nano, unfortunately, I only bookmarked the webpage, I did not copy the code. The website has gone down as of yesterday. Quite frustrating knowing I did not copy the code, but who would image the site would disappear just when I needed it...
I would suggest using a DMX library as it makes the code you need to write a lot easier. There are several different libraries available but I can maybe suggest this one as I have used it before and it worked well. When you download the library you will find one of its examples called DmxSerialRecv is almost exactly what you want apart from it using analogWrite where you would use digitalWrite instead for relays.
EDIT:
Please don't cross post.
Topics moved to a common forum section and merged
Thank you very much Riva! As you suggested, looks like exactly what I need. I will do some testing in a couple days and follow up if all goes well. Cheers and thanks again.
Hello Again,
I have run some tests. I have set up the DmxSerialRecv example, connecting individual led's to pin 5, 6 and 9. I have been able to verify that the presets set in the example sketch function correctly, as I can change values of the default values and the "set some default values". If I change these values and re-upload the sketch, I get expected results. I also have the correct result when no dmx packet has been received for 5 seconds.
I do not understand where to set an individual DMX address in the sketch. From Freestyler DMX software, I am sending out a dmx signal, and I am receiving it at my Nano, and the values of pins 5, 6, and 9 do change, but they do not change as I would expect them to. The led's are just randomly changing intensity across all 3 led's, it also seems to make no difference which dmx address I send from Freestyler, as long as the Nano sees a packet coming in, it adjusts the pwm values. Slowly driving one dmx address from 0 to 255 and back again does not create a dim to bright and back to dim again, the led's flicker, switch on and off, change intensity, and doing this several times does not produce the same result each time.
Thanks in advance for any advice or help. Cheers.
We cannot see the code that you are referring to
// - - - - -
// DmxSerial - A hardware supported interface to DMX.
// DmxSerialRecv.ino: Sample DMX application for retrieving 3 DMX values:
// address 1 (red) -> PWM Port 9
// address 2 (green) -> PWM Port 6
// address 3 (blue) -> PWM Port 5
//
// Copyright (c) 2011-2015 by Matthias Hertel, http://www.mathertel.de
// This work is licensed under a BSD style license. See Software License Agreement (BSD License)
//
// Documentation and samples are available at Arduino Projects
// 25.07.2011 creation of the DmxSerial library.
// 10.09.2011 fully control the serial hardware register
// without using the Arduino Serial (HardwareSerial) class to avoid ISR implementation conflicts.
// 01.12.2011 include file and extension changed to work with the Arduino 1.0 environment
// 28.12.2011 changed to channels 1..3 (RGB) for compatibility with the DmxSerialSend sample.
// 10.05.2012 added some lines to loop to show how to fall back to a default color when no data was received since some time.
// - - - - -
#include <DMXSerial.h>
// Constants for demo program
const int RedPin = 9; // PWM output pin for Red Light.
const int GreenPin = 6; // PWM output pin for Green Light.
const int BluePin = 5; // PWM output pin for Blue Light.
#define RedDefaultLevel 100
#define GreenDefaultLevel 200
#define BlueDefaultLevel 255
void setup () {
DMXSerial.init(DMXReceiver);
// set some default values
DMXSerial.write(1, 80);
DMXSerial.write(2, 0);
DMXSerial.write(3, 0);
// enable pwm outputs
pinMode(RedPin, OUTPUT); // sets the digital pin as output
pinMode(GreenPin, OUTPUT);
pinMode(BluePin, OUTPUT);
}
void loop() {
// Calculate how long no data backet was received
unsigned long lastPacket = DMXSerial.noDataSince();
if (lastPacket < 5000) {
// read recent DMX values and set pwm levels
analogWrite(RedPin, DMXSerial.read(1));
analogWrite(GreenPin, DMXSerial.read(2));
analogWrite(BluePin, DMXSerial.read(3));
} else {
// Show pure red color, when no data was received since 5 seconds or more.
analogWrite(RedPin, RedDefaultLevel);
analogWrite(GreenPin, GreenDefaultLevel);
analogWrite(BluePin, BlueDefaultLevel);
} // if
}
// End.
The DMX read addresses are 1, 2 & 3 (DMXSerial.read(dmxAddress) as seen in the example code you posted.
As I had mentioned in reply #2 for relays you will need to change analogWrite to digitalWrite as relays will chatter and maybe burn out with analogWrite.
digitalWrite (RedPin, DMXSerial.read(1));
digitalWrite (GreenPin, DMXSerial.read(2));
digitalWrite (BluePin, DMXSerial.read(3));
Thanks for your reply. Yes, understand exactly what you are saying. I have not yet tried to use relays. I wanted to make sure the example code and hardware worked as it should before moving on to relays. So, with the led's connected to the pwm outputs, using a 220 ohm resistor, regardless of what address I trigger in dmx, I am getting all sorts of output from the analog pins to the led's. I sent dmx signal to address' 1, 2 and 3, then to 100, 101, and 102, and then to 7, 8, and 9. regardless of what dmx address I was trying to trigger from Freestyler, I always saw changes to the led's. If I was not changing the dmx signal, then after 5 seconds the led's would go back to their default settings properly. I also tried to change the DMXSerialRead numbers from 1, 2 and 3 to 7, 8 and 9, and triggered both sets of addresses individually from Freestyler, but again, regardless of what I am outputting from Freestyler, anytime there is data being sent via dmx, it causes output on the pwm pins.
I'm not familiar with Freestyler but the first question is what DMX interface are you using with it to create the DMX signals.
Unless the library has been broken in later revisions since about 3 years ago, I used it to build some Wireless DMX transceivers for work and it performed very well.
One Arduino in DMX read mode to read signals from a lighting desk (ETC Expression) and wirelessly transmit the universe to several Arduino in DMX write mode to control fixtures.
I also used it to make a DMX Tester that performed well though it is using DMX write.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.