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.

TDC1000: TDC1000 :For water and Gas Level measurement

Part Number: TDC1000
Other Parts Discussed in Thread: TDC7200

Tool/software:

Hi,

     I am using the TDC1000 connected with an STM32 for water and gas level measurement. I have configured the TDC1000 registers based on the datasheet. However, my sensor behaves differently from what I have set in the TDC1000 registers. I am using a 1 MHz transducer, and I am getting multiple STOP pulses per measurement cycle from the TDC1000, even though my configuration is set for single echo mode with NUM_RX = 1h (expecting only 1 STOP pulse). I have also set NUM_TX = 1h (1 pulse), but the TX pin outputs 5 pulses (default value, 5h), even when I change the number of pulses in the register.

I have provided a 16 MHz CLKIN to the TDC1000. I also have another question: how should I choose TX_FREQ_DIV in the CONFIG_0 register based on the transducer frequency? Currently, I am using the default setting, and I don’t observe any difference in the STOP pulse and COMPIN signals when I measure water level in a white glass beaker.

Below, I have provided the circuit diagram and register settings and the signals I obtained from the TDC1000 IC when the 1 MHz transducer was connected.

Register Setting of TDC1000:

CONFIG_0 Register

  • TX_FREQ_DIV = 2h: Divide by 8 (default) 

  • NUM_TX = 1h: 1 pulses

CONFIG_1 Register

  • NUM_RX = 1h: 1 event (1 STOP pulse output)

  • NUM_AVG = 0h: 1 measurement cycle (default)

  • RESERVED = 1h: Reserved (default)

CONFIG_2 Register

  • TOF_MEAS_MODE = 0h: Mode 0 (default)

  • CH_SEL = 0h: Channel 1 (default)

  • EXT_CHSEL = 0h: Disable external channel select (default)

  • CH_SWP = 0h: Disable automatic channel swap (default)

  • DAMPING = 0h: Disable damping (default)

  • MEAS_MODE = 0h: Time-of-flight measurement (default)

  • VCOM_SEL = 1h: External

CONFIG_3 Register

  • ECHO_QUAL_THLD = 4h: –220 mV

  • BLANKING = 0h: Disable power blanking (default)

  • TEMP_CLK_DIV = 0h: Divide by 8 (default)

  • TEMP_RTD_SEL = 0h: PT1000 (default)

  • TEMP_MODE = 0h: Measure REF, RTD1 and RTD2 (default)

  • RESERVED = 0h: Reserved (default)

CONFIG_4 Register

  • TX_PH_SHIFT_POS = 1Fh: Position 31 (default)

  • TRIG_EDGE_POLARITY = 0h: Rising edge (default)

  • RECEIVE_MODE = 0h: Single echo (default)

  • RESERVED = 0h: Reserved (default)

TOF_1 Register

  • TIMING_REG[9:8] = 0h: 0 (default)

  • LNA_FB = 1h: Resistive feedback

  • LNA_CTRL = 0h: Active (default)

  • PGA_CTRL = 0h: Active (default)

  • PGA_GAIN = 7h: 21 dB

TOF_0 Register

  • TIMING_REG[7:0] = 0h: 0 (default)

ERROR_FLAGS Register

  • ERR_SIG_HIGH = 0h

  • ERR_NO_SIG = 0h

  • ERR_SIG_WEAK = 0h

  • RESERVED = 0h: Reserved (default)

TIMEOUT Register

  • TOF_TIMEOUT_CTRL = 3h: 1024 × T0

  • ECHO_TIMEOUT = 0h: Enable echo timeout (default)

  • SHORT_TOF_BLANK_PERIOD = 4h: 128 × T0

  • FORCE_SHORT_TOF = 0h: Disabled (default)

  • RESERVED = 0h: Reserved (default)

CLOCK_RATE Register

  • AUTOZERO_PERIOD = 0h: 64 × T0 (default)

  • CLOCKIN_DIV = 0h: Divide by 1 (default)

  • RESERVED = 0h: Reserved (default)

Configuration Data Values
CONFIG_0_DATA             = 0x41;
CONFIG_1_DATA             = 0x41;
CONFIG_2_DATA             = 0x80;
CONFIG_3_DATA             = 0x04;
CONFIG_4_DATA             = 0x1F;
TOF_1_DATA                    = 0xE4;
TOF_0_DATA                    = 0x00;
ERROR_FLAGS_DATA    = 0x00;
TIMEOUT_DATA               = 0x23;
CLOCK_RATE_DATA       = 0x00;



Circuit Diagram:

1.Trigger signal                                                                                                               


2.Start Pulse From TDC1000



3.Stop Pulse from TDC1000

4.COMPIN signal from TDC1000                                                                                         

      

5.Signal From TX and RX pin of TDC1000       









  • Source Code:

    int main(void)
    {
      HAL_Init();
      SystemClock_Config();
      MX_GPIO_Init();
      MX_SPI1_Init();
      //Main on
      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
      //Crystal on
      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);
     RST_TDC1000();
      //TDC1000_Enable
      HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
      //TDC7200_Enable
      HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
      i=4;
      TDC_init();
      while (1)
      {
          //TRIGGER
          HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_SET);
          HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET);
          HAL_Delay(10);
          tdc1000_error_check();
      }
    }


    TDC1000 write function:

    void tdc1000_wr_config_reg (uint8_t rw, uint8_t reg, uint8_t config_reg_data) // write or read configuration register

    {

    uint8_t Data_Byte_Low = config_reg_data;

    uint8_t Data_Byte_High = 0x40|reg; // 0b01000000 to write to a register

    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_RESET);

    uint8_t address[2] = {Data_Byte_High, Data_Byte_Low };

    HAL_SPI_Transmit(&hspi1, address, 2, 1);

    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);

    }

  • Hi Vignesh,

    Thank you for posting to the Sensors forum!

    Unfortunately, I was not able to get to your thread today, but I should have some time tomorrow to take a look at it.

    Best,

    ~Alicia

  • Hi Vignesh,

    Are you able to share a read of the Config_1 Register value?

    For the TX_FREQ_DIV, section 8.4.5.1 Timing Control and Frequency Scaling (CLKIN) of the datasheet discusses how this can be calculated.

    Best,

    ~Alicia