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:
36:883de6f9a73b
Parent:
35:95d838d33bf5
Child:
37:40f94c634c3e
--- a/main.cpp	Tue Feb 17 10:58:58 2015 +0000
+++ b/main.cpp	Fri Feb 20 09:07:52 2015 +0000
@@ -18,13 +18,25 @@
     pc.printf("Voltage: %f\r\n", dw.getVoltage());
     pc.printf("Size of Frame: %d\r\n", sizeof(r.TX));
     
-    uint16_t setdelay = 32768;
+    uint16_t setdelay = 32768; // TODO: = 2^15
     dw.writeRegister16(DW1000_TX_ANTD, 0, setdelay);
     pc.printf("Antenna Delay TX: %d\r\n", dw.readRegister16(DW1000_TX_ANTD, 0));
     pc.printf("Antenna Delay RX: %d\r\n", dw.readRegister16(DW1000_LDE_CTRL, 0x1804));
-    //r.receiver = true;
+    r.receiver = true;
+    if (r.receiver)
+        r.address = 1;
+    else
+        r.address = 0; // sender node has address 0
+    pc.printf("Address: %d\r\n", r.address);
+    wait(2);
     
     while(1) {
+        if (!r.receiver) {                  // Request ranging
+            r.requestRanging(1);            // TODO: ask all available nodes!
+            wait(0.005);
+        }
+        
+        // Output bar on console
         for(int j = 0; j < 1; j++)
             //pc.printf("%f ", r.tofs[j]*MMRANGING_TIMEUNIT_NS);
             pc.printf("%lld [", r.tofs);
@@ -33,17 +45,19 @@
             for(int j = 0; j < dots; j++)
                 pc.printf("=");
         pc.printf("]\r\n");
-        /*for(int j = 0; j < 10; j++)
-            if(r.event[j][0] == '!') {
-                pc.printf("%s Time: %lldus\r\n", r.event[j], r.eventtimes[j]);
-                r.event[j][0] = 'X';
-            }    */
-        if (!r.receiver) {
-            r.requestRanging();
-            wait(0.05);
-            r.requestTime();
-        }
-        //pc.printf("Status: %llX\r\n", dw.getStatus());
+        
+        #if 1   // Output events for debugging
+            for(int j = 0; j < 10; j++)
+                if(r.event[j][0] == '!') {
+                    pc.printf("%s\r\n", r.event[j]);
+                    r.event[j][0] = 'X';
+                }
+            r.event_i = 0;
+        #endif
+        pc.printf("Status: %llX\r\n", dw.getStatus());
+        pc.printf("Status: %llX\r\n", dw.readRegister40(DW1000_TX_FCTRL, 0));
+        
         wait(0.01);
+        wait(0.3);
     }
 }
\ No newline at end of file