]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
DCDC MDC Single Dummy: add V_out and C_out
authorOle Artz <ole.artz@t-online.de>
Tue, 25 Aug 2020 09:49:30 +0000 (11:49 +0200)
committerOle Artz <ole.artz@t-online.de>
Tue, 25 Aug 2020 09:49:30 +0000 (11:49 +0200)
atmega32u4/dcdc_mdc_single_dummy/README.md [new file with mode: 0644]
atmega32u4/dcdc_mdc_single_dummy/main.c

diff --git a/atmega32u4/dcdc_mdc_single_dummy/README.md b/atmega32u4/dcdc_mdc_single_dummy/README.md
new file mode 100644 (file)
index 0000000..b8f462a
--- /dev/null
@@ -0,0 +1,73 @@
+# MDC DCDC Single Dummy Converter Board
+
+This is the firmware for the dcdc_mdc_single_dummy Converter Board. It's a test board for the upcomming MDC DCDC Converter Board which serves as the power supply for the mdc layers/chambers. 
+
+------------------------------------------------------------------------------------------------------------------------
+
+## Installation
+
+1. make
+2. connect the Board via MicroUSB
+3. RESET the Microcontroller
+4. dfu-programmer atmega32u4 erase --force
+5. make program_bootloader
+
+------------------------------------------------------------------------------------------------------------------------
+
+## Protocol definition
+
+Data format: XuuGcRvvvv        (10 characters)         
+
+The data format has to end with \n
+
+|   Value |   Description                                                                   |
+|---------|---------------------------------------------------------------------------------|
+|   X     |   command (W := write, R := read, A := answer, etc.)                            |
+|   uu    |   Controllernumber (HEX value)                                                  |
+|   G     |   Groupnumber (to talk to all channels, that belong together in one command)    |
+|   c     |   Channelnumber in the group (HEX value)                                        |
+|   R     |   register (HEX value)                                                          |
+|   vvvv  |   16 Bit value                                                                  |
+
+Example: "RF2012FE51\n"
+
+------------------------------------------------------------------------------------------------------------------------
+
+## Channelnumber definition
+
+|Channelnumber  |   Description |
+|---------------|---------------|
+|   0           |   LDO 0       |
+|   1           |   LDO 1       |
+|   2           |   DCDC 0      |
+|   3           |   DCDC 1      |
+
+
+------------------------------------------------------------------------------------------------------------------------
+
+## Register definition
+
+|   Registers   |   Description                                                 |
+|---------------|---------------------------------------------------------------|
+|       0       |   LDO ON/OFF                                                  |
+|       1       |   DCDC set voltage adjustment resistors                       |
+|       2       |   Voltage V_in                                           (NA) |
+|       3       |   Current C_in                                           (NA) |
+|       4       |   Temperature                                            (RO) |
+|       5       |   [15:4] Firmware; [3:2] reserved; [1] Switch ; [0] LED  (RO) |
+|       6       |   Current Offset                                              |
+|       7       |   Voltage V_out                                          (RO) |
+|       8       |   Current C_out                                          (RO) |
+
+NA := not available
+RO := read only
+
+------------------------------------------------------------------------------------------------------------------------
+
+## Usage
+
+The dcdc_mdc_single_dummy Converter Board get his operating voltage via MicroUSB and receives messages via the LANTelnetServerBoard with UART Baud rate 57600.  
+
+------------------------------------------------------------------------------------------------------------------------
+
+### Version 1.0, 2020-08-25
index 642791cb8f0775e1c60690905e55d934a101fa80..c744715e31ffc16107cbd95d24b780041730b526 100644 (file)
@@ -51,6 +51,8 @@
 // |    4      |  Temperature                                            (RO) |
 // |    5      |  [15:4] Firmware; [3:2] reserved; [1] Switch ; [0] LED  (RO) |
 // |    6      |  Current Offset                                              |
