This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I am trying to read register 0 and after reset I get all 0s clocked out.

Other Parts Discussed in Thread: ADS1298

Here is the main program

 

//set pin names
int ledPin =  13;      // LED connected to digital pin 13 d13
int RESET = 11;        //reset pin active reset low d10.
int START = 10;        //start pin activate conversion when high d11.
int DRDY = 12;         //active low when data is ready to be read d12.
int cs_main = 9;       //selects main chip to configure registers d9
int cs_secondary =8;   //selects non-main chip to configure registers d9
int sclk=14;          //system clock for all the other pins d14
int doutMISO_0=0;          //doutMISO of the main chip 2-7 secondary chips master in slave out
int dinMOSI=15;           //data in to all other pins Master out slave in

//global vareables
int buttonState=LOW;
int drdy_State=HIGH;
int dout_input=HIGH;

// The setup() method runs once, when the sketch starts

void setup()   {               

  ads1298_Set_Pins();
  ads1298_Power_Up();

  send_Reset_Command();
  //delay after reset
  delay(1000); 
  delay(1000); 
  delay(1000); 
  delay(1000); 
  delay(1000);

  //Stop Read Data Continuously mode
  sdatac();

  //read = RREG When in RDATAC mode, the RREG command is ignored.



  //read register 0
  read_reg_0();

  read_byte_1();


  digitalWrite(sclk, HIGH);
  //b7
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b6
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b5
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b4
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b3
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b2
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b1
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);


  digitalWrite(sclk, HIGH);
  //b0
  digitalWrite(sclk, LOW);
  dout_input = digitalRead(doutMISO_0);
  SerialUSB.print(dout_input);



  //  digitalWrite(START, HIGH);

  //check for drdy change before filling registers...
  while(drdy_State==HIGH){
    drdy_State = digitalRead(DRDY);
    if(drdy_State==LOW){ 
      digitalWrite(ledPin, HIGH);
    }
  }

}
// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()                    
{
  buttonState = digitalRead(DRDY);

  if(buttonState==LOW){ 
    //    lowsig++;      
  }           // wait for a second
  if(buttonState==HIGH){ 
    //    highsig++;      
  }

  //SerialUSB.println("Hello World! low");
  //  SerialUSB.println(lowsig);
  //  SerialUSB.println(highsig);

}


here is the functions:

 


void ads1298_Set_Pins(void){
  SerialUSB.println("ADS1298 power up!");
  //setup pins for inputs and outputs
  pinMode(ledPin, OUTPUT);
  pinMode(RESET, OUTPUT); 
  pinMode(START, OUTPUT); 
  pinMode(DRDY, INPUT);
  pinMode(cs_main, OUTPUT);
  pinMode(cs_secondary, OUTPUT);
  pinMode(sclk, OUTPUT);
  pinMode(doutMISO_0, INPUT);
  pinMode(dinMOSI, OUTPUT);
}

void ads1298_Power_Up(void){
  //tie all low
  digitalWrite(START, LOW);
  digitalWrite(ledPin, LOW);
  digitalWrite(cs_main, LOW);
  digitalWrite(cs_secondary, LOW);
  digitalWrite(sclk, LOW);
  digitalWrite(dinMOSI, LOW);
  //step 1 wait 500ms instead of recomended 150ms
  //for power supplies to stableise
  delay(500);
  //set CLKSEL=1 wait 20us //allready set to 1 unless tie to pin.
  delay(500); //wait 500ms instead of 20us to let clk stableise
  //wait 2^16 tclk = 65536 tclk 2.x Mhz
  delay(1000); //wait 1 s instead of 65536 tclk
  //reset pulse low wait 18tclks longer low wait 5 sec for power on reset
  //reset allready tied HIGH
  digitalWrite(RESET, LOW);
  delay(100);
  digitalWrite(RESET, HIGH);
  delay(1000);
  delay(1000);
  delay(1000);
  delay(1000);
  delay(1000);
}

void send_Reset_Command(void){
  //0000 0110
  //msb first
  //set configuration registers...

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//msb 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //doutMISO 6 =0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //doutMISO 5 =0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //doutMISO 4 =0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //doutMISO 3 =0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, HIGH); //dinMOSI b2=1
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //doutMISO b1=1
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//dinMOSI b0=0
  digitalWrite(sclk, LOW);
}

void sdatac(void){
  //SDATAC
  //0001 0001
  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//msb7 = 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b6 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b5 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, HIGH);//b4 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//b3 = 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b2 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b1 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, HIGH);//b0=1
  digitalWrite(sclk, LOW);
}

void rreg (void){
  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//msb7 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b6 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, HIGH);//b5 1
  digitalWrite(sclk, LOW);
}

void wr_defalt_pre_num_of_bytes(void){
  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//msb 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b6 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b5 0
  digitalWrite(sclk, LOW);
}

void rwrite(void){ 
  //rwrite = WREG
  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//msb 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, HIGH);//b7 1
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//b6 0
  digitalWrite(sclk, LOW);
}

