Multi-Channel ADC with STM32 using DMA and Interrupt- Multiple Analog Sensors

Ғылым және технология

Learn how to use Multi Channel ADC with STM32 Microcontroller. We’ll program ADC to read multiple ADC channels of STM32 Nucleo board. This project uses DMA and Interrupt along with ADC to sample multiple sensor data. In the end, we’ll measure light intensity using LDR and variable resistor using POT as an analog sensor.
[SUPPORT]
►► Try the world's most trusted PCB design software, Altium Designer with 365, for free and 25% off your purchase: www.altium.com/yt/binaryupdates
►► Free search engine for the best quality components from Octopart: octopart.com/
►► Learn about Altium 365, the electronics product design platform that unites PCB design, MCAD, data management, and teamwork: www.altium.com/altium-365
[RESOURCES]
►► Need Help? To Learn Embedded Systems: courses.binaryupdates.com
►► Single Channel ADC: • How to use ADC in STM3...
[TIMESTAMPS]
00:00 Introduction
00:16 Altium Free Trial
00:47 Create new project
01:28 Configure Multi-channel ADC
03:04 Configure DMA in ADC
03:48 Configure NVIC Interrupt
04:30 Configure UART
05:04 Write code for ADC Multiple Channel
15:03 Connect LDR and POT with STM32
16:26 Upload the code on STM32 MCU
16:42 read multiple analog sensor values
18:05 outro

