Artnet to DMX

Dependencies:   mbed DMX TextLCD mbed-rtos

/media/uploads/Ayrton_L/dmx.png

Art-NET to DMX converter.

Read Art-NET and process the data so it can be send by 3 XLR3 outputs for DMX. With a 4x20 display you can choose some options. For example what universe you would like on what output.

This is a project we make as our final project of our 2nd year of university. We study Electronics-ICT / Embedded ICT.

We chose for this amazing platform (MBED LPC1768) because it has al the interfaces and pins we need.

Files at this revision

API Documentation at this revision

Comitter:
Ayrton_L
Date:
Mon May 23 14:26:36 2016 +0000
Parent:
34:fc85eeb84a93
Child:
36:dba7a0094213
Commit message:
latest stable

Changed in this revision

DMX.lib Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.lib Show diff for this revision Revisions of this file
Screen.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
--- a/DMX.lib	Thu May 19 14:27:07 2016 +0000
+++ b/DMX.lib	Mon May 23 14:26:36 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/Ayrton_L/code/DMX/#256845339155
+https://developer.mbed.org/users/Ayrton_L/code/DMX/#622a294f70ab
--- a/EthernetInterface.lib	Thu May 19 14:27:07 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#4d7bff17a592
--- a/Screen.h	Thu May 19 14:27:07 2016 +0000
+++ b/Screen.h	Mon May 23 14:26:36 2016 +0000
@@ -1,7 +1,7 @@
 #include "string.h"
 #include "stdint.h"
 #include "TextLCD.h"
-TextLCD lcd(p10, p12, p15, p16, p29, p30, TextLCD::LCD20x4);
+TextLCD lcd(p21, p26, p22, p23, p24, p25, TextLCD::LCD20x4);
 
 class Screen
 {
--- a/main.cpp	Thu May 19 14:27:07 2016 +0000
+++ b/main.cpp	Mon May 23 14:26:36 2016 +0000
@@ -1,10 +1,4 @@
-#include "main.h"
- 
-typedef struct 
-{
-    uint32_t Universe[2];   
-    uint8_t I8_Values[511];       
-}DMX_Data;
+#include "main.h"    
 
 void V_EnableRotary()
 {
@@ -14,43 +8,20 @@
 
 void V_InterruptMenu()
 {
-        Error2 = 1;
-        Error4 = 1;
+        //Error2 = 1;
+        //Error4 = 1;
         S.V_SetInterrupt(true); 
 }
-    
-void V_DMXThread1(void const *args)
-{
-    while(1)
-    {
-        XLR1.V_SendDMX();
-    }
-}
-
-void V_DMXThread2(void const *args)
-{
-    while(1)
-    {
-        XLR2.V_SendDMX();
-    }
-}
-
-void V_DMXThread3(void const *args)
-{
-    while(1)
-    {
-        XLR3.V_SendDMX();
-    }
-}
 
 int main() 
 {
-    //RightTwist.mode(PullUp);
-    //LeftTwist.mode(PullUp);
+    RightTwist.mode(PullUp);
+    LeftTwist.mode(PullUp);
     PushButton.rise(&V_InterruptMenu);                                                                      //interrupt bij push op button, rising edge
-    Thread T_DMX1(V_DMXThread1);
-    Thread T_DMX2(V_DMXThread2);
-    Thread T_DMX3(V_DMXThread3);
+    
+    XLR1.V_Start();
+    XLR2.V_Start();
+    XLR3.V_Start();
     
     char C_Buf[572];
     uint16_t I16_Universe;
@@ -59,10 +30,14 @@
         if(S.B_GetInterrupt() == false)
         {
             int size = eth.receive();   
-            if(size > 0) {
+            if(size > 0) 
+            {
+                Error2 = 1;
                 eth.read(C_Buf, size);
+                Error8 = 1;
                 if(C_Buf[34] == 0x19 and C_Buf[35] == 0x36 and C_Buf[36] == 0x19 and C_Buf[37] == 0x36)    //Poort checken (6465 = 0x1936 // deel van udp protocol
                 {
+                    Error1 = 1;
                     char C_ID[7];
                     memcpy(C_ID, &C_Buf[42], 7);
                     if(I32_CheckHeader(C_ID) == 0)                                                  //Art-Net Header checken
@@ -77,35 +52,46 @@
                                 I16_Universe = I16_Universe & 0xFF00;
                                 I16_Universe = I16_Universe + C_Buf[57];
                                 
-                                //Settings S;
-                                uint8_t I8_Values[512];
-                                
+                                uint8_t I8_Values[511];
+                                uint32_t I32_Teller;
+                                Error4 = 1;
                                 if(I16_Universe == S.I32_GetOutput1())
                                 {
                                     memcpy(I8_Values, &C_Buf[60], 512);
-                                    XLR1.V_SetData(I8_Values);
+                                    Error8 = 1;
+                                    for (I32_Teller = 1; I32_Teller < 512; I32_Teller ++) 
+                                    {
+                                        XLR1.V_PutData(I32_Teller, I8_Values[I32_Teller -1]);
+                                    }
                                 }
                                 else if(I16_Universe == S.I32_GetOutput2())
                                 {
                                     memcpy(I8_Values, &C_Buf[60], 512);
-                                    XLR2.V_SetData(I8_Values);
+                                   for (I32_Teller = 0; I32_Teller < 512; I32_Teller ++) 
+                                    {
+                                        XLR2.V_PutData(I32_Teller, I8_Values[I32_Teller -1]);
+                                    }
                                 }
                                 else if(I16_Universe == S.I32_GetOutput3())
                                 {
                                     memcpy(I8_Values, &C_Buf[60], 512);
-                                    XLR3.V_SetData(I8_Values);
+                                   for (I32_Teller = 0; I32_Teller < 512; I32_Teller ++) 
+                                    {
+                                        XLR3.V_PutData(I32_Teller, I8_Values[I32_Teller -1]);
+                                    }
                                 } //einde universes
                             } //einde protocol 
                         }//einde OPCODE
                     }//Einde Artnet
                 }//Einde Poort checken
             }//einde if(size...
+            //Error4 = 1;
         }//wait_ms(1); //einde IF getinterrupt == false
         else
-        {   
-            T_DMX1.terminate();                             //Threads stoppen
-            T_DMX2.terminate();                             //Geen nut, waarom dmx uitsturen als er geen Art-Net binnenkomt?
-            T_DMX3.terminate();
+        {                              
+            XLR1.V_Stop();                                          //Geen nut, waarom dmx uitsturen als er geen Art-Net binnenkomt?
+            XLR2.V_Stop();                                          //idem
+            XLR3.V_Stop();                                          //idem
             
             S.V_SetInterrupt(false);
             wait(1);
@@ -115,11 +101,11 @@
             
             V_DisplayMenu();
             
-            /*Thread T_DMX1(V_DMXThread1);                    //DMX threads terug starten
-            Thread T_DMX2(V_DMXThread2);
-            Thread T_DMX3(V_DMXThread3);*/
+            XLR1.V_Start();                                         //dmx terug starten
+            XLR2.V_Start();
+            XLR3.V_Start();
         }//einde IF getinterrupt != false
-    }//einde while*/
+    }//einde while
 }//einde main
 
 void V_Reset()
@@ -154,37 +140,26 @@
         
         case 1:
         {
-            V_WriteTxt(6, 2, "test");
+            V_WriteTxt(6, 2, "Universe");
             break;
         }
         
         case 2:
         {
+            V_WriteTxt(6, 2, "Universe");
             break;
         }
         
         case 3:
         {
-            break;
-        }
-        
-        case 4:
-        {
-            break;
-        }
-        
-        case 5:
-        {
-            break;
-        }
-        
-        case 6:
-        {
+            V_WriteTxt(6, 2, "Universe");
             break;
         }
         
         default:
         {
+            V_WriteTxt(6, 2, "Error");
+            V_WriteTxt(6, 3, "Restart");
             break;
         }
         
--- a/main.h	Thu May 19 14:27:07 2016 +0000
+++ b/main.h	Mon May 23 14:26:36 2016 +0000
@@ -1,7 +1,7 @@
 #ifndef MAIN_H
 #define MAIN_H
 
-#define _CRT_SECURE_NO_WARNINGS
+//#define _CRT_SECURE_NO_WARNINGS
 
 #include "mbed.h"
 #include "rtos.h"
@@ -13,15 +13,14 @@
 #include "Screen.h"
 
 #define FIRMWARE "B-01-10"
-const string S_Menu[] {"Firmware", "Output 1", "Output 2", "Output 3", "IP", "Netmask", "Save"};
+const string S_Menu[] {"Firmware", "Output 1", "Output 2", "Output 3", "Save"};
 
-DMX XLR1(p9);
-DMX XLR2(p13);
-DMX XLR3(p28);
+DMX XLR1(p9, p10);
+DMX XLR2(p13, p14);
+DMX XLR3(p28, p27);
 
 Settings S;
 Screen Sc;
-
 Ethernet eth;
 
 DigitalOut Error1(LED1);
@@ -29,6 +28,7 @@
 DigitalOut Error4(LED3);
 DigitalOut Error8(LED4);
 
+
 InterruptIn PushButton(p5);
 InterruptIn LeftTwist(p6);
 InterruptIn RightTwist(p7);
@@ -47,6 +47,8 @@
 void V_WriteTxt(uint32_t I32_Kolom, uint32_t I32_Rij, char * C_Tekst);
 uint32_t I32_GeneralTxt();
 
+void V_SEND();
+
 #endif