DMA for IR sensor only saves the ADC sample time. Not worth that much efforts to make it work.
そんなこともしていましたねえ．毎年何かしら意図せず面倒な半田付け作業をするはめになっているような気がします．でも今年の密度では空中配線もほぼ不可能．DMAは自由度低いですね．使い方がほぼ決まっているというか．間接的にでもどうにかならないかと思いましたがちょっと無理そうです．I want to sample at 8kHz for encoders and at 64kHz in total including photo sensors. So, A/D conversion and LED control processes are desired to be performed without CPU. DMA is a key to do this. I will use alternative method to send triggers to DMAC.
oh, I thought you only amplify your encoder sinusoidal signal to make it low resolution square wave to feed quadrature encoder module in STM32. So you are using STM32 to do some digital processing for sinusoidal input directly from your customized encoder to achieve more resolution? In this case having ADC continuously driving by DMA seems necessary. Did you use look up table or FPU to do the math? and how much CPU time that the math computation would occupy on every 1ms without counting the DMA ADC sampling time? how much encoder resolution that you ended up achieving?
For encoders, I just get square pulses using ADC as you think. But, encoder emitters are driven with pulse signal like photo sensors in order to reduce battery consumption. The pulse is controlled by write I/O port state in the register by using DMA trasfer.The sequence of my photo sensor and encoder sampling is as follows.1. Turn on LED for a photo sensor or encoder using DMA which is triggered by a timer.2. A/D conversion is performed, which is also triggered by the timer. Then, A/D data is trasfferd by DMA.3. Turn off LED using DMA triggered by the timer.There are 18 teeth in my encoder, and so, 8kHz is necessary to obtain correct square waves at the target maximum speed, which is 4 m/s.
thanks for your detailed explanation. That looks like a lot of trade off in order to reduce the weight by using customized encoder. If the output is amplified to square wave through op-amp, why don't use digital input instead of ADC? Or you can slower the encoder IR LED current to keep it on all the time then use quadrature encoder module in stm32 to pick up amplified square wave automatically? I bet you did such a test already. Or you can do sinusoidal signal process on every control cycle between phase A and B as long as the it won't exceed the 1/4 of the period of the sinusoidal wave. Anyway, your method looks very challenge to me :DI would rather to use magnetic encoder with extra weight by adding extra battery to compensate the lose of driving force.
The output signal of photo transistor is actually amplified, but the signal is still small. So digital input port cannot detect a rising or falling edge. This is because I use ADC to detect the pulses of the encoder. Although this encoder is very challenging, its small size and weight is large benefit.
no wonder you can't amply it to square wave. Since you used such a system to detect forward speed by fusion encoder and accelerometer data. Would you mind share the equation that you combine the encoder and accelerometer data into a usable speed for controller? Thank you.