Good evening all,
Very new to Arduino, so any help you can offer is greatly appreciated.
I currently have:
- 1x 12v 2.5A PSU which is split to power:
- 2x UNOs
- 2x 8-Pack Relays
- 1x DMX Shield
I currently have the DMX Shield on one UNO controlling one 8-Pack Relay (D5-D12); I was wondering if it was possible to use that same DMX Shield with the other UNO/Relay as well; I've found many posts about using multiple shields with a single Arduino board, but I couldn't find any that reference the other way around.
Below is the code I am using on the first UNO; of course the DMX-ADDRESS on the second UNO will be 9 (so as not to overlap with the first UNO):
#include <Conceptinetics.h>
#define DMX_ADDRESS 1
#define NUM_OF_RELAYS 8
#define FIRST_RELAY_OUTPUT 5
#define SWITCHING_THRESHOLD 127
DMX_Slave dmx_slave(NUM_OF_RELAYS);
const int lastRelayOutput = FIRST_RELAY_OUTPUT + (NUM_OF_RELAYS - 1);
void setup() {
dmx_slave.enable();
dmx_slave.setStartAddress(DMX_ADDRESS);
for (int i = FIRST_RELAY_OUTPUT; i <= lastRelayOutput; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, HIGH);
}
}
void loop() {
int currentChannel = 1;
for (int currentOutput = lastRelayOutput; currentOutput >= FIRST_RELAY_OUTPUT; currentOutput--) {
if (dmx_slave.getChannelValue(currentChannel) > SWITCHING_THRESHOLD) {
digitalWrite(currentOutput, LOW);
} else {
digitalWrite(currentOutput, HIGH);
}
currentChannel++;
delay(10);
}
}
Again, any assistance is greatly appreciated.
Sincere regards,
Ryan
You want 2 different controllers operating the same shield and the same set of 8 relays?
What is supposed to happend if one controller orders Off to a relay and the other controller orders On?
Hi @Railroader,
No, each UNO has a separate 8-Pack Relay:
UNO 1 will respond to DMX Address' 1-8 and switch on the corresponding relay on Relay-Pack 1.
UNO 2 will respond to DMX Address' 9-16 and switch on the corresponding relay on Relay-Pack 2.
The programming dictates what address the relay will respond to so there should never be a conflict.
To confirm, the DMX Shield is used as a trigger, the relays being the result.
Sincere regards,
Ryan
Can You post a link to that DMX shield.?
Why not use 2 shields and get rid of the question?
How do You intend to connect a total of 16 relays to the 8 outputs of the shield?
What is the project supposed to do?
Hi @Railroaded,
There are 2 UNOs, 1 will run the 1st 8, the other will run the 2nd 8.
The project is a DMX Controlled 16-Pack Relay.
The Shield I am using is https://core-electronics.com.au/dmx-shield.html
I only want it to have the 1 DMX Input, hence why I am trying to use the 1 shield for both.
Sincere regards,
Ryan
I suggest that you use an I2C port expander to increase the output pins available instead of a second Uno. A MCP23008 has 8 bidirectional GPIO pins. A MCP23017 has 16 bidirectional GPIO pins. That would be much easier to program and would only use 2 pins (A4 and A5) to get 8 or 16 (or up to 128) extra pins.
Okey. The DMX handes 16 relays, not 8.
The following settings are configurable via the onboard jumpers:
Send data via TX or Digital pin 4
Receive data via RX or Digital pin 3
Hardware slave mode or Software Controlled Slave/Master via Digital pin 2 (Required for RDM)
Enable / Disable shield
Both Tx and digital pin 4 will be nailed by the Arduino hosting the shield.
I can't find out how "slave mode" works. Suppose Arduino 1 sets pin 2 to slave. How can Arduino 2 access the device then?
The natural advice is to drop the idea and buy a second shield. I don't find it motivated to plow down into this to achieve "not much".
Does the shield have anything to do with pins other than 3 and 4? I don't see a schematic.
If not, why not drive 8 relays from 2,5,6,7,8,9,10,11, and then 12,13,14,15,16,17,18,19 for the other 8?
Ah, I see 2 is used as a selector kind of pin.
Do you need SPDT relay contacts (NC-C-NO), or just SPST (C-NO) that closes when energized?
If you hadn't bought relay boards already, I would have suggested relay boards with a shift register so that just 3 pins can control multiple groups of 8 relays.
In action (Mega shield version)
3 daisy chained boards (didn't send out 3 unique bytes, so indicator lights all show the same)
Thank you @Railroader and @groundFungus for your suggestions.
I ended up just ppiggybacking off the RX port and both with perfectly.
Thank you @CrossRoads, I didn't know I could use an analog output as a digital one; this would mean I wouldn't need to use my second UNO!
All pins on the Uno & 328P boards are digital pins.
Some have 2nd functions:
PWM
SPI
I2C
Analog Inputs.
There are no analog outputs; PWM can be made to act like analog output with an RC lowpass filter. Can do software PWM with micros() or millis() for timing and achieve the same. Here are 13 outputs with a '1284P (only 8 are played in the demo, I ran out of buttons):
Thanks @CrossRoads, I now have both Relays running through the one UNO.
For anyone trying to do something similar I created two Arrays, one for the output pins, and one for the corresponding DMX Address, and used these in a for loop.
If you need further expansion to another Arduino you can run a jumper out of the RX Port on the Shield and into the RX Port on the second Arduino.