void read_reg_0(void){
  rreg();
 
  digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);//b4 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b3 0
  digitalWrite(sclk, LOW);


  digitalWrite(sclk, HIGH);
  //b2 0
  digitalWrite(sclk, LOW);


  digitalWrite(sclk, HIGH);
  //b1 1
  digitalWrite(sclk, LOW);


  digitalWrite(sclk, HIGH);
  //b0 0
  digitalWrite(sclk, LOW);
}

void read_byte_1(void){
//wr_defalt_pre_num_of_bytes
wr_defalt_pre_num_of_bytes();
//number of bytes 0


    digitalWrite(sclk, HIGH);
  digitalWrite(dinMOSI, LOW);  //b4 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b3 0
  digitalWrite(sclk, LOW);


  digitalWrite(sclk, HIGH);
  //b2 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b1 0
  digitalWrite(sclk, LOW);

  digitalWrite(sclk, HIGH);
  //b0 0
  digitalWrite(sclk, LOW);
}

  • Hi Josh,

    Screen shots from a scope or logic analyser would help a lot here.  What is the state of your /CS input during the initialation?

  • I will double check the Active Low Chip Select Line their will be a few steps I will try.

    1. The CS line is low in the functions saved in the 2nd sketch file but the pin definition is in the first file.
    2. I hear there might be some problem with that because maples system doen't see or transfer information well between files I will see if this is still a problem in the forums for maple.
    3. I will test the code as one file.
    4. I will check the chip select wilre with a meeter for continuity & 0v when powered up and toggle it to check for a high.
    5. cs_main is the chip select vareable defined in the main code and used in the 2nd file.

    I kept the CS low at all times in my functions I seen no need to unselect the chip or does that cause problems?

    If the steps above do not work I will assemble the gadget factories fpga logic analiser and try to take some pictures with that of the waveform.

     

     

  • this is what it says it should be on the data sheet
    010 = ADS1298; 24-bit resolution, 8 channels
    the lower bits of Address = 00h
    page 39
    it is now showing all 1's

  • I checked the wireing the wire came loose I get now 10010010 so I guess it is working I can read from the SPI the next test I will do is read & write to a different register that is read and write able.

  • Connected Inputs to DRL and tried taking mesurements shouldn't the status bits be different than mesurements?

     

     

     

     




    Connected Inputs to DRL and tried taking measurements shouldn't the status bits be different than measurements?

    The code is in the downloads section on the left it says code valt of kicad files & calculations. (It should include software...)

    MAPLE_CODE_LOAD_ADC_N_READ-101016a.zip

    Here is the program output it sets the registers & shows what they read then reads 24 bits 18 times

    10010010 Register 0 Shows 010 at the end 8 channel & ID
    10100001 Register 1 Shows value 10100001=161=high res,daisy chain,osc out,16ksps
    10 Register 2 Shows test signal not used
    11000000 Register 3 en ref buf 2=rld buf en
    0 Register 4 Shows 00 = Lead-off detection turned off (default)
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    10000 Register 5-12 Shows 6:4=001 gain =1
    11111111 Register 13 Shows ALL pos BITS EFFECT RLD
    11111111 Register 14 Shows ALL neg BITS EFFECT RLD
    0 Register 15 Shows sens pos. off
    0 Register 16 Shows sens neg. off
    0 Register 17 Shows sens flip. off
    0 Register 20 GPIO = 0 = output
    0 Register 21 Pace
    0 Register 22 Shows RESPETORY = 0 = respetory circuit off
    0 Register 23 Config4
    0 Register 24 WCT1
    0 Register 25 WCT2
    10000000000000000000000
    10000001011000000000000
    11100000000000000000000
    10000010110000000000000
    1100000000000000000000
    10000011100000000000000
    10000000000000000000000
    10000000000101100000000
    1100000000000000000000
    10000000000000000000000
    10000101100000000000000
    10000000000000000000000
    110000000000001001000000
    10000000000000000000000
    10111000000000000000000
    10000001011000000000000
    10000000000000000000000
    10000000000000000000000

    Here is a picture of the setup rig.
    The solderless breadboard could be not making good connection.

    https://sites.google.com/site/openloopproject/

  • I'm trying to communicate with AS1298 too (read Reg 0x00) but I get all 0's at the dout.  I verified all signals going out with oscope and they all check out.  After setting "CS" low, I sent '00100000' to read reg 0x00 and then '00000001' to specify number of bytes, however I get nonthing back when I sent "SCLK" cycles.  A couple questions:

    1) Is it necessary to cycle the RESET pin like you did before communicating with ADS1298?

    2) Is is necessary to take "START" pin high if you just want to communciate with ASD1298, i.e., read Reg 0x00?

    3) What is "cs_secondary" and is it connected to ADS1298, and if so which pin is it connected? 

    4) How much delay I should have between OP codes?

    Thanks,

    Ben

  • I used the reset command I do not have a reset pin on my ads1298 module I made.

    Start should be low to read registers and write them I believe start effects data out and doing conversions and sincing conversions.

    CS secondary chip selects the secondary ads1298 I consider the main one to make the clock for the rest for that it needs to be chip selected seperately to load seperate data.

    My micro is slow enough to allow for delay inbetween opcodes I used leaflabs maple and it can be programed in arduino like code.

    leaflabs.com

     

    Tell me if you have any more questions.

    register 0 is read only.