This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

multiple adc +multiple pwm

Hi, i am using nrf52840 development kit , four servo motor . using 15.2 sdk version

here i am controlling the angle using adc values , i am done with one servo motor . pwm+adc. Now i need to control the angle for all the four motors , how to do that ? how can  i add the four adc channels . 

Parents Reply Children
  • Thank you so much Edvin, for your support. i got .. my mistake i didn't multiply the number of channels.. 

    can you explain me a bit , "SAMPLES_IN_BUFFER" = n*number of channels, where n=1,2,3,4,...by multiplying the number of channels what will happen ?

    and more what is the m_buffer_pool[0], m_buffer_pool[1]?  i am confused between these two

  • Hello,

    The reason I suggested SAMPLES_IN_BUFFER = n*num_of_channels is because the saadc buffer doesn't know what channel the different samples comes from.

    E.g. if you have SAMPLES_IN_BUFFER = 5, and use two channels, then in the first SAADC callback event, buffer[0], buffer[2] and buffer[4] will contain samples from channel 1, while buffer[1] and buffer[3] will contain the samples from channel 2.

    But in the next event, they will be shifter:

    Buffer[1] and buffer[3] will contain samples from channel 1, and buffer[0], [2] and [3] now contains samples from channel 2.

    If you set the SAMPLES_IN_BUFFER = 4, then buffer[0] and buffer[2] will always contain samples from channel 1, and buffer[1] and buffer[3] will always contain samples from channel 2.

    m_buffer_pool[0] and [1] is mostly in use by the ADC internally. The reason it is two of them is that once one sampling is done, it can pass one of the buffer, and start sampling on the other one immediately. Nothing that you need to worry about. The actual values from the samples you will find in the callback, where it is printed to the log in the example.

    Best regards,

    Edvin

Related