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.
Revision 47:b6120c152ad1, committed 2015-03-19
- Comitter:
- manumaet
- Date:
- Thu Mar 19 12:54:28 2015 +0000
- Parent:
- 46:6398237672a0
- Commit message:
- final release with the code used in the verification test case
Changed in this revision
diff -r 6398237672a0 -r b6120c152ad1 DW1000/DW1000.cpp --- a/DW1000/DW1000.cpp Tue Mar 10 12:11:13 2015 +0000 +++ b/DW1000/DW1000.cpp Thu Mar 19 12:54:28 2015 +0000 @@ -99,7 +99,7 @@ writeRegister(DW1000_TX_CAL, 0x00, &buffer[4], 1); readRegister(DW1000_TX_CAL, 0x03, &buffer[5], 2); // get the 8-Bit readings for Voltage and Temperature float Voltage = buffer[5] * 0.0057 + 2.3; - //float Temperature = buffer[6] * 1.13 - 113.0; // TODO: getTemperature was always ~35 degree with better formula/calibration see instance_common.c row 391 + //float Temperature = buffer[6] * 1.13 - 113.0; // TODO: getTemperature was always ~35 degree with better formula/calibration return Voltage; }
diff -r 6398237672a0 -r b6120c152ad1 MM2WayRanging/MM2WayRanging.cpp --- a/MM2WayRanging/MM2WayRanging.cpp Tue Mar 10 12:11:13 2015 +0000 +++ b/MM2WayRanging/MM2WayRanging.cpp Thu Mar 19 12:54:28 2015 +0000 @@ -12,7 +12,6 @@ dw.setCallbacks(this, &MM2WayRanging::callbackRX, &MM2WayRanging::callbackTX); - //Timer for debugging purposes LocalTimer.start(); dw.startRX();
diff -r 6398237672a0 -r b6120c152ad1 MM2WayRanging/MM2WayRanging.h --- a/MM2WayRanging/MM2WayRanging.h Tue Mar 10 12:11:13 2015 +0000 +++ b/MM2WayRanging/MM2WayRanging.h Thu Mar 19 12:54:28 2015 +0000 @@ -68,6 +68,8 @@ DISTANCES_FRAME }; + //the packed attribute makes sure the types only use their respective size in memory (8 bit for uint8_t), otherwise they would always use 32 bit + //IT IS A GCC SPECIFIC DIRECTIVE struct __attribute__((packed, aligned(1))) RangingFrame { uint8_t source; uint8_t destination;
diff -r 6398237672a0 -r b6120c152ad1 main.cpp --- a/main.cpp Tue Mar 10 12:11:13 2015 +0000 +++ b/main.cpp Thu Mar 19 12:54:28 2015 +0000 @@ -37,7 +37,7 @@ node.requestRanging(destination); if(node.overflow){ - myprintf("Overflow! Measured: %f\r\n", node.distances[destination]); + myprintf("Overflow! Measured: %f\r\n", node.distances[destination]); // This is the output to see if a timer overflow was corrected by the two way ranging class } if (node.distances[destination] == -1) { @@ -95,53 +95,44 @@ pc.printf("EUI register: %016llX\r\n", dw.getEUI()); pc.printf("Voltage: %fV\r\n", dw.getVoltage()); - node.isAnchor = true; - // declare as anchor or beacon + node.isAnchor = true; // declare as anchor or beacon + if (node.isAnchor) { - node.address = 5; + node.address = 1; myprintf("This node is Anchor node %d \r\n", node.address); } else { node.address = 0; myprintf("This node is a Beacon. "); } - if (node.address == 5){ - dw.setCallbacks(&altCallbackRX, NULL); - } + if (node.address == 5){ // the node with address 5 was used as an observer node putting out the results in our test case + dw.setCallbacks(&altCallbackRX, NULL); + } while(1) { if (!node.isAnchor){ rangeAndDisplayAll(); //calibrationRanging(4); - - - - - }else - //myprintf(".\r"); - + } else { + //myprintf("."); // to see if the core and output is working wait(0.5); + } } } -void altCallbackRX(){ +void altCallbackRX() { // this callback was used in our verification test case for the observer node which only receives and outputs the resulting data DistancesFrame distFrame; float distances[4]; dw.readRegister(DW1000_RX_BUFFER, 0, (uint8_t*)&distFrame, dw.getFramelength()); - if (distFrame.destination == 5){ + if (distFrame.destination == 5) { for (int i = 0; i<4; i++){ - distances[i] = distFrame.dist[i]; + myprintf("%f, ", distFrame.dist[i]); } - - for (int i = 0; i < 4; i++) { // Output Results - myprintf("%f, ", distances[i]); - - } - + myprintf("\r\n"); } dw.startRX();