Multiple Anchors for DWM1000

Hi all, I'm building a user-following robot based on the DWM1000 module by Decawave. I want to use two modules on the robot itself as anchors and one module on the user as the tag. I plan on using a TDOA concept model to determine the range and direction of the user with respect to the robot. I am using an Arduino Mega on the robot and an Arduino Nano/ Uno on the user. My problem is connecting the two anchors to the Arduino Mega.

I've been using a modified code based on the DW1000 library by Wahaj Murtaza which is also a modified version of thotro's DW1000 library.

I have also created a very simple carrier board for the DWM1000 according to the datasheet and manual which I have attached below.

Here's the code I've created (in the attachment). For some reason, the code loops continuously in the "reset inactive" part below.

  if (!sentAck && !receivedAck) {
    Serial.print(sentAck);Serial.print(",");Serial.println(receivedAck);
    if (curMillis - lastActivity > resetPeriod) {
        Serial.println(curMillis - lastActivity);
        resetInactive(PIN_SS);
    }
    // check if inactive
    return;
  }
  Serial.println("Inactive check...");
  // continue on any success confirmation

I still don't know whether it is a communication error between the module and the Arduino or if it is in fact a coding logic error.

All help is very much appreciated.

TA-2_double_w_o_ranging_library.ino (13.4 KB)

DWM1000.JPG

Could you please add the pins from the host MCU into the schematic? SPI has a crossover connection? DATA OUT on one side to the DATA IN on the other side. And reverse. It’s not clear without the pin description.

Hi, Klaus_K, thanks for replying. Unfortunately, I'm not using a Node MCU, but an Arduino Mega. I have uploaded the pin connections below. The arrows in the picture show the dataflow between the DWM1000 modules and the Arduino Mega.

Looking at your picture and the following link, it looks like you have swapped pin 50 and 52.

Can you check whether this is just on the paper or in your circuit?

Also check the note on that page regarding SS, pin 53 in your case.

Note about Slave Select (SS) pin on AVR based boards
All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

Do you have a way of measuring the signals between the Arduino and the DWM1000 e.g. an oscilloscope? If not, you might be able to get away with using a low power led and a 1 or 2.2kOhm resistor.

First check the CLK signal. This should run in any case talking to both devices.
Then check the MOSI. This is the Master OUT, again this should run talking to both devices, but depending on the data it might not light up as easy.
Pin 49 and 48 should light up whenever your Mega communicates with one or the other DWM. This should be visible because the chip select signal is asserted during the entire transfer.
These 4 pins should have some signal when your software tries to write to the DWM even if the other side is not working correctly.
Last check the MISO. This is the Slave OUT. If you see a signal here the DWM is at least answering.

You can use a simpler SPI example and write some code that just writes some values over SPI continuously to help with checking the SPI interface.

Looking at your picture and the following link, it looks like you have swapped pin 50 and 52.

SPI - Arduino Reference

Can you check whether this is just on the paper or in your circuit?

Yes, it is only in the paper, I accidentally swapped it while drawing the schematic.

Note about Slave Select (SS) pin on AVR based boards
All AVR based boards have an SS pin that is useful when they act as a slave controlled by an external master. Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.

Based on your advice, I've added pinMode(PIN_SS1, OUTPUT); pinMode(PIN_SS2, OUTPUT); into the setup before anything else. However, the problem persists: -See image titled 'Capture'-
The program is still looping and continually resets.

The other pictures attached shows the oscilloscope outputs of each of the pins according to the file name.

So the SCLK picture looks fine. Your SPI module is creating a clock.

The MOSI signal looks fine too. There are some 1s and 0s, going from the master to the slave.

The MISO signal does not look OK. You should see something that looks similar to the MOSI.

The SS1 pin stays high all the time. That is not OK. You should see the signal go low during the entire time the clock signal is active and you are talking to sensor1.

The same is true for SS2. There is a high to low transition. So maybe you need to zoom out a bit and see what the signal really look like.

I noted the following code. I did not have time to understand everything you are doing. So just want to check with you. The reurn will make sure nothing gets executed after this if, if the statement evaluates to false. The loop function will exit and start at the begining next time. Its OK, if thats what you want. Just checking.

  if (!sentAck && !receivedAck) {
    Serial.print(sentAck);Serial.print(",");Serial.println(receivedAck);
    if (curMillis - lastActivity > resetPeriod) {
        Serial.println(curMillis - lastActivity);
        resetInactive(PIN_SS);
    }
    // check if inactive
    return;
  }
  Serial.println("Inactive check...");
  // continue on any success confirmation

Additionally, the note about the SS pin is not about your SS pins, its about the peripheral SS pin. It looks like the libarary is taking care of it, because you have SCK and MOSI sending stuff out. But the sensors are ignoring you because the SS1 and SS2 pins are not pulled down.

Have a look at the timing diagram on wikpedia.

Okay, thanks for the feedback.

The SS1 pin stays high all the time. That is not OK. You should see the signal go low during the entire time the clock signal is active and you are talking to sensor1.

The same is true for SS2. There is a high to low transition. So maybe you need to zoom out a bit and see what the signal really look like.

Please correct me if I understand this wrongly. So you're saying that the problem is because of the SS pins are not deselected after every loop?

I noted the following code. I did not have time to understand everything you are doing. So just want to check with you. The reurn will make sure nothing gets executed after this if, if the statement evaluates to false. The loop function will exit and start at the begining next time. Its OK, if thats what you want. Just checking.

Yes, this part of the code I got from one of the examples given with the library.

But the sensors are ignoring you because the SS1 and SS2 pins are not pulled down.

Do you mean that I should attach pulldown resistors on both the ss pins?

The SPI slave will ignore everything you send to it while the chip select pin is not active. If you have a look into the DWM1000 datasheet, in pin description it states, SPICSn is active low. So when I write it needs to pull down it means actively writing LOW to your Arduino pin so the voltage at the pin goes to 0V/GND. And you should see that in the SS1 and SS2 jpg. You do not need pull down resisitors. The SPI pins are driven activily in both directions.

In SS1.jpg the signal never goes low. That means nothing that gets send to sensor1 will have an effect.
SS2 has a low to high transistion. So it was low for some reason.

Can you meassure SS1 and SCLK together? How many signals can you view at a time?

If you can see two, disable the code for one sensor.

You should see SS1 go to low, then SCLK should toggle and after that SS1 should go high again. The same is true for SS2 and SCLK together.

If you can see three. Leave the code as it is. Display SS1, SS2 and SCLK. Then you should see, SS1 or SS2 go down, the SCLK toggles and the SS1/SS2 pin goes high again. This should happen in an alternating way. SS1 and SS2 never go low at the same time.

Check the DWM1000 datasheet, section 1.3. SPI Host Interface. This shows you what the siganls should look like in a picture.