+// |    7      |  Voltage V_out                                          (RO) |
+// |    8      |  Current C_out                                          (RO) |
 
 // **Data format:**    *XuuGcRvvvv*
 // **Data format:**    *X000cRvvvv*
@@ -82,15 +84,17 @@ uint8_t rxcnt = 0, txpoint = 0;
 uint8_t rxbuf[11];
 uint8_t txbuf[12];
 uint16_t adc[16];  //raw values from ADC
-uint16_t volt = 0;
-uint16_t curr = 0;
+uint16_t V_in = 0;
+uint16_t C_in = 0;
 uint16_t temp = 0;
 uint16_t information = 1;
 int8_t curr_offset = 0;
 uint16_t shift_register;
 uint16_t read_LDO_status;
 uint16_t read_setting;
-uint8_t  isMaster = 0;
+uint8_t isMaster = 0;
+uint16_t V_out;
+uint16_t C_out;
 
 uint8_t nib_to_hex(uint16_t in, uint8_t nib) {
   uint8_t t = (in >> (nib*4)) & 0xF;
@@ -187,23 +191,23 @@ void switchLDO(uint8_t chan, uint8_t val) {
 
 void setDCDC(uint8_t chan, uint8_t val) {
 //DCDC CH0
-  if (chan == 3 & val<=7) {
+  if (chan == 2 & val<=7) {
   shift_register &= ~((1<<15)|(1<<14)|(1<<13)); //clear decbitpos15-13
   shift_register |= val<<13;
   }
 //DCDC CH1
-  if (chan == 4 & val<=7) {
+  if (chan == 3 & val<=7) {
   shift_register &= ~((1<<11)|(1<<10)|(1<<9));
   shift_register |= val<<9;
   }
 //LDO CH1
-  if (chan == 2 & val<=7) {
+  if (chan == 1 & val<=7) {
   shift_register &= ~((1<<7)|(1<<6)|(1<<5));
   shift_register |= val<<5;
   }
 //LDO CH0
-  if (chan == 1 & val<=7) {
-  shift_register &= ~((1<<2)|(1<<1)|(1<<0));Sense5 Vmon1 LDO
+  if (chan == 0 & val<=7) {
+  shift_register &= ~((1<<2)|(1<<1)|(1<<0));
   shift_register |= val<<0;
   }
   setVoltages();
@@ -219,7 +223,6 @@ void setInfo(uint8_t chan, uint8_t val){
   information |= (FIRMWARE_VERSION<<4);
 }
 
-
 /*
 //  Data:   XuuGcRvvvv
 //Switch deactivated
@@ -242,11 +245,13 @@ void setInfo(uint8_t chan, uint8_t val){
 // |-----------|--------------------------------------------------------------|
 // |    0      |  LDO ON/OFF                                                  |
 // |    1      |  DCDC set voltage adjustment resistors                       |
-// |    2      |  Voltage V_in                                      Sense5 Vmon1 LDO     (RO) |
-// |    3      |  Current C_in                                           (RO) |
+// |    2      |  Voltage V_in                                           (NA) |
+// |    3      |  Current C_in                                           (NA) |
 // |    4      |  Temperature                                            (RO) |
 // |    5      |  [15:4] Firmware; [3:2] reserved; [1] Switch ; [0] LED  (RO) |
 // |    6      |  Current Offset                                              |
+// |    7      |  Voltage V_out                                          (RO) |
+// |    8      |  Current C_out                                          (RO) |
 */
 
 void getdata(uint8_t buf) {
@@ -331,10 +336,10 @@ void getdata(uint8_t buf) {
         if (hex_to_int(rxbuf[5]) == 0) {
         uint16_t read_LDO_status = 0xFFFF;
             //LDO Status CH1
-            if (hex_to_int(rxbuf[4]) == 2) {read_LDO_status = ((shift_register >> 4) & 1);
+            if (hex_to_int(rxbuf[4]) == 1) {read_LDO_status = ((shift_register >> 4) & 1);
             }
             //LDO Status CH0
-            if (hex_to_int(rxbuf[4]) == 1) {read_LDO_status = ((shift_register >> 3) & 1);
+            if (hex_to_int(rxbuf[4]) == 0) {read_LDO_status = ((shift_register >> 3) & 1);
             }
           send_answer_hex(&rxbuf[0],read_LDO_status);
         }
@@ -343,32 +348,33 @@ void getdata(uint8_t buf) {
         if (hex_to_int(rxbuf[5]) == 1) {
         uint16_t read_setting = 0xFFFF;
             //DCDC CH0
-            if (hex_to_int(rxbuf[4]) == 3) {read_setting = (shift_register >> 13) & 7;
+            if (hex_to_int(rxbuf[4]) == 2) {read_setting = (shift_register >> 13) & 7;
             }
             //DCDC CH1
-            if (hex_to_int(rxbuf[4]) == 4) {read_setting = (shift_register >> 9) & 7;
+            if (hex_to_int(rxbuf[4]) == 3) {read_setting = (shift_register >> 9) & 7;
             }
             //LDO CH1
-            if (hex_to_int(rxbuf[4]) == 2) {read_setting = (shift_register >> 5) & 7;
+            if (hex_to_int(rxbuf[4]) == 1) {read_setting = (shift_register >> 5) & 7;
             }
             //LDO CH0
-            if (hex_to_int(rxbuf[4]) == 1) {read_setting = shift_register & 7;
+            if (hex_to_int(rxbuf[4]) == 0) {read_setting = shift_register & 7;
             }
           send_answer_hex(&rxbuf[0],read_setting);                                                   
         }
         
-        // get voltage
+        // get voltage V_in
         if (hex_to_int(rxbuf[5]) == 2) {
-          send_answer_hex(&rxbuf[0],volt);
+          send_answer_hex(&rxbuf[0],V_in);
         }
         
-        // get current
+        // get current C_in
         if (hex_to_int(rxbuf[5]) == 3) {
-          send_answer_hex(&rxbuf[0],curr);
+          send_answer_hex(&rxbuf[0],C_in);
         }
         
         // get temperature
         if (hex_to_int(rxbuf[5]) == 4) {
+            temp = adc[5];
           send_answer_hex(&rxbuf[0],temp);
         }
         
@@ -382,6 +388,44 @@ void getdata(uint8_t buf) {
         if (hex_to_int(rxbuf[5]) == 6) {
           send_answer_hex(&rxbuf[0],curr_offset*16);
         } 
+        
+        // get voltage V_out
+        if (hex_to_int(rxbuf[5]) == 7) {
+        //DCDC CH0
+            if (hex_to_int(rxbuf[4]) == 2) {
+              V_out = adc[0];
+              send_answer_hex(&rxbuf[0],V_out);
+            }
+        //DCDC CH1
+            if (hex_to_int(rxbuf[4]) == 3) {
+              V_out = adc[7];
+              send_answer_hex(&rxbuf[0],V_out);
+            }
+        //LDO CH1
+            if (hex_to_int(rxbuf[4]) == 1) {
+              V_out = adc[6];
+              send_answer_hex(&rxbuf[0],V_out);
+            }
+        //LDO CH0  
+            if (hex_to_int(rxbuf[4]) == 0) {
+              V_out = adc[1];
+              send_answer_hex(&rxbuf[0],V_out);
+            }
+          
+        }
+        
+        // get current C_out
+        if (hex_to_int(rxbuf[5]) == 8) {  
+        //LDO CH1
+            if (hex_to_int(rxbuf[4]) == 1) {
+              C_out = adc[13];
+            }    
+        //LDO CH0  
+            if (hex_to_int(rxbuf[4]) == 0) {
+              C_out = adc[3];
+            }
+          send_answer_hex(&rxbuf[0],C_out);
+        }  
       }
     }
   if (rxcnt >= 10 || buf == '\n' || buf == '\r') { rxcnt = 0; }