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.
Diff: MM2WayRanging/MM2WayRanging.cpp
- Revision:
- 46:6398237672a0
- Parent:
- 45:01a33363bc21
- Child:
- 47:b6120c152ad1
--- a/MM2WayRanging/MM2WayRanging.cpp Sun Mar 08 15:59:14 2015 +0000 +++ b/MM2WayRanging/MM2WayRanging.cpp Tue Mar 10 12:11:13 2015 +0000 @@ -51,7 +51,7 @@ break; default : break; } - + dw.startRX(); } @@ -84,7 +84,7 @@ sendPingFrame(destination); - while(!acknowledgement[destination] && (LocalTimer.read() < time_before + 0.5f)); // wait for succeeding ranging or timeout + while(!acknowledgement[destination] && (LocalTimer.read() < time_before + 0.02f)); // wait for succeeding ranging or timeout roundtriptimes[destination] = LocalTimer.read() - time_before; @@ -96,27 +96,31 @@ } inline float MM2WayRanging::calibratedDistance(uint8_t destination) { - + float rawDistance = (tofs[destination] * 300 * TIMEUNITS_TO_US / 4); - - if (this->address == 1) rawDistance+= 10; - - switch(destination){ - case 2: - return rawDistance * 0.9754 - 0.5004; - case 3: - return rawDistance * 0.9759 - 0.4103; - case 4: - return rawDistance * 0.9798 - 0.5499; - case 5: - return rawDistance * 0.9765 - 0.5169; - } - - + + + + // Calibration for Nucleo 0 (and 1) + + // if (this->address == 1) rawDistance+= 10; +// switch(destination){ +// case 2: +// return rawDistance * 0.9754 - 0.5004; +// case 3: +// return rawDistance * 0.9759 - 0.4103; +// case 4: +// return rawDistance * 0.9798 - 0.5499; +// case 5: +// return rawDistance * 0.9765 - 0.5169; +// } + + return rawDistance; + } void MM2WayRanging::requestRangingAll() { - for (int i = 1; i <= 5; i++) { // Request ranging to all anchors + for (int i = 1; i <= 4; i++) { // Request ranging to all anchors requestRanging(i); } }