thotro / arduino-dw1000

A library that offers functionality to use Decawave's DW1000 chips/modules with Arduino.
Apache License 2.0
516 stars 288 forks source link

Channel and RX Settings #252

Open werty37 opened 6 years ago

werty37 commented 6 years ago

I am currently trying different parameters of configuring the DWM1000 chip to test ToF. How do i change channel, data rate, pulse frequency, preamble length, preamble code?

For example, setting DW1000.setChannel(DW1000.CHANNEL_7) does not seem to work.

Irrespective of what the configurations i set, the DWM1000 initializes with these settings: Device mode: Data rate: 6800 kb/s, PRF: 16 MHz, Preamble: 128 symbols (code #4), Channel: #5

Taking a quick look at DW1000.cpp, i see that setDefault method always sets the DWM to MODE_LONGDATA_RANGE_LOWPOWER

void DW1000Class::setDefaults() {
//...
//...
    enableMode(MODE_LONGDATA_RANGE_LOWPOWER); 
}

and enableMode method sets the channel to 5.

void DW1000Class::enableMode(const byte mode[]) {
    setDataRate(mode[0]);
    setPulseFrequency(mode[1]);
    setPreambleLength(mode[2]);
    // TODO add channel and code to mode tuples
    // TODO add channel and code settings with checks (see Table 58)
    setChannel(CHANNEL_5);
    if(mode[1] == TX_PULSE_FREQ_16MHZ) {
        setPreambleCode(PREAMBLE_CODE_16MHZ_4);
    } else {
        setPreambleCode(PREAMBLE_CODE_64MHZ_10);
    }
}

I am using Arduino 1.8.5, DW1000 Library 0.6, Pro Mini 5V and Wayne DWM1000 Adapter. Any pointers?

ZizziWang commented 6 years ago

This issue can be trickily solved by add DW1000.setChannel(DW1000.CHANNEL_7) before each DW1000.commitConfiguration(); in your code

Anacron-sec commented 6 years ago

I made a pull request (#283) to address this issue.