*Exploring the ADC of the CH32 Microcontroller: Single and Multi-Channel Acquisition* * *0:05** ADC Overview:* The CH32 microcontroller features 10 ADC channels: 8 external (accessible via GPIO pins) and 2 internal. The ADC covers the full voltage range (0 to 3.3V in this case). * *1:33** Single Channel Acquisition:* The video demonstrates how to initialize and configure the ADC for single channel acquisition. It focuses on reading voltage from channel 2, which is connected to GPIO pin PC4. * *10:09** Printing ADC Voltage:* A function `print_ADC_voltage` is created to retrieve the raw ADC value and convert it to a human-readable voltage format. * *11:38** Voltage Calculation:* The function `calculate_voltage` converts the raw ADC value to voltage using the formula: `(Vref * ADC_bits) / 1024`. * *17:49** Oversampling for Higher Resolution:* The video explains how oversampling can improve the effective resolution of the ADC. By averaging 16 samples, the effective resolution can be increased from 10 bits to 12 bits. * *23:45** Implementing Oversampling:* A function `get_oversampled_ADC_reading` is implemented to perform oversampling and return the averaged ADC value. * *29:34** Multi-Channel Acquisition:* The video demonstrates how to configure the ADC for multi-channel acquisition using DMA (Dynamic Memory Access). * *35:46** DMA Initialization:* A function `initialize_DMA` is created to configure DMA for transferring ADC data to memory. * *44:09** Printing Multi-Channel Data:* A function `print_multichannel_ADC_data` is implemented to iterate through the ADC buffer and print the voltage readings for each channel. * *49:02** Resources and Support:* The video encourages viewers to visit the creator's website for code snippets, affiliate links to hardware, and to subscribe to the channel for future updates. I used gemini-1.5-pro-exp-0827 on rocketrecap dot com to summarize the transcript. Cost (if I didn't use the free tier): $0.03 Input tokens: 21448 Output tokens: 444
I am using CH32X035 and already have a 12bit resolution, but I need some more accuracy, can I use the same oversampling table you have mentioned in this video as a reference for better accuracy?
Hi! I don't know how common it is because I don't have too broad experience with different environments, but I know that, for example, the Arduino's environment can print float directly via the Serial.println() function. You can even pass another parameter to the function that controls the number of decimal digits.
Lovely Video, Thought at 17:10 the "%04d" is redundant because you already removed the whole number part of that number & multiplied it with 10,000 which would bring that decimal part 4 digits higher & then it's casted to an integer which would remove any remaining decimal points. So, For example this is what happens: 452.692821 -> 0.692821 -> 6928.21 -> 6928.
Thanks! Yes, in fact the multiplication with the casting already determines the number of digits and I do not need the "%04d". I kept it there as an "educational" part so people can see how to trim an integer number.
*Exploring the ADC of the CH32 Microcontroller: Single and Multi-Channel Acquisition*
* *0:05** ADC Overview:* The CH32 microcontroller features 10 ADC channels: 8 external (accessible via GPIO pins) and 2 internal. The ADC covers the full voltage range (0 to 3.3V in this case).
* *1:33** Single Channel Acquisition:* The video demonstrates how to initialize and configure the ADC for single channel acquisition. It focuses on reading voltage from channel 2, which is connected to GPIO pin PC4.
* *10:09** Printing ADC Voltage:* A function `print_ADC_voltage` is created to retrieve the raw ADC value and convert it to a human-readable voltage format.
* *11:38** Voltage Calculation:* The function `calculate_voltage` converts the raw ADC value to voltage using the formula: `(Vref * ADC_bits) / 1024`.
* *17:49** Oversampling for Higher Resolution:* The video explains how oversampling can improve the effective resolution of the ADC. By averaging 16 samples, the effective resolution can be increased from 10 bits to 12 bits.
* *23:45** Implementing Oversampling:* A function `get_oversampled_ADC_reading` is implemented to perform oversampling and return the averaged ADC value.
* *29:34** Multi-Channel Acquisition:* The video demonstrates how to configure the ADC for multi-channel acquisition using DMA (Dynamic Memory Access).
* *35:46** DMA Initialization:* A function `initialize_DMA` is created to configure DMA for transferring ADC data to memory.
* *44:09** Printing Multi-Channel Data:* A function `print_multichannel_ADC_data` is implemented to iterate through the ADC buffer and print the voltage readings for each channel.
* *49:02** Resources and Support:* The video encourages viewers to visit the creator's website for code snippets, affiliate links to hardware, and to subscribe to the channel for future updates.
I used gemini-1.5-pro-exp-0827 on rocketrecap dot com to summarize the transcript.
Cost (if I didn't use the free tier): $0.03
Input tokens: 21448
Output tokens: 444
Hi very informative video as always. I think for increasing the resolution you need to do Oversampling and decimation (not averaging) ??
Hi and thanks! I think both works, although averaging is more of an "effective increase". It helps increasing SNR.
I am using CH32X035 and already have a 12bit resolution, but I need some more accuracy, can I use the same oversampling table you have mentioned in this video as a reference for better accuracy?
Absolutely, it's a universal technique.
Interesting that the printf in this c stdlib doesn't support %f for printing floating point numbers. Is that common with embedded devices?
Hi! I don't know how common it is because I don't have too broad experience with different environments, but I know that, for example, the Arduino's environment can print float directly via the Serial.println() function. You can even pass another parameter to the function that controls the number of decimal digits.
Lovely Video, Thought at 17:10 the "%04d" is redundant because you already removed the whole number part of that number & multiplied it with 10,000 which would bring that decimal part 4 digits higher & then it's casted to an integer which would remove any remaining decimal points.
So, For example this is what happens: 452.692821 -> 0.692821 -> 6928.21 -> 6928.
Thanks! Yes, in fact the multiplication with the casting already determines the number of digits and I do not need the "%04d". I kept it there as an "educational" part so people can see how to trim an integer number.