Пікірлер: 37

  • @danielcarpio4302
    @danielcarpio430211 күн бұрын

    Very nice, I dont need to make the video faster because you speak on a very reasonable speed.

  • @lucdrouin2625
    @lucdrouin26257 ай бұрын

    Excellent work, very clear, structured and informative presentation on a popular topic for STM32. Congratulations Sir.

  • @BINARYUPDATES

    @BINARYUPDATES

    7 ай бұрын

    Thanks you! I'm glad you enjoyed this STM32 tutorial. Best wishes!

  • @usmantariq1611
    @usmantariq16117 ай бұрын

    Excellent explained

  • @BINARYUPDATES

    @BINARYUPDATES

    7 ай бұрын

    Thank you Good luck and best wishes!

  • @javierlopez2022
    @javierlopez20223 ай бұрын

    Thanks a lot :)

  • @abelashenafi6291
    @abelashenafi62914 ай бұрын

    Thanks for the superb explanation. I learned quite a lot! But why do we need to reset the MCU every time we need to read the input voltage of each Analog pin? is there anyway where we could read the input voltage without resetting the MCU?

  • @gujarisantamanyugmai
    @gujarisantamanyugmai29 күн бұрын

    Nice Video Sir!!!

  • @BINARYUPDATES

    @BINARYUPDATES

    19 күн бұрын

    Thank you so much Santamanyu. Best wishes!

  • @unknown.477
    @unknown.4778 ай бұрын

    this multiple ADC doesn't work for me. I'm using nucleo G070rb . What may the reason..?

  • @romeshpg5041
    @romeshpg50414 күн бұрын

    How did you learn all this? I would also like to know this way. Would you be able to recommend any books or courses?

  • @dragon_619
    @dragon_6195 ай бұрын

    Brother Im using NUCLEO-L452RE so what I do if i want to make all 16 channels in active mode

  • @JoeBob189
    @JoeBob1892 ай бұрын

    at 7:12 you cast rawValues as a uint32_t pointer, however rawValues is a 16 bit array with a size of 2. This means that 32 bits in total are taken up by rawValues. You give your uint32_t casted rawValues a size of 2, which would tell the compiler that you have 64 bits allocated for this buffer. Wouldn't this be a vulnerability as it is *possible* to overwrite an unrelated address? Am I missing something here?

  • @bobby4976
    @bobby49764 ай бұрын

    thank you. anyway i am wondering, in line 126 (minute 10:20): why does the code has to iterate it until i i can understand if it is only 2 number conversions so that the code only does the iteration once since it is 2-1. say, for example, if we have 3 number of conversions, then the code there will have to iterate twice since it is 3 - 1. So reading adc chanel 0, 1, 2 twice?

  • @neudyvielma

    @neudyvielma

    2 ай бұрын

    Not only are you right about that, but there is a final line missing: reset the "convCompleted" variable to zero.

  • @javierlopez2022
    @javierlopez20223 ай бұрын

    I should use a DMA with a lot more samples (32, 64 ones) to work them after in order to use DMA advantages

  • @spencerclegg1606
    @spencerclegg16066 ай бұрын

    Why were the channel cycles set to 480 cycles instead of 3?

  • @BINARYUPDATES

    @BINARYUPDATES

    4 ай бұрын

    The 480 cycle is an optimal and most common choice to make sure we achieve resolution and accuracy while reading ADC value. If we choose 3 cycle then it will be very fast and it'll not allows us to read analog pins to maintain stable output from ADC channel of STM32

  • @spencerclegg1606

    @spencerclegg1606

    4 ай бұрын

    @@BINARYUPDATES Perfect, thanks. Yeah, I'd assume at some point it will not finish reading the ADC channels before the next cycle begins. So in cases where sample rate isn't critical it makes sense to select the slowest sample rate (480 cycles).

  • @khichadeneeta
    @khichadeneeta2 ай бұрын

    sir please make the video on SPI and I2C

  • @BINARYUPDATES

    @BINARYUPDATES

    2 ай бұрын

    Hi Khichadeneeta, I'll try to find time soon to finish making videos on using I2C and SPI peripheral to interface different sensors with STM32 Microcontroller. Thanks for your patience. Best wishes!

  • @CAN_MIKE
    @CAN_MIKE4 ай бұрын

    Hello, I don't understand why you have to reset the board to obtain a new value from the ADC, in theory the DMA ADC would have to do it

  • @BINARYUPDATES

    @BINARYUPDATES

    4 ай бұрын

    Hi Mike. you're right to make this multiple ADC with STM32 short I did conversion in while loop. Otherwise to avoid press RESET button I'll have to add few more lines on code. To keep video short I prefer this way of reading multichannel ADC in video lesson.

  • @abelashenafi6291

    @abelashenafi6291

    4 ай бұрын

    @@BINARYUPDATES Hey man, can you please add the few lines of code to avoid resetting the MCU all the time and see the values change in real-time? This would be really really appreciated. Regardless, you just earned a subscriber. Kudos

  • @neudyvielma

    @neudyvielma

    2 ай бұрын

    @@abelashenafi6291 To avoid the reset it is only necessary to reset the "convCompleted" variable to zero

  • @muhammadabdullah5660
    @muhammadabdullah56602 ай бұрын

    Kindly tell that why we are pressing reset button to see new value, why don't we get new value automatically. I understood everything it was informative video but this Question kindly answer. Anyone can tell me i need the answer i am learning this.

  • @itayjc1
    @itayjc13 ай бұрын

    how come you're not resetting the flag after the blocking while loop?

  • @JoeBob189

    @JoeBob189

    2 ай бұрын

    Because he's only doing one reading from the ADC. If you check his code, he never does another conversion. He is manually resetting the board to force another conversion. No need to reset the flag if it is only used once.

  • @woldecosgrove
    @woldecosgrove8 ай бұрын

    Nice video, can u share the code and instructions?

  • @whiteknighte
    @whiteknighte9 ай бұрын

    Please give me a link to the previous video on the stm32

  • @BINARYUPDATES

    @BINARYUPDATES

    9 ай бұрын

    Hi Whiteknighte, the video of Single channel ADC is in description section. Also, check entire playlist of STM32 Nucleo Board. Thanks!

  • @ahbushnell1
    @ahbushnell13 ай бұрын

    Good job. But slowwww down.

  • @OndrejPopp
    @OndrejPopp5 ай бұрын

    I haven't seen a schematic, but from the "wiring explanation" I got the impression that you are feeding the ADC input from 5V and not from 3V3. You have to be careful with that, because not every input of the micro controller is 5V tolerant.... And if you use one that is not, it may get damaged due to the 5V... So, actually I just checked on the stm32 forum : 5V tolerance does not apply to analog inputs at all, and you should not go beyond min(VDDA, VREF+) +0.3. VDDA and VREF+ are on the nucleo boards I have, Nucleo-743ZI2, equal to VDD_MCU which is dependent on a jumper setting and is either 3V3 or 1V8.... so be careful with that, and check the board schematic to see what VDDA and VREF+ actually are on your board, most likely 3V3 with the standard jumper setting like on the one I have.

  • @wavemusic6386
    @wavemusic63867 ай бұрын

    I have problem with line while(!convCompleted); this 'while' clause does not guard... [-Wmisleading-indentation] main.c This code working only one time. What can i do?

  • @BINARYUPDATES

    @BINARYUPDATES

    7 ай бұрын

    The code is written to print ADC value only once using Single conversion. So when we press RESET button then only next ADC conversion happen. It's because of the use of interrupt in code. if you make ADC conversion code in while loop then it will print continuously in continuous conversion mode instead of single conversion mode. I hope this may help you. Good luck and best wishes!

  • @OndrejPopp

    @OndrejPopp

    5 ай бұрын

    Actually, while(!convCompleted); means : "loop until convCompleted becomes true", and there are no additional statements needed, and the semi-colon at the end means an "empty single statement". You can have a single statement after a control structure, such as a while or an if, without the need of curly braces {....} which is called a compound statement, if there is only one or an empty statement following it. So while(cond) stat; a control structure with a single statement, is equivalent to while(cond) {stat;} and while(cond); a control structure with an empty statement is equivalent to while(cond){}. This short form without the curly braces is more convenient to write, but can be ambiguous and a source of very subtle mistakes and that is why the compiler checks for this. For example while(cond) ; {.....} means : a while loop with an empty statement, (like in this code) followed by an "unguarded" compound statement. But maybe there is a typo in the code and what was actually meant was while(cond) {.... }. This can happen because while typing you are used to put a semi-colon at almost every line and so a mistake like this is easily made and very hard to track down. And that is why the compiler warns about this, because it can not know what was actually meant. But the construct here is correct, but writing it like while(!convCompleted){} is more readable and will silence the compiler ⚠️. P.S, because the compiler warns about "misleading identation" maybe if you write it like this, while(!convCompleted) ; So putting the semi-colon on the next line, and indent it, will silence the compiler as well. But you need to try that, most of the time "white space" is ignored so maybe this does not work, but using empty curly braces, so while(cond){} should always work.

  • @MohammedAltowayti
    @MohammedAltowayti4 ай бұрын

    I'm using STM32 NUCLEO-F411RE chip... Can you help me write a code to make it capture an image using OV2640 and store it in pc folder?

Келесі