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

Committer:
manumaet
Date:
Tue Feb 17 10:58:58 2015 +0000
Revision:
35:95d838d33bf5
Parent:
34:f56962030c5c
Child:
36:883de6f9a73b
working console bar with two nodes after cleanup

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manumaet 27:71178fdb78e1 1 // by Matthias Grob & Manuel Stalder - ETH Zürich - 2015
manumaet 27:71178fdb78e1 2
manumaet 27:71178fdb78e1 3 #ifndef MMRANGING_H
manumaet 27:71178fdb78e1 4 #define MMRANGING_H
manumaet 27:71178fdb78e1 5
manumaet 27:71178fdb78e1 6 #include "mbed.h"
manumaet 27:71178fdb78e1 7 #include "DW1000.h"
manumaet 27:71178fdb78e1 8
manumaet 35:95d838d33bf5 9 #define MMRANGING_TIMEUNIT_US 1/(128*499.2) // conversion between LSB of TX and RX timestamps and microseconds
manumaet 35:95d838d33bf5 10 #define MMRANGING_TIMEUNIT_NS 1000/(128*499.2) // conversion between LSB of TX and RX timestamps and nanoseconds
manumaet 27:71178fdb78e1 11
manumaet 27:71178fdb78e1 12 class MMRanging {
manumaet 28:a830131560e8 13 public:
manumaet 28:a830131560e8 14 MMRanging(DW1000& DW);
manumaet 28:a830131560e8 15 void requestRanging();
manumaet 31:6f76f3d518ac 16 void requestTime();
manumaet 28:a830131560e8 17 //private:
manumaet 28:a830131560e8 18 DW1000& dw;
manumaet 28:a830131560e8 19
manumaet 30:4ecc69d3cf8d 20 void callbackRX();
manumaet 30:4ecc69d3cf8d 21 void callbackTX();
manumaet 35:95d838d33bf5 22 void sendRangingframe(uint8_t type, uint8_t sequence_number, uint64_t time_difference_receiver);
manumaet 30:4ecc69d3cf8d 23
manumaet 34:f56962030c5c 24 struct rangingframe {
manumaet 34:f56962030c5c 25 uint32_t type;
manumaet 34:f56962030c5c 26 uint32_t sequence_number;
manumaet 31:6f76f3d518ac 27 uint64_t time_difference_receiver;
manumaet 31:6f76f3d518ac 28 } ;
manumaet 31:6f76f3d518ac 29 uint64_t rangingtimingsSender[10][2];
manumaet 31:6f76f3d518ac 30 uint64_t rangingtimingsReceiver[10][2];
manumaet 35:95d838d33bf5 31 uint64_t tofs;
manumaet 31:6f76f3d518ac 32
manumaet 31:6f76f3d518ac 33 rangingframe TX;
manumaet 31:6f76f3d518ac 34
manumaet 28:a830131560e8 35 // draft for first test
manumaet 28:a830131560e8 36 bool receiver;
manumaet 28:a830131560e8 37 uint64_t TX_timestamp;
manumaet 28:a830131560e8 38 uint64_t RX_timestamp;
manumaet 28:a830131560e8 39 int event_i;
manumaet 28:a830131560e8 40 char event[10][20];
manumaet 28:a830131560e8 41 uint64_t eventtimes[10];
manumaet 28:a830131560e8 42 uint8_t counter;
manumaet 27:71178fdb78e1 43 };
manumaet 27:71178fdb78e1 44
manumaet 27:71178fdb78e1 45 #endif