Current control, update time

Good day folks,

so I want to implement a current control for a BLCD Motor. The measurement of the current works fine. I implemented a PI Controller. Currently the updated time is about every 3ms, so around 300Hz. For a inner control loop this is way to long. I am using a uno, is there a better and faster arduino board or would you recommend any other board for faster controlling?

Thanks you very much

What I would recommend is that you post the code that is too slow. Perhaps there is something it is doing that is not necessary, which could be removed to speed things up.

I don't know what you mean by "updated time". Perhaps an extra d slipped in there, and you meant "update time".


yes I meant the update time the loop needs.

void loop() {
current_mA = ina219.getCurrent_mA();
shuntvoltage = ina219.getShuntVoltage_mV();

What baud rate are you using? Indeed, why are you serial printing anything at all if speed is an issue?

How often does the PID actually compute anything? - the version I use defaults to a SampleTime of 100ms.

Hey, baud rate 115200 I use serial.print to get the setpoint and the real value to evaluate the parameters of the control. The PID sample time is set to 15ms.

jacko91: The PID sample time is set to 15ms.

Given this, what's the issue with loop taking 3ms? Do you have a lot more to do that hasn't been written yet? If so, you could do the analogRead and associated calc less frequently - there's no point doing it until the PID needs it. Also, IIRC, I think you can do the analogRead asynchronously.

To answer your original question though, a Teensy or Due run significantly faster than an Uno.


yes you are right, it makes no sense to run it more often then the controller. What do u mean with IIRC? And thanks for the teensy tip, I always thought it was a small and slow arduino, but looking at the specs it looks awesome.

IIRC == If I recall correctly

Hey, is there any way I can get access to you code and list of hardware? I'm doing something close to your project.