Skip to content

Commit 5721215

Browse files
Merge pull request #5 from apdlv72/i2s_documentation
I2s documentation
2 parents 3464f22 + 6e5079a commit 5721215

File tree

4 files changed

+75
-69
lines changed

4 files changed

+75
-69
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,47 @@ Wherever there is activity on the web interface (configuration, monitoring), the
88

99
See http://robertoostenveld.nl/art-net-to-dmx512-with-esp8266/ for more details and photos, and https://robertoostenveld.nl/timing-and-jitter-in-dmx512-signals/ for a detailled look at the timing of the DMX signals.
1010

11+
# Operating modes
12+
13+
## UART
14+
15+
DMX is a serial protocol and - except for different voltage levels - very similar to RS232. Therefore it is obvious to use the built-in UART (Universal Asynchronous Receiver/Transmitter)
16+
of the micro controller to send the DMX frames. This is the original way this sketch used to work and expects the max485 level shifter to be connected to the pin that corresponds to Serial1.
17+
On a Wemos D1 this is pin D4 aka TX1. In order to use UART mode, comment in the ENABLE_UART definition.
18+
19+
## I2S
20+
21+
However, the built-in UART provides only very limited control over e.g. number of stop bits, breaks etc. That may become a problem when you want to control devices with kind of "sloppy" firmware. When trying to control two cheap, china made moving heads, I found that they somehow reacted to the signal but showed lots of jitter and random moves, random color changes and so on.
22+
When connected to a commercial, manual DMX512 control panel, they worked flawlessly. An analysis with an oscilloscope showed a significant difference between the signal and the offical DMX
23+
standard, most obviously in the number of stop bits. The DMX standard defines 2 stop bits whereas the commercial panel sent approx. 11 bits.
24+
It seems like the manufacturers of such panels are aware of the fact that there are devices which apparently need more time between two DMX channel values to process the data received.
25+
26+
Because the buil-in UART does not allow to send more than 2 stop bits, the I2S mode (https://en.wikipedia.org/wiki/I%C2%B2S) has been implemented that supports very fine-grained control over
27+
the timing of every single bit. Unfortunately, the I2S data output pin is hardwired to GPIO3 (=RX0) on an ESP8266 which means that the max485 level shifter needs to be attached to this pin.
28+
Using a double throw switch allows to switch between those two pins as depicted in the wiring schematic below.
29+
30+
*Warning*: When uploading your this sketch to your ESP8266, make sure to disconnect any fixtures from the XLR connector because this means sending data to RX0 and will cause your
31+
fixtures to do random things. This might not be a big problem with simple lamps but might cause damage when using motion devices.
32+
33+
You can just as well use two max485 circuits and wire one to TX1/D4 and the second one to RX0 and comment in both modes (ENABLE_UART and ENABLE_I2S).
34+
35+
Because of the number of extra stop bits, I2S mode will cause the throughput to drop from 40 frames/second to approx. 30 f/s which still should be acceptable under normal circumstances.
36+
37+
For I2S mode, there is another conditional define (I2S_SUPER_SAFE) which not only adds extra stop bits but also extends the MBB (mark before break) and SFB (space before break)
38+
to the values observed with the oscilloscope. Try this if you encounter problems with a fixture although you are already using I2S mode.
39+
40+
41+
## Standalone mode
42+
43+
Normally you would configure your Art-Net device to connect to your local WiFi after you uploaded this sketch (_and_ the static content! - see notes below).
44+
To do so, you will connect to the AP (access point) network the ESP8266 creates after booting for the first time.
45+
But there might be circumstances where you do not have access to a local WiFi network, for instance an outdoor garten pary.
46+
This is what the standalone mode is for. In standalone mode the sketch will not wait until a local WiFi connection was established but will start to listen for Art-Net packets
47+
right away on the AP network. You can then connect to this network, ignore/minimize the WiFi setup dialog and send your Art-Net packets to the corresponding network interface.
48+
49+
Consider setting also a password in standalone mode, otherwise someone else might configure your device to connect to a random Wifi.
50+
51+
1152
# Components
1253

1354
- Wemos D1 mini
@@ -18,6 +59,11 @@ See http://robertoostenveld.nl/art-net-to-dmx512-with-esp8266/ for more details
1859
- 3 or 5 pin female XLR connector
1960
- panel mount 2.1 x 5.5 mm DC barrel jack
2061
- 82 x 58 x 34 mm ABS enclosure box
62+
63+
Optional for I2S mode:
64+
65+
- an SPDT (single pole double throw) switch OR
66+
- an extra MAX485 module and XLR connector
2167

2268
# Wiring scheme
2369

esp8266_artnet_dmx512.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
// Uncomment to send DMX data using the microcontroller's builtin UART.
3434
// This is the original way this sketch used to work and expects the max485 level
35-
// shifter to be connected to the pin that corresondents to Serial1.
36-
// On a Wemos D1 this is pin D4 aka RX1.
35+
// shifter to be connected to the pin that corresponds to Serial1.
36+
// On a Wemos D1 this is pin D4 aka TX1.
3737
#define ENABLE_UART
3838

3939
// Uncomment to send DMX data via I2S instead of UART.

rgb_led.cpp

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,51 @@ void ledInit() {
77
}
88

99
#ifdef COMMON_ANODE
10+
#define LED_ON LOW
11+
#define LED_OFF HIGH
12+
#else
13+
#define LED_ON HIGH
14+
#define LED_OFF LOW
15+
#endif
1016

1117
void ledRed() {
12-
digitalWrite(LED_R, LOW);
13-
digitalWrite(LED_G, HIGH);
14-
digitalWrite(LED_B, HIGH);
15-
}
16-
17-
void ledGreen() {
18-
digitalWrite(LED_R, HIGH);
19-
digitalWrite(LED_G, LOW);
20-
digitalWrite(LED_B, HIGH);
21-
}
22-
23-
void ledBlue() {
24-
digitalWrite(LED_R, HIGH);
25-
digitalWrite(LED_G, HIGH);
26-
digitalWrite(LED_B, LOW);
27-
}
28-
29-
void ledYellow() {
30-
digitalWrite(LED_R, LOW);
31-
digitalWrite(LED_G, LOW);
32-
digitalWrite(LED_B, HIGH);
33-
}
34-
35-
void ledMagenta() {
36-
digitalWrite(LED_R, LOW);
37-
digitalWrite(LED_G, HIGH);
38-
digitalWrite(LED_B, LOW);
39-
}
40-
41-
void ledCyan() {
42-
digitalWrite(LED_R, HIGH);
43-
digitalWrite(LED_G, LOW);
44-
digitalWrite(LED_B, LOW);
45-
}
46-
47-
void ledBlack() {
48-
digitalWrite(LED_R, HIGH);
49-
digitalWrite(LED_G, HIGH);
50-
digitalWrite(LED_B, HIGH);
51-
}
52-
53-
#else
54-
55-
void ledRed() {
56-
digitalWrite(LED_R, HIGH);
57-
digitalWrite(LED_G, LOW);
58-
digitalWrite(LED_B, LOW);
18+
digitalWrite(LED_R, LED_ON);
19+
digitalWrite(LED_G, LED_OFF);
20+
digitalWrite(LED_B, LED_OFF);
5921
}
6022

6123
void ledGreen() {
62-
digitalWrite(LED_R, LOW);
63-
digitalWrite(LED_G, HIGH);
64-
digitalWrite(LED_B, LOW);
24+
digitalWrite(LED_R, LED_OFF);
25+
digitalWrite(LED_G, LED_ON);
26+
digitalWrite(LED_B, LED_OFF);
6527
}
6628

6729
void ledBlue() {
68-
digitalWrite(LED_R, LOW);
69-
digitalWrite(LED_G, LOW);
70-
digitalWrite(LED_B, HIGH);
30+
digitalWrite(LED_R, LED_OFF);
31+
digitalWrite(LED_G, LED_OFF);
32+
digitalWrite(LED_B, LED_ON);
7133
}
7234

7335
void ledYellow() {
74-
digitalWrite(LED_R, HIGH);
75-
digitalWrite(LED_G, HIGH);
76-
digitalWrite(LED_B, LOW);
36+
digitalWrite(LED_R, LED_ON);
37+
digitalWrite(LED_G, LED_ON);
38+
digitalWrite(LED_B, LED_OFF);
7739
}
7840

7941
void ledMagenta() {
80-
digitalWrite(LED_R, HIGH);
81-
digitalWrite(LED_G, LOW);
82-
digitalWrite(LED_B, HIGH);
42+
digitalWrite(LED_R, LED_ON);
43+
digitalWrite(LED_G, LED_OFF);
44+
digitalWrite(LED_B, LED_ON);
8345
}
8446

8547
void ledCyan() {
86-
digitalWrite(LED_R, LOW);
87-
digitalWrite(LED_G, HIGH);
88-
digitalWrite(LED_B, HIGH);
48+
digitalWrite(LED_R, LED_OFF);
49+
digitalWrite(LED_G, LED_ON);
50+
digitalWrite(LED_B, LED_ON);
8951
}
9052

9153
void ledBlack() {
92-
digitalWrite(LED_R, LOW);
93-
digitalWrite(LED_G, LOW);
94-
digitalWrite(LED_B, LOW);
54+
digitalWrite(LED_R, LED_OFF);
55+
digitalWrite(LED_G, LED_OFF);
56+
digitalWrite(LED_B, LED_OFF);
9557
}
96-
97-
#endif

schematic.png

-31.8 KB
Loading

0 commit comments

Comments
 (0)