Tag not communicating with anchors?

Hi,
I’m trying to run some of the example code for the API with some slight modifications. I’ve already configured 3 anchors successfully and their positions are returned correctly by the get_loc function. However when I configure a 4th dwm1001 as a tag and run the get_loc function it only returns zero. Looking a little bit deeper it seems the loc.anchors.dist.cnt object always returns 0. Is there any reason my tag wont recognize the surrounding anchors?

int get_loc(void)
{
// ========== dwm_loc_get ==========
int rv, err_cnt = 0, i;
dwm_loc_data_t loc;
dwm_pos_t pos;
loc.p_pos = &pos;
HAL_Log(“dwm_loc_get(&loc)\n”);
rv = Test_CheckTxRx(dwm_loc_get(&loc));
gettimeofday(&tv,NULL);
if(rv == RV_OK)
{
HAL_Log(“ts:%ld.%06ld [%d,%d,%d,%u]\n”, tv.tv_sec, tv.tv_usec, loc.p_pos->x, loc.p_pos->y, loc.p_pos->z, loc.p_pos->qf);
printf(“ts:%ld.%06ld [%d,%d,%d,%u]”, tv.tv_sec, tv.tv_usec, loc.p_pos->x, loc.p_pos->y, loc.p_pos->z, loc.p_pos->qf);
auto var = loc.anchors.dist.cnt;
for (i = 0; i < loc.anchors.dist.cnt; ++i)
{
HAL_Log("#%u)", i);
printf("#%u)", i);
HAL_Log(“a:0x%08x”, loc.anchors.dist.addr[i]);
printf(“a:0x%08x”, loc.anchors.dist.addr[i]);
if (i < loc.anchors.an_pos.cnt)
{
HAL_Log("[%d,%d,%d,%u]", loc.anchors.an_pos.pos[i].x,
loc.anchors.an_pos.pos[i].y,
loc.anchors.an_pos.pos[i].z,
loc.anchors.an_pos.pos[i].qf);
printf("[%d,%d,%d,%u]", loc.anchors.an_pos.pos[i].x,
loc.anchors.an_pos.pos[i].y,
loc.anchors.an_pos.pos[i].z,
loc.anchors.an_pos.pos[i].qf);
}
HAL_Log(“d=%u,qf=%u\n”, loc.anchors.dist.dist[i], loc.anchors.dist.qf[i]);
printf(“d=%u,qf=%u”, loc.anchors.dist.dist[i], loc.anchors.dist.qf[i]);
}
HAL_Log("\n");
printf("\n");
}
err_cnt += rv;
return err_cnt;
}

int main(int argc, char*argv[])
{
dwm_init(argv[1]);
{//init
printf(“Initializing…\n”);
HAL_Log(“Initializing…\n”);
HAL_Log(“Done\n”);
}

if (argc > 1)
{
if (strcmp(argv[2], “anchor”) == 0)
{
configAnchor(atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]));
}
if (strcmp(argv[2], “tag”) == 0)
{
setup_tag();
}
}
dwm_upd_rate_set(1,1);
dwm_panid_set(1);
dwm_int_cfg_set(DWM1001_INTR_LOC_READY);

dwm_pos_t checker;
// dwm_pos_get(&checker);
dwm_cfg_t cfg;
dwm_cfg_get(&cfg);
printf(“Configured as %d\n”, cfg.mode);
dwm_pos_get(&checker);
while(1)
{
get_loc();
HAL_Delay(10);
}

Hi @cart0421,

possible reasons:
1.tag is not configured to be in the same network as the anchors, not the same network/pan ID. (shell commands: nis, si)
2. You dont have an initiator in your network. At least one of the anchors must be the initaitor (shell commands: nmi, si)
3. Tag is not in an active mode. The passive mode is default after factory reset. (shell commands: nmt, si)
4. Tag is not configured to have enabled location engine. But in that case you will get at least distances, so this might not be your case. (shell commands: acts, si)

All these can be configured and checked by the shell and by the UART/SPI as well, see the API GUIDE.

JF.

@leapslabs This helped a lot thank you! I now have the tags and anchors communicating on the same network but even though I set the anchors position and can verify it locally (shell commands: aps, apg) the tag sees their position as 0,0,0 when I use the shell command la. I’m assuming this is why i’m having issues getting position data while I have no issue getting distances. Any suggestions? (loc_en is enabled on tag)

ignore this, I realized I was setting position thinking it was in meters but its actually millimetres. once I multiplied my position values by 1000 it works fine.