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:
42:83931678c4de
Parent:
40:5ce51b7e3118
Child:
44:2e0045042a59
--- a/DW1000/DW1000.cpp	Sun Mar 01 20:19:38 2015 +0000
+++ b/DW1000/DW1000.cpp	Mon Mar 02 09:33:03 2015 +0000
@@ -8,13 +8,30 @@
     spi.frequency(1000000);             // with a 1MHz clock rate (worked up to 49MHz in our Test)
     
     resetAll();                         // we do a soft reset of the DW1000 everytime the driver starts
-    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
+    
+    // User Manual "2.5.5 Default Configurations that should be modified" p. 22
+    writeRegister16(DW1000_AGC_CTRL, 0x04, 0x8870);
+    writeRegister32(DW1000_AGC_CTRL, 0x0C, 0x2502A907);
+    writeRegister32(DW1000_DRX_CONF, 0x08, 0x311A002D);
+    writeRegister8 (DW1000_LDE_CTRL, 0x0806, 0xD);
+    writeRegister16(DW1000_LDE_CTRL, 0x1806, 0x1607);
+    writeRegister32(DW1000_TX_POWER, 0, 0x0E082848);
+    writeRegister32(DW1000_RF_CONF, 0x0C, 0x001E3FE0);
+    writeRegister8 (DW1000_TX_CAL, 0x0B, 0xC0);
+    writeRegister8 (DW1000_FS_CTRL, 0x0B, 0xA6);
+    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
+    
+    // 110kbps CAUTION: a lot of other registers have to be set for an optimized operation on 110kbps
     //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
     //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_ANTD, 0, 16384); // set TX and RX Antenna delay to neutral because we calibrate afterwards
+    writeRegister16(DW1000_LDE_CTRL, 0x1804, 16384); // = 2^14 a qurter of the range of the 16-Bit register which corresponds to zero calibration in a round trip (TX1+RX2+TX2+RX1)
+    
+    writeRegister8(DW1000_SYS_CFG, 3, 0x20);    // enable auto reenabling receiver after error
+    
     irq.rise(this, &DW1000::ISR);       // attach interrupt handler to rising edge of interrupt pin from DW1000
 }
 
@@ -174,6 +191,10 @@
     writeRegister(reg, subaddress, (uint8_t*)&buffer, 2);
 }
 
+void DW1000::writeRegister32(uint8_t reg, uint16_t subaddress, uint32_t buffer) {
+    writeRegister(reg, subaddress, (uint8_t*)&buffer, 4);
+}
+
 void DW1000::readRegister(uint8_t reg, uint16_t subaddress, uint8_t *buffer, int length) {
     setupTransaction(reg, subaddress, false);
     for(int i=0; i<length; i++)                             // get data