This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Distance measurement between several TAGs and several ANCHORs #216
Comments
Hi! Add anchor filter in tag: RangeRequestResult tagRangeRequest() {
DW1000NgRTLS::transmitTwrShortBlink();
if(!DW1000NgRTLS::waitForNextRangingStep()) return {false, 0};
size_t init_len = DW1000Ng::getReceivedDataLength();
byte init_recv[init_len];
DW1000Ng::getReceivedData(init_recv, init_len);
// compare tag eui and eui from response message from anchor
byte eui[] = {1,1,1,1,1,1,1,1};
DW1000Ng::getEUI(&eui[0]);
if(init_recv[5] != eui[0]
|| init_recv[6] != eui[1]
|| init_recv[7] != eui[2]
|| init_recv[8] != eui[3]
|| init_recv[9] != eui[4]
|| init_recv[10] != eui[5]
|| init_recv[11] != eui[6]
|| init_recv[12] != eui[7]) {
return { false, 0};
}
if(!(init_len > 17 && init_recv[15] == RANGING_INITIATION)) {
return { false, 0};
}
DW1000Ng::setDeviceAddress(DW1000NgUtils::bytesAsValue(&init_recv[16], 2));
return { true, static_cast<uint16_t>(DW1000NgUtils::bytesAsValue(&init_recv[13], 2)) };
} create some tags (change EUI): #include <DW1000Ng.hpp>
#include <DW1000NgUtils.hpp>
#include <DW1000NgTime.hpp>
#include <DW1000NgConstants.hpp>
#include <DW1000NgRanging.hpp>
#include <DW1000NgRTLS.hpp>
const uint8_t PIN_SS = SS; // spi select pin
const uint8_t PIN_RST = 27;
// Extended Unique Identifier register. 64-bit device identifier. Register file: 0x01
char EUI[] = "CC:CC:CC:CC:CC:CC:CC:CC";
volatile uint32_t blink_rate = 200;
device_configuration_t DEFAULT_CONFIG = {
false,
true,
true,
true,
false,
SFDMode::STANDARD_SFD,
Channel::CHANNEL_5,
DataRate::RATE_850KBPS,
PulseFrequency::FREQ_16MHZ,
PreambleLength::LEN_256,
PreambleCode::CODE_3
};
frame_filtering_configuration_t TAG_FRAME_FILTER_CONFIG = {
false,
false,
true,
false,
false,
false,
false,
false
};
sleep_configuration_t SLEEP_CONFIG = {
false, // onWakeUpRunADC reg 0x2C:00
false, // onWakeUpReceive
false, // onWakeUpLoadEUI
true, // onWakeUpLoadL64Param
true, // preserveSleep
true, // enableSLP reg 0x2C:06
false, // enableWakePIN
true // enableWakeSPI
};
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(32, OUTPUT);
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(32, HIGH);
// DEBUG monitoring
Serial.begin(115200);
// initialize the driver
DW1000Ng::initializeNoInterrupt(PIN_SS, PIN_RST);
Serial.println("DW1000Ng initialized ...");
// general configuration
DW1000Ng::applyConfiguration(DEFAULT_CONFIG);
//DW1000Ng::enableFrameFiltering(TAG_FRAME_FILTER_CONFIG);
DW1000Ng::setEUI(EUI);
DW1000Ng::setNetworkId(RTLS_APP_ID);
DW1000Ng::setAntennaDelay(16436);
DW1000Ng::applySleepConfiguration(SLEEP_CONFIG);
DW1000Ng::setPreambleDetectionTimeout(15);
DW1000Ng::setSfdDetectionTimeout(273);
DW1000Ng::setReceiveFrameWaitTimeoutPeriod(2000);
DW1000Ng::setDeviceAddress(1);
Serial.println(F("Committed configuration ..."));
// DEBUG chip info and registers pretty printed
char msg[128];
DW1000Ng::getPrintableDeviceIdentifier(msg);
Serial.print("Device ID: "); Serial.println(msg);
DW1000Ng::getPrintableExtendedUniqueIdentifier(msg);
Serial.print("Unique ID: "); Serial.println(msg);
DW1000Ng::getPrintableNetworkIdAndShortAddress(msg);
Serial.print("Network ID & Device Address: "); Serial.println(msg);
DW1000Ng::getPrintableDeviceMode(msg);
Serial.print("Device mode: "); Serial.println(msg);
}
void loop() {
DW1000Ng::deepSleep();
delay(blink_rate);
DW1000Ng::spiWakeup();
DW1000Ng::setEUI(EUI);
RangeInfrastructureResult res = DW1000NgRTLS::tagTwrLocalize(1500);
if(res.success)
blink_rate = res.new_blink_rate;
} create some anchors: #include <DW1000Ng.hpp>
#include <DW1000NgUtils.hpp>
#include <DW1000NgRanging.hpp>
#include <DW1000NgRTLS.hpp>
const uint8_t PIN_SS = SS; // spi select pin
const uint8_t PIN_RST = 27;
// Extended Unique Identifier register. 64-bit device identifier. Register file: 0x01
char EUI[] = "AA:BB:CC:DD:EE:FF:00:01";
byte tag_shortAddress[] = {0x05, 0x00};
uint16_t next_anchor = 2;
device_configuration_t DEFAULT_CONFIG = {
false,
true,
true,
true,
false,
SFDMode::STANDARD_SFD,
Channel::CHANNEL_5,
DataRate::RATE_850KBPS,
PulseFrequency::FREQ_16MHZ,
PreambleLength::LEN_256,
PreambleCode::CODE_3
};
frame_filtering_configuration_t ANCHOR_FRAME_FILTER_CONFIG = {
false,
false,
true,
false,
false,
false,
false,
true /* This allows blink frames */
};
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(32, OUTPUT);
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
digitalWrite(32, HIGH);
// DEBUG monitoring
Serial.begin(115200);
Serial.println(F("### DW1000Ng-arduino-ranging-anchorMain ###"));
// initialize the driver
DW1000Ng::initializeNoInterrupt(PIN_SS, PIN_RST);
Serial.println(F("DW1000Ng initialized ..."));
// general configuration
DW1000Ng::applyConfiguration(DEFAULT_CONFIG);
//DW1000Ng::enableFrameFiltering(ANCHOR_FRAME_FILTER_CONFIG);
DW1000Ng::setEUI(EUI);
DW1000Ng::setPreambleDetectionTimeout(64);
DW1000Ng::setSfdDetectionTimeout(273);
DW1000Ng::setReceiveFrameWaitTimeoutPeriod(5000);
DW1000Ng::setNetworkId(RTLS_APP_ID);
DW1000Ng::setDeviceAddress(3);
DW1000Ng::setAntennaDelay(16436);
Serial.println(F("Committed configuration ..."));
// DEBUG chip info and registers pretty printed
char msg[128];
DW1000Ng::getPrintableDeviceIdentifier(msg);
Serial.print("Device ID: "); Serial.println(msg);
DW1000Ng::getPrintableExtendedUniqueIdentifier(msg);
Serial.print("Unique ID: "); Serial.println(msg);
DW1000Ng::getPrintableNetworkIdAndShortAddress(msg);
Serial.print("Network ID & Device Address: "); Serial.println(msg);
DW1000Ng::getPrintableDeviceMode(msg);
Serial.print("Device mode: "); Serial.println(msg);
}
byte eui[] = {1,1,1,1,1,1,1,1};
void loop() {
if(DW1000NgRTLS::receiveFrame()){
size_t recv_len = DW1000Ng::getReceivedDataLength();
byte recv_data[recv_len];
DW1000Ng::getReceivedData(recv_data, recv_len);
if(recv_data[0] == BLINK) {
//c ode with the eui check is needed so that other tags can be read
if(eui[0] != recv_data[9]
|| eui[1] != recv_data[8]
|| eui[2] != recv_data[7]
|| eui[3] != recv_data[6]
|| eui[4] != recv_data[5]
|| eui[5] != recv_data[4]
|| eui[6] != recv_data[3]
|| eui[7] != recv_data[2]) {
DW1000NgRTLS::transmitRangingInitiation(&recv_data[2], tag_shortAddress);
DW1000NgRTLS::waitForTransmission();
RangeAcceptResult result = DW1000NgRTLS::anchorRangeAccept(NextActivity::RANGING_CONFIRM, next_anchor);
if(!result.success) return;
double range_self = result.range;
eui[0] = recv_data[9];
eui[1] = recv_data[8];
eui[2] = recv_data[7];
eui[3] = recv_data[6];
eui[4] = recv_data[5];
eui[5] = recv_data[4];
eui[6] = recv_data[3];
eui[7] = recv_data[2];
Serial.print(recv_data[9], HEX);
Serial.print(recv_data[8], HEX);
Serial.print(recv_data[7], HEX);
Serial.print(recv_data[6], HEX);
Serial.print(recv_data[5], HEX);
Serial.print(recv_data[4], HEX);
Serial.print(recv_data[3], HEX);
Serial.print(recv_data[2], HEX);
String rangeString = " range ";
rangeString += range_self; rangeString += " m";
rangeString += "\t RX power: "; rangeString += DW1000Ng::getReceivePower(); rangeString += " dBm";
Serial.println(rangeString);
// uncomment if you need save power
// DW1000Ng::deepSleep();
// delay(1000);
// DW1000Ng::spiWakeup();
// DW1000Ng::initializeNoInterrupt(PIN_SS, PIN_RST);
// DW1000Ng::applyConfiguration(DEFAULT_CONFIG);
// //DW1000Ng::enableFrameFiltering(ANCHOR_FRAME_FILTER_CONFIG);
// DW1000Ng::setEUI(EUI);
// DW1000Ng::setPreambleDetectionTimeout(64);
// DW1000Ng::setSfdDetectionTimeout(273);
// DW1000Ng::setReceiveFrameWaitTimeoutPeriod(5000);
// DW1000Ng::setNetworkId(RTLS_APP_ID);
// DW1000Ng::setDeviceAddress(3);
// DW1000Ng::setAntennaDelay(16436);
}
}
}
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Step 1: What do you want?
Step 2: Describe your environment
Step 3: Describe the problem
Hello, I would like to be able to have several TAGs on the same loop of 4 ANCHORs and that the TAGs only give their distance from each ANCHOR. I don't need to do triangulation, only TAG/ANCHORs distance measurement but with multiple TAGs.
I arrive at the result only with a single TAG, but not if I want to have several. If you could additionally include an .ino example that would be perfect.
The text was updated successfully, but these errors were encountered: