Transmit e1.31 from Arduino?

General discussion of other lighting topics with an emphasis on software topics not covered in the support/feedback category.
Post Reply
ezzet
Posts: 1
Joined: Sat Oct 11, 2014 9:43 am

Transmit e1.31 from Arduino?

Post by ezzet »

Hi, I found this fantastic arduino codes for receiveing e1.31
http://www.claudeheintzdesign.com/lx/lxarduino.html

Could someone guide me in right directions how to send e1.31 package from arduino? I would like to convert rs232 commands to e1.31

Many thanks
admin
Site Admin
Posts: 1643
Joined: Mon Nov 05, 2007 1:26 am
Contact:

Post by admin »

This a a fragment of code that should show you how to construct an sACN packet to send.

Code: Select all

#define DIMMERS_IN_UNIVERSE 512
#define SACN_MESSAGE_SIZE 638

void packInt16Big(unsigned char* c, int i) {
	c[0] = ((i & 0xff00) >> 8);
	c[1] = i & 0xff;
}

unsigned char _messageout[SACN_MESSAGE_SIZE];	//dmx buffer  512 + max Header = 638 for 1 universe
int acnPriority = 100;
int packetSequenceNumber = 0;					//this should ++ 0-255 for each packet sent
int outsubnet = 0;
int outuniverse = 1;

int i;
for &#40;i=0; i<126; i++&#41; &#123;
	mbytes&#91;i&#93; = 0x00;	//zero up until mbytes&#91;125&#93; the start code before dmx slots
&#125;
//Root Layer
	mbytes&#91;1&#93; = 0x10;		//mbytes&#91;0&#93; & mbytes&#91;1&#93; are preamble size mbytes&#91;0&#93; is always 0 as set above
	mbytes&#91;4&#93; = 'A';	//0x41;
	mbytes&#91;5&#93; = 'S';	//0x53;
	mbytes&#91;6&#93; = 'C';	//0x43;
	mbytes&#91;7&#93; = '-';	//0x2d;
	mbytes&#91;8&#93; = 'E';	//0x45;
	mbytes&#91;9&#93; = '1';	//0x31;
	mbytes&#91;10&#93; = '.';	//0x2e;
	mbytes&#91;11&#93; = '1';	//0x31;
	mbytes&#91;12&#93; = '7';	//0x37;	//the pad 0's &#91;13&#93;,&#91;14&#93;,&#91;15&#93; are already set
	int flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 110;
	packInt16Big&#40;&mbytes&#91;16&#93;, flagsPlusLength&#41;;
	mbytes&#91;21&#93; = 0x04;	//vector18,19,20=0x00
	mbytes&#91;22&#93; = 206;	//16byte UUID should be guaranteed unique for each instance
	mbytes&#91;23&#93; = 156;
	mbytes&#91;24&#93; = 55;
	mbytes&#91;25&#93; = 180;
	mbytes&#91;26&#93; = 9;
	mbytes&#91;27&#93; = 147;
	mbytes&#91;28&#93; = 67;
	mbytes&#91;29&#93; = 81;
	mbytes&#91;30&#93; = 165;
	mbytes&#91;31&#93; = 133;
	mbytes&#91;32&#93; = 170;
	mbytes&#91;33&#93; = 144;
	mbytes&#91;34&#93; = 121;
	mbytes&#91;35&#93; = 76;
	mbytes&#91;36&#93; = 9;
	mbytes&#91;37&#93; = 240;

//Framing Layer
	flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 88;
	packInt16Big&#40;&mbytes&#91;38&#93;, flagsPlusLength&#41;;
	mbytes&#91;43&#93; = 0x02;	//vector indicates framing wraps DMP
	mbytes&#91;44&#93; = 'm';
	mbytes&#91;45&#93; = 'y';
	mbytes&#91;46&#93; = 'C';
	mbytes&#91;47&#93; = 'o';
	mbytes&#91;48&#93; = 'n';
	mbytes&#91;49&#93; = 's';
	mbytes&#91;50&#93; = 'o';
	mbytes&#91;51&#93; = 'l';
	mbytes&#91;52&#93; = 'e';		//null terminated, padded until &#91;108&#93;
	mbytes&#91;108&#93; = acnPriority;	//priority &#40;&#91;109&#93;,&#91;110&#93; reserved=0&#41;
	mbytes&#91;111&#93; = packetSequenceNumber;
	mbytes&#91;113&#93; = outsubnet;
	mbytes&#91;114&#93; = outuniverse;
	
//DMP Layer
	flagsPlusLength = 0x7000 + DIMMERS_IN_UNIVERSE + 11;
	packInt16Big&#40;&mbytes&#91;115&#93;, flagsPlusLength&#41;;
	mbytes&#91;117&#93; = 0x02;	//indicates a DMP Set Property message
	mbytes&#91;118&#93; = 0xa1;	//type of data
	mbytes&#91;122&#93; = 0x01;	//address increment
	packInt16Big&#40;&mbytes&#91;123&#93;, DIMMERS_IN_UNIVERSE+1&#41;;  //+1 for start code
	mbytes&#91;125&#93; = 0x00;	//start code 

//DMX
	mbytes&#91;126&#93; to mbytes&#91;637&#93; are the individual DMX values 1-512
	
	
UDP.write&#40;mbytes, SACN_MESSAGE_SIZE&#41;;

Post Reply