' DMX transmitter for weenie and the MAX485 chip' this program is written for the arduino mega board' and the Conceptinetics DMX shield which is based on the' MAX485 signalling chip' see the setup specifics at the end of the code below#chip mega2560, 16#include <maths.h>'************************ COMM SETTINGS *******************************#define USART_BAUD_RATE 250000 ' Initializes USART port to 250000 baud#define USART_TX_BLOCKING ' wait for tx register to finish#define DMXout PORTE.1 ' Pin E.1, TX - out to MAX481 DMX driverdirDMXoutout' Set pin directionssetDMXouton' DMX MARK condition (DMX idle)#define DE PORTE.4 ' on the shield i'm using, this is fordirDEout' Pin E.4, MAX485 output enablesetDEon#define LED PORTB.7 ' Pin B.7 - LEDdirLEDoutsetLEDoffUCSR0C=0b00001111' Async, 8N2TXEN0=0' disable TX'************************ FUNCTION SETTINGS ***************************#define MaxChan 10dimDMXCHAN(MaxChan)' Create DMX arraydimxxasworddimyyasbyte'**************************** EXECUTION *****************************'****************************** SETUP *******************************ClrAll' Clear DMX array' load buffer with two valuesSendChan(1,6)' enable floodliteSendChan(4,255)' enable dumb control of colorsforxx=1to10' Blink "I'malive" LEDpulseoutLED,60mswait60msnextxx'***************************** RUN **********************************do' this routine sends a symetric sawtooth stream of values to' the green channel of a floodlite to make the green LEDs ' slowly fade up and downxx=xx+1direction=(xx/256)%2green=((xx%256)*direction)+(256-(xx%256))*(1-direction)SendChan(6,power((green/16),2))wait2msloop'************************ SUBS by MotoGeek ************************subSendChan(Chan,Value)' update single channelDMXCHAN(Chan)=ValueTransDMXendsubsubSendAll(Value)' update all channelsforxx=1toMaxChanDMXCHAN(xx)=ValuenextxxTransDMXendsubsubClrAll' clear all channelsforxx=1toMaxChanDMXCHAN(xx)=0nextxxTransDMXendsub'****************** TRANSMIT DMX Channels *************' this sub transmits (MaxChan) of the DMX arraysubTransDMXsetLEDon'Show DMX activity on LEDsetDMXoutoffwait100us'BREAKsetDMXoutonwait6us'MARK AFTER BREAK (MAB)TXEN0=1'enable TXHSerSend0'STARTCODE (always 0)'set DMXout on'wait 100 ms 'MarkTimeBetweenFrames(MTBF)'set DMXout offforyy=1toMaxChan'Channel 1 - (MaxChan)HSerSendDMXCHAN(yy)nextyyTXEN0=0' disable TXsetDMXouton'DMX MARK condition (DMX idle)setLEDoffendsub' SPECS' written on SynWrite 6.22.2290 on Windows 7 - 64' tested on the weenie mega 2560 r3' using a dmx shield, the Conceptinetics CTC-DRA-10-R2' the shield takes serial data on mega pins D0(rx), D1(tx), D2(enable)' which is serial0 on the atmega2560' the shield has an option to take rx and tx from pins D3 and D4' this routine sends dmx data to a cheap no-name LED floodlite' as seen here: https://www.youtube.com/watch?v=9wAr2UX-c5A' google: 8CH 12 LED color Par Light' all it does is continuously fade the green up and down' CREDITS' i took the code written by MotoGeek' (https://sourceforge.net/p/gcbasic/discussion/projects&guides/thread/899e5a0b/?page=0)' and modified it for the 2560' thanks to him, to Anobium and particularly to Mike' (https://sourceforge.net/u/mmotte/profile/) for thier assistance
here is a video of my program at work:

https://www.youtube.com/watch?v=VOzxqHe4tm8
using MotoGeek's code as seen here: https://sourceforge.net/p/gcbasic/discussion/projects%26guides/thread/899e5a0b/
and modified for the weenie Mega2560 board.
dmxing a LED floodlite
Last edit: louie 2018-04-29