This is the DW1000 driver and our self developed distance measurement application based on it. We do this as a semester thesis at ETH Zürich under the Automatic Control Laboratory in the Department of electrical engineering.

Dependencies:   mbed

Revision:
38:8ef3b8d8b908
Parent:
37:40f94c634c3e
Child:
39:bb57aa77b015
--- a/DW1000/DW1000.cpp	Fri Feb 20 13:21:06 2015 +0000
+++ b/DW1000/DW1000.cpp	Sun Feb 22 11:41:18 2015 +0000
@@ -11,8 +11,9 @@
     loadLDE();                          // important everytime DW1000 initialises/awakes otherwise the LDE algorithm must be turned of or there's receiving malfunction see User Manual LDELOAD on p22 & p158
     
     // Configuration TODO: make method for that
-    writeRegister8(DW1000_SYS_CFG, 3, 0x20); // enable auto reenabling receiver after error
-    //writeRegister8(DW1000_SYS_CFG, 2, 0x03); // enable 1024 byte frames TODO: is this really what stated in the comment?
+    writeRegister8(DW1000_SYS_CFG, 3, 0x20);    // enable auto reenabling receiver after error
+    writeRegister8(DW1000_SYS_CFG, 2, 0x40);    // enable special receiving option for 110kbps!! (0x40) see p.64 of DW1000 User Manual [DO NOT enable 1024 byte frames (0x03) becuase it generates disturbance of ranging don't know why...]
+    writeRegister16(DW1000_TX_FCTRL, 1, 0x2800 | 0x0100 | 0x0080); // use 2048 symbols preable (0x2800), 16MHz pulse repetition frequency (0x0100), 110kbps bit rate (0x0080) see p.69 of DW1000 User Manual
     
     irq.rise(this, &DW1000::ISR);       // attach Interrupt handler to rising edge
 }
@@ -80,19 +81,20 @@
 }
 
 void DW1000::sendFrame(uint8_t* message, uint16_t length) {
-    if (length >= 1021) length = 1021;                              // check for maximim length a frame can have            TODO: 127 Byte mode?
+    //if (length >= 1021) length = 1021;                            // check for maximim length a frame can have with 1024 Byte frames [not used, see constructor]
+    if (length >= 125) length = 125;                                // check for maximim length a frame can have with 127 Byte frames
     writeRegister(DW1000_TX_BUFFER, 0, message, length);            // fill buffer
     
     #if 0 // switch draft for slower data rate and original working 6.8Mbps
         uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame
         length += 2;                                                    // including 2 CRC Bytes
         //length = ((backup & 0xFC) << 8) | (length & 0x03FF);
-        length = ((0xA0 & 0xFC) << 8) | (length & 0x03FF); // for slower data rate and therefore more range   TODO: put in a modular configuration not a fixed value
+        length = ((0x80 & 0xFC) << 8) | (length & 0x03FF); // for slower data rate and therefore more range   TODO: put in a modular configuration not a fixed value
         writeRegister16(DW1000_TX_FCTRL, 0, length);
         
         backup = readRegister8(DW1000_TX_FCTRL, 2); // change preamble length
         uint8_t preamble_reg = (backup & 0xC0) | (0x29 & 0x3F); // for longer preamble to match slower data rate   TODO: put in a modular configuration not a fixed value
-        writeRegister8(DW1000_TX_FCTRL, 2, preamble_reg);
+        //writeRegister8(DW1000_TX_FCTRL, 2, preamble_reg);
     #else
         uint8_t backup = readRegister8(DW1000_TX_FCTRL, 1);             // put length of frame
         length += 2;                                                    // including 2 CRC Bytes