Post Go back to editing

ADAR1000 SPI Control

Hi,

I would like to clarify the SPI control for the ADAR1000.

I will connect 4 SPI lines via an Arduino or Raspberry Pi to the ADAR1000 using pins 16 -19 on P1. Is this correct?

And to confirm this 4-wire SPI connection will allow me to control the amplitude and phase of all 4 channels of the ADAR1000?

Many thanks,

Zain

  • Yes, that is correct: Pins 16 through 19 on the P1 header are connected to the 4 SPI lines.  Note that P2 has the same connections as P1 so you can connect several boards together.

    Yes, the amplitude, phase, subcircuit bias current, etc. for all channels is all controlled via the 4-wire SPI.  Chip setup, memory control and access is also controlled via the SPI. 

  • Many thanks for the reply.

    Could you point me in the best direction to get started with SPI using an Arduino. Simply would like to steer RX1 to 30deg. 

    Is there existing code I could start from?

    Best regards,

    Zain

  • Doing a search on Arduino's website, I found the reference SPI page which seems to give a good overview of establishing a SPI connection, SPI setup, doing a SPI transfer, and ending the connection:

    https://www.arduino.cc/en/Reference/SPI

    It looks like the actual method that does a SPI transfer is found here:

    https://www.arduino.cc/en/Reference/SPITransfer

    For Rx1 with approx 30 degrees phase shift you would write the following in hexidecimal (format is "Register Address, Register Data")

    0x14, 0x3B

    0x15, 0x2F

  • So I have been attempting to control the ADAR1000 with the Arduino. 

    My codes is as follows:

    #include <SPI.h>

    int ss=10;
    int del=20;

    void setup() {
    pinMode(ss, OUTPUT);
    SPI.begin();
    SPI.setBitOrder(MSBFIRST);

    digitalWrite(ss, LOW);
    SPI.transfer(0x1C); //register address max gain
    SPI.transfer(0xFF); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x14); //register address CH1 I
    SPI.transfer(0x36); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);


    digitalWrite(ss, LOW);
    SPI.transfer(0x15); //register address CH1 I
    SPI.transfer(0x35); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);


    while(1);
    }

    The ADAR1000 won't do anything. I have checked the wiring and all seems fine.

    Any suggestions?

  • Can you confirm you are providing a 24 bit SPI transaction each time the SS/CSB line is asserted low?

    Are these all the SPI writes you are doing?  Where are all the setup, enable, device mode,  memory vs. register data sourcing writes to registers 0x2E, 0x2F, 0x31 and 0x38?  Note that you need to also write to register 0x28 to load the new gain and phase settings, since the gain and phase data is double buffered.  I suggest the following writes:

    0x2E, 0x7F //All Rx channels and subcircuits enabled

    0x2F, 0x7F  //All Tx channels and subcircuits enabled

    0x31, 0x20  //Rx global enable asserted, TR in SPI control, TR_SPI = 0 (Rx mode)

     0x38, 0x60   //gain, phase and bias data sourced from registers

    0x28, 0x01  //Load the new gain and phase data

  • I tried adding the extra registers you mentioned so that the code is now as below. 

    I have checked my SPI and believe it is 8-bit. I haven't used SPI before so could you advise what to do. 

    I see from figure 6 the device address will be 0001. So should I send this before the register address?

    Many thanks for the help. This is all new to me.

    #include <SPI.h>

    int ss=10;
    int del=20;

    void setup() {
    pinMode(ss, OUTPUT);
    SPI.begin();
    SPI.setBitOrder(MSBFIRST);

    digitalWrite(ss, LOW);
    SPI.transfer(0x000); //register address max gain
    SPI.transfer(0xBD); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x2E); //All Rx channels and subcircuits enabled
    SPI.transfer(0x7F); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x2F); ///All Tx channels and subcircuits enabled
    SPI.transfer(0x7F); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x31); //Rx global enable asserted, TR in SPI control, TR_SPI = 0 (Rx mode)
    SPI.transfer(0x20); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x38); //gain, phase and bias data sourced from registers
    SPI.transfer(0x60); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x28); //Load the new gain and phase data
    SPI.transfer(0x01); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);


    digitalWrite(ss, LOW);
    SPI.transfer(0x01C); //register address max gain
    SPI.transfer(0xFF); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);

    digitalWrite(ss, LOW);
    SPI.transfer(0x014); //register address CH1 I
    SPI.transfer(0x36); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);


    digitalWrite(ss, LOW);
    SPI.transfer(0x015); //register address CH1 Q
    SPI.transfer(0x35); //Hex value to be sent
    digitalWrite(ss, HIGH);
    delay(del);


    while(1);
    }

  • Figure 6 is a special case of Write All mode, meaning it writes the same data to all chips on the SPI bus.  I would disregard this for now until you figure out your Arduino problems.

    Please make sure your SPI transaction follows the protocols shown in Figures 2, 3 and 4 in the Rev. A datasheet.  In other words, there should be a 16 bit instruction cycle, which contains the R/W instruction bit (first bit clocked in when MSB first) followed by 15 address bits (in general).  This is immediately followed by an 8 bit data cycle.  The total transaction is 24 bits and CSB stays low only for those 24 bits.  I would advise measuring the CSB, CLK and MOSI (data) lines with an oscilloscope to make sure that your Arduino controller is writing what you think it is writing. 

    By the way, the write to register 0x28 needs to come after you set the gain and phase values, else they will not update as you have it now.

    BTW, have you noticed what the +3.3V current to the ADAR1000 board is on your supply?  Given the SPI writes above, it should be around 80 mA.

  • Many thanks I will look into things with an oscilloscope. 

    Could I also ask another question relating to the ADAR1000. 

    If the device has an incoming signal to RX1.

    1. Is the ADAR1000 able to read the incoming phase and amplitude of this signal?

    or

    2. Can the device only amplify and phase shift this incoming signal?

  • You're welcome. 

    RX1 will only amplify and phase shift a signal, it will not detect amplitude or phase.  

    There are on-board detectors found at DET1, 2, 3 and 4 that will detect amplitude.  The detector is sampled and its value is available via the ADC.

  • Hi again,

    So I managed to get the Arduino to SPI code working. It was working fine I could control all channels  phase ang gain etc. I saved the code and used it a few hours later and it will not work. 

    I can confirm the reset command is working but nothing else.

    The code is as follows:

    #include<SPI.h>


    int SS=10;


    void setup()
    {
    //Serial.begin(25000);
    SPI.begin();
    delay(100);


    //--------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x000);
    SPI.transfer(0x81);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x000);
    SPI.transfer(0x18);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //--------------------- This wasn't working
    // digitalWrite(SS, LOW);
    //SPI.transfer(0x0);
    //SPI.transfer(0x400);
    // SPI.transfer(0x55);
    // digitalWrite(SS, HIGH);
    //---------------------

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x038);
    SPI.transfer(0x60);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x02F);
    SPI.transfer(0x7F);
    digitalWrite(SS, HIGH);
    //---------------------

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x036);
    SPI.transfer(0x16);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x037);
    SPI.transfer(0x06);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x031);
    SPI.transfer(0x42);
    digitalWrite(SS, HIGH);
    //---------------------CURRENT

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x01C); // Channel 1 : 0x01c , Channel 2 : 0x01d , Channel 3 : 0x01e , Channel 4 : 0x01f
    SPI.transfer(0xFF);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //--------------------- I
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x020); //Channel 1 : 0x020 , Channel 2 : 0x022 , Channel 3 : 0x024 , Channel 4 : 0x026
    SPI.transfer(0x36);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //--------------------- Q
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x021); //Channel 1 : 0x021 , Channel 2 : 0x023 , Channel 3 : 0x025 , Channel 4 : 0x027
    SPI.transfer(0x36);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);

    //---------------------
    digitalWrite(SS, LOW);
    SPI.transfer(0x0);
    SPI.transfer(0x028);
    SPI.transfer(0x02);
    digitalWrite(SS, HIGH);
    //---------------------

    delay(100);
    }

    void loop()
    {

    }

    Any suggestions on what to do here?