Index: fact/tools/hvMCUtest/ARDUINO_FTDI/ARDUINO_FTDI.pde
===================================================================
--- fact/tools/hvMCUtest/ARDUINO_FTDI/ARDUINO_FTDI.pde	(revision 12146)
+++ fact/tools/hvMCUtest/ARDUINO_FTDI/ARDUINO_FTDI.pde	(revision 12147)
@@ -29,5 +29,8 @@
 */
 //define non transferable variables
-#define NUMCHANNELS 416
+#define MAXBOARDS 13
+#define EXISTINGBOARDS 10
+#define CHPERBOARD 32
+#define NUMCHANNELS EXISTINGBOARDS*CHPERBOARD
 #define BLANKBYTE 0x00
 #define READSTATEBYTE 0x20
@@ -40,15 +43,23 @@
 
 typedef enum {
+  set_message,
+  send_message,
+  get_message,
+  pc_serial,
+  parsing
+} state_contr; //Type to define what microcontroller should do
+
+typedef enum {
   channel_status,
   sys_reset,
   global_set,
   channel_set
-} function_t;
+} function_t; //Type to define which function of PLD shell be build
 
 typedef enum {
-  set_message,
-  send_message,
-  get_message
-} state_contr;
+  transmit_PLD_answer,
+  get_request,
+} communication; //Type to define communication with PC
+
 
 const unsigned char wr  =  2;
@@ -59,6 +70,6 @@
 volatile unsigned char databus = 0x00; //temp. memory for Reading Databus interrupt
 unsigned char message[3];	//field where the 3 Byte message is saved
-unsigned char messageindex=0;	//index of field
-
+unsigned char messageindex = 0;	//index of field
+unsigned char incommingByte = 0;  //for incomming serial Data
 unsigned int recent_voltages[NUMCHANNELS];  //The actual Voltage of each channel is saved in this variable
 unsigned int set_voltage;                   //The Value to which channel shell be set is saved in the variable
@@ -68,5 +79,6 @@
 
 function_t function;
-state_contr state_controler = set_message;
+state_contr state_controler;
+communication pc_com = get_request;
 
 //unsigned char call_function;                //variable to call a funtion
@@ -98,5 +110,5 @@
 function = channel_set;
 set_voltage = 0xaaa;
-state_controler = set_message; //just for development
+state_controler = pc_serial; //just for development
 digitalWrite(FREE1, LOW);
 
@@ -141,4 +153,5 @@
     }
     if ( state_controler == send_message){
+        //Serial.print ("sending message");
             //RisingEdge_RD = false;
     //This is the FIFO Read Cycle, PLD reads from FIFO, ARDUINO writes to FIFO
@@ -203,5 +216,6 @@
                         message[messageindex] = databus;
                         messageindex = 0;
-                        state_controler = set_message;
+                        state_controler = pc_serial;
+                        pc_com = transmit_PLD_answer;
                         break;
             }
@@ -213,4 +227,52 @@
 
   // delay(1000); //slow down process for test pourpose
+
+// Communication with PC via USB
+    if ( state_controler == pc_serial){
+
+    // Outgoing Commands
+    switch ( pc_com ){
+        //report PLD response to PC
+        case transmit_PLD_answer:
+            Serial.println("PLD answered: ");
+            for (messageindex = 0; messageindex < 3; messageindex++){
+            Serial.print(message[messageindex], BIN);
+            Serial.print( "\t" );
+            }
+            Serial.println(" in BIN ");
+            for (messageindex = 0; messageindex < 3; messageindex++){
+            Serial.print(message[messageindex], HEX);
+            Serial.print( "\t" );
+            }
+            messageindex = 0;
+            Serial.println(" in HEX ");
+            Serial.println( "_______________________ " );
+            pc_com = get_request;
+            break;
+
+    // Incoming Commands
+        case get_request:
+            while (Serial.available() < 3){};
+            if (Serial.available() > 0){
+                Serial.print("I received: ");
+                messageindex = 0;
+                while (messageindex < 3){
+                message[messageindex] = Serial.read();
+                Serial.print( "0x" );
+                Serial.print(message[messageindex], HEX);
+                messageindex++;
+                Serial.print( " " );
+                }
+                messageindex = 0;
+                //Serial.print(incommingByte, BYTE);
+                Serial.println(",du Nase!");
+                }
+                state_controler = send_message;
+            break;
+
+    }
+
+    }
+
 }
 
