ADC readings fast as possible

Hi guys, I have a project where I'm controlling a voice coil motor with a linear encoder and I need to read the current of the motor as fast as possible. Knowing how fast can I read the current will determine how fast my current loop will be (I hope it's close to 10us).

I've been reading the STM32H747XI Reference manual and I've seen that I can set the ADC to differential mode (with pins A0 and A1) and read it in continuous mode with DMA.

What I expect is that ADC reads then DMA writes the value to a register and I access that register using a pointer. So every Interrup cycle I'll read the register copy it to a variable and do my calculations.

The question is: is it possible and if so, how can I do it?

DMA is DIRECT MEMORY ACCESS, no register involved. Does your Arduino support DMA? Have you used it before?
You do NOT want to read as fast as possible. You only want to read if there is NEW data. You DO NOT want the device to be changing memory while you are reading it.

1 Like

Have you taken a look at this?

If you can read audio you can probably do what you want fast enough :slight_smile:

I don't know what is the max but the example is at 16kHz

Hi Paul, I think the Arduino Giga supports it. I've never used it before so I'm lost as I can be.

How could I do it? I'd like to read 1-2 MSPs from the ADC if that was possible.

I've read arduino_advancedanalog but it doesn't mention maximum sample rates nor how to configure it so that I can measure positive and negative currents using a shunt resistor. Using A0 and A1 (ADC12_INP_4 and ADC12_INN4), I should be able to read positive and negative voltages.

I think I'm asking too much and I should fully read the "RM0399 Reference manual", set the bits/registers and check the flags one by one.

Yes, looks like the microprocessor used in the Arduino Giga does support DMA in three versions. Now, whether the Arduino commercial implementation supports it is another question you will have to support.
Hopefully you have an attention span lasting years!

An ADC sample rate of 100kHz is no problem for a Teensy from PJRC, and you have the advantage of using libraries that have been tested, and actually work.

I guess the only option I have is to read "RM0399 Reference manual" and test. Thanks for the replies guys, I appreciate it.