2023-04-09 12:52 PM
Hello All,
I am reasonably new to STM and could use some advice.
I am looking to sample 4 ADC channels.1 analog signal represents the current passing through a motor and needs to be sampled 2k times per half cycle (60hz). Towards the end of the half cycle, my current is negotiable, and it can be ignored for my purpose, so I want to set it up to trigger off my firing angle and stop after collecting 2k samples (approximately 8mS with adjustment of sampling time). After that sampling is complete, and the time is the last portion of the half cycle (approximately 0.33mS of the 8.33mS), I want to collect 1 sample after another of the other 3 channels. (I.e., 1 sample of another channel (Line Voltage), then one sample on another channel (potentiometer), and finally one sample of another channel (PCB board temperature sensor)).
I have a few ideas to set this up, but I thought I would see what the experts recommend.
I have already set up PA4 to collect 2k ADC values using DMA once starting the DMA, and it stops when all the samples have been collected, so that is working properly. I was thinking about setting up the other ADC channels to start sampling after this, but it would require the ADC to be reset and then set back when complete. I also thought about injecting channels for the lower priority ADC sampling but not triggering them until all 2k samples have been completed. There are also a few other options in the manual, but I wanted to reach out and see what everyone think before spending days researching to pick the best option.
Any advice would be appreciated.
Bullet points:
* (PA4) ADC channel sampling 2k in ~8mS when triggered. (high priority)
* (PA0) ADC channel sampling 1 time after the above samples are collected. (medium priority)
* (PB0) ADC channel sampling 1 time after the above samples are collected. (medium priority)
* (PA5) ADC Channel sampling 1 time after the above samples are collected. (low priority)
Note: I am only using Keil and the reference manual to program the STM32F103 MCU. I am not using any of the graphical design tools for software setup (I.E., CubeMX, CubeIDE, or any like that).
Thank you!!!
2023-04-09 07:22 PM
Using 2 ADCs would avoid having to reconfigure.
2023-04-10 05:53 AM
Hello @Community memberpiering
First let me thank you for posting .
One possible solution to your problem is to use the ADC regular group and the ADC injected group to sample the four channels with the desired priorities.
Here's a high-level overview of how you can implement this solution:
You can adjust the sampling time for the regular group by configuring the timer trigger accordingly. You may also want to set up the ADC to use the lowest possible sampling time for the injected group channels to minimize the time delay between the regular group and injected group conversions.
Thx
Ghofrane