Post Go back to editing

switching between channels in the fastest way possible

Thread Summary

The user is experiencing slow data acquisition when reading six channels from a fabricated six-axis force/torque sensor using the AD7794 ADC with an STM32 microcontroller. The issue is resolved by configuring the ADC in continuous conversion mode and optimizing the channel switching process in the code, reducing the full scan time across six channels to a more acceptable level. The user confirms that the suggested changes significantly improved the performance.
AI Generated Content
Category: Software
Product Number: AD7794
Software Version: Keil

Hi i have fabricated a six-axis force/torque sensor using strain gauges and for data acquisition process i used AD7794 ADC in order to read all six channel each related to a Wheatstone bridge of my strain gauges.

I have a BIG problem and i need to fix it. I have created a PCB already and installed it on my sensor i use STM32 as my microcontroller and i use Keil IDE for programing and changing the hardware is not an option for me.

I know that AD7794 does not have a auto switching mode for reading all channels. Therefore i try to switch channels in the STM32 programming code but the problem is that reading all channels takes so much time and i believe it is because of my programming. It takes approximately 1.2 seconds to read all channels and this is very slow for what i plan to do.

In the datasheet it says the maximum sampling speed is 470Hz but clearly i am reading all channels much slower. Can someone tell me how to fix my issue? 

I need to read all channels as fast as possible and show them on the output (i use UART).

Can someone tell me how to fix my problem and what code should i write and how i configure it ?(changing the hardware and the circuits is not an option because the PCB is already fabricated and is not changeable) 

Thanks. 

  • Hi  ,

    Have you configured the ADC with CHOP ENABLED or DISABLED?

    As the ADC powers up and performs a single conversion, you should take note that the oscillator requires 1 ms to power up and settle. The ADC then performs the conversion, which takes a total time of conversion time plus settling time when chop is disabled. With chop enabled, the settling time is two times the conversion time.

    So, you may want to configure the ADC with CHOP DISABLED. Can you please confirm if have set MR3 to MR0 of the MODE REGISTER to 0001? 

    Could you share your configuration settings if possible? 

    Thanks and regards,

    Rod

  • Hi Rod,

    thanks for your reply i really appreciate your helping and thanks for your time.

    1- i am sure that i have CHOP disabled in my code, i set the mode register to 0x0211.

    MD2-MD0 = 000 which is continuous conversion mode (i know using single conversion mode might be better for my work but i really struggle doing that i could not succeed)

    AMP-CM enabled (bit 9=1)

    CHOP Disabled (bit 8 =1)

    FS bits =  0001 meaning 470Hz sampling based on the datasheet 

    the exact code is : 

    uint16_t mode_value = 0x0211;
    write_register(MODE_REG_ADDR, mode_value);

    2- MR3 to MR0 : yes as you said it is 0001

    3- Oscillator startup delay: I do perform a reset on the ADC at startup using 32 clock pulses (0xFFFFFFFF over SPI), and I insert a 2 ms delay afterward (HAL_Delay(2);) before proceeding. So I believe I am accounting for oscillator settling at power-up.

    4-  now i read 6 channels like this: 

    Writing to the configuration register to select the channel

    Rewriting the mode register (again with 0x0211)

    Waiting for RDY bit to go low

    Then reading the data register

    but, the full scan across 6 channels takes about 1.2 seconds, which is far from the performance i need.

    5- i select the channels like this: 

    void select_channel(uint8_t channel, uint16_t config_value)
    {
    config_value &= 0xF000; // clear previous channel/gain bits
    config_value |= (0x07 << 8); // Gain = 128
    config_value |= (channel & 0x0F); // Channel select
    write_register(CONFIG_REG_ADDR, config_value);

    // Wait for conversion to complete
    while (read_register(STATUS_REG_ADDR) & 0x80) { }
    }

    i think these cover's your questions. I am really looking forward to your advice to make my data acquisition process as fast as possible.

    Again thanks for your time i sincerely appreciate your help.

    i can also provide my full code and settings.

    Thanks again and best regards.

  • hi again  

    I have replied again as a reminder to tell you i look forward to your help if you be kind ad put your time.

    i still suffer from the same problem and i have issues with the speed of my work

    Regards

  • Hi  

    Apologies for missing the thread. 

    Have you tried exploring the continuous read mode? 

    Since you set the ADC inn continuous conversion mode, the ADC continuously performs conversions and places the result in the data register. With this, you can read these conversions by placing the device in continuous read mode whereby the conversions are automatically placed on the DOUT/RDY line when SCLK pulses are applied. 

    You can do this rather than writing to the communications register each time a conversion is complete to access the data and see if it improves your setup.

    i can also provide my full code and settings.
    • Yes, this would be great. It would help give a wider perspective on how the ADC was configured and is being used. 

    Thanks and regards,

    Rod

  • Hi  

    I have applied your suggestions to my ST code and now it works perfectly and satisfies my desires 
    i really appreciate your effort and thanks for your time 

    Regards.

  • Hi  ,

    That's good to know, we appreciate your engagement. If you have any further questions, please feel free to post them on our forum, we're here to help.

    Thanks and regards,

    Rod