├── Makefile ├── README.md └── DmxUsbProArduino.ino /Makefile: -------------------------------------------------------------------------------- 1 | #ARDUINO_DIR = /usr/share/arduino 2 | #ARDMK_DIR = /usr 3 | #AVR_TOOLS_DIR = /usr 4 | BOARD_TAG = uno 5 | MONITOR_PORT = /dev/ttyACM* 6 | #ARDUINO_LIBS = /usr/share/arduino/libraries 7 | ARDUINO_LIBS = DmxMaster 8 | include /usr/share/arduino/Arduino.mk 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | This is a firmware for arduino + dmx shield. 4 | 5 | It makes the arduino compatible with programs that use the Enttec Dmx Usb Pro protocol. 6 | 7 | It uses the [SimpleDmx library](http://code.google.com/p/tinkerit/wiki/DmxSimple). 8 | 9 | This has been successfully tested with [SK Pang's Arduino DMX Shield](http://www.skpang.co.uk/catalog/arduino-dmx-shield-p-663.html), and should work with all mentioned by SimpleDmx. Make sure to change the TX pin according to your shield. 10 | 11 | This has been sucessfully tested with the following software: [ofxDmx](https://github.com/kylemcdonald/ofxDmx), [pySimpleDmx](https://github.com/c0z3n/pySimpleDMX). And should work with others. 12 | 13 | The implementation lacks some checking for bad packets for now. You're welcome to help! 14 | 15 | 16 | # Installation 17 | 18 | ``` 19 | sudo apt-get install arduino-mk 20 | sudo usermod -aG dialout $(whoami) 21 | ``` 22 | 23 | Restart your session for the changes on groups to take effect. 24 | Or `su - $USER` 25 | 26 | ``` 27 | git clone https://github.com/TinkerKit/DmxMaster 28 | sudo cp -r DmxMaster /usr/share/arduino/libraries/ 29 | git clone git@github.com:emmanuelgeoffray/DmxUsbProArduino.git 30 | cd DmxUsbProArduino 31 | make 32 | make upload 33 | ``` 34 | 35 | -------------------------------------------------------------------------------- /DmxUsbProArduino.ino: -------------------------------------------------------------------------------- 1 | /*============================================================================== 2 | 3 | Copyright (c) 2013 Soixante circuits 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | ==============================================================================*/ 23 | 24 | #include 25 | 26 | #define DMX_PRO_HEADER_SIZE 4 27 | #define DMX_PRO_START_MSG 0x7E 28 | #define DMX_START_CODE 0 29 | #define DMX_START_CODE_SIZE 1 30 | #define DMX_PRO_SEND_PACKET 6 // "periodically send a DMX packet" mode 31 | #define DMX_PRO_END_SIZE 1 32 | #define DMX_PRO_END_MSG 0xE7 33 | #define DMX_PRO_SEND_SIZE_LSB 10 34 | #define DMX_PRO_SEND_SIZE_MSB 11 35 | unsigned char state; 36 | unsigned int dataSize; 37 | unsigned int channel; 38 | 39 | void setup() { 40 | Serial.begin(57600); 41 | // change the TX pin according to the DMX shield you're using 42 | DmxMaster.usePin(2); 43 | state = DMX_PRO_END_MSG; 44 | } 45 | 46 | 47 | void loop() { 48 | unsigned char c; 49 | 50 | while(!Serial.available()); 51 | c = Serial.read(); 52 | if (c == DMX_PRO_START_MSG && state == DMX_PRO_END_MSG){ 53 | state = c; 54 | } 55 | else if (c == DMX_PRO_SEND_PACKET && state == DMX_PRO_START_MSG){ 56 | state = c; 57 | } 58 | else if (state == DMX_PRO_SEND_PACKET ){ 59 | dataSize = c & 0xff; 60 | state = DMX_PRO_SEND_SIZE_LSB; 61 | } 62 | else if (state == DMX_PRO_SEND_SIZE_LSB){ 63 | dataSize += (c << 8) & 0xff00; 64 | state = DMX_PRO_SEND_SIZE_MSB; 65 | } 66 | else if ( c == DMX_START_CODE && state == DMX_PRO_SEND_SIZE_MSB){ 67 | state = c; 68 | channel=1; 69 | } 70 | else if ( state == DMX_START_CODE && channel < dataSize){ 71 | DmxMaster.write(channel, c); 72 | channel++; 73 | } 74 | else if ( state == DMX_START_CODE && channel == dataSize && c == DMX_PRO_END_MSG){ 75 | state = c; 76 | } 77 | } 78 | --------------------------------------------------------------------------------