Page 1 of 1

The order of the Conversion Frame results (Continuous Mode).

Posted: Thu Dec 12, 2024 3:39 am
by safocl
the documentation does not provide information about the order in case of a configuration with several ADC channels (Continuous Mode).
https://docs.espressif.com/projects/esp ... r-concepts

i use ADC with 2 number of the channels -- the conversion results of the different channels have some order in the frame?
I use filtering for different channels due to the algorithm.

Code: Select all

    std::vector< adc_digi_pattern_config_t > mDigiPatterns {
        adc_digi_pattern_config_t { static_cast< std::uint8_t >( adc_atten_t::ADC_ATTEN_DB_12 ),
                                    static_cast< std::uint8_t >( channel1 ),
                                    static_cast< std::uint8_t >( unit ),
                                    static_cast< std::uint8_t >( adc_bitwidth_t::ADC_BITWIDTH_12 ) },
                                    
        adc_digi_pattern_config_t { static_cast< std::uint8_t >( adc_atten_t::ADC_ATTEN_DB_12 ),
                                    static_cast< std::uint8_t >( channel2 ),
                                    static_cast< std::uint8_t >( unit ),
                                    static_cast< std::uint8_t >( adc_bitwidth_t::ADC_BITWIDTH_12 ) }
    };
    
    mAdc.configure( mDigiPatterns, SamplingRateHZ, ADC_CONV_SINGLE_UNIT_1, ADC_DIGI_OUTPUT_FORMAT_TYPE1 );


                mAdc.read( std::as_writable_bytes( dataSpan ), std::chrono::milliseconds( ADC_MAX_DELAY ) );

                auto channel_1_digies = dataSpan | std::views::as_const | std::views::filter( [ channel1 ]( auto & el ) {
                                     return el.type1.channel == channel1;
                                 } );

                auto channel_2_digies = dataSpan | std::views::as_const | std::views::filter( [ channel2 ]( auto & el ) {
                                      return el.type1.channel == channel2;
                                  } );
does this need to be done?

Re: The order of the Conversion Frame results (Continuous Mode).

Posted: Thu Dec 12, 2024 8:39 pm
by MicroController
does this need to be done?
If the frame size in bytes is not an integer multiple of (SOC_ADC_DIGI_RESULT_BYTES * pattern_num) the offset of each channel's result will change from one frame to the next.
You shouldn't have to filter every single sample though, because they should come alternating between the channels. So if result[x].channel == channelX, then channelX results should all be found in result[x + pattern_num * i] for i >= 0.

Re: The order of the Conversion Frame results (Continuous Mode).

Posted: Thu Dec 12, 2024 10:12 pm
by safocl
does this need to be done?
You shouldn't have to filter every single sample though, because they should come alternating between the channels. So if result[x].channel == channelX, then channelX results should all be found in result[x + pattern_num * i] for i >= 0.
I can't find such a guarantee in the documentation -- will this always be true?