How does simplefoc internally sets or limits the Voltage?

Hi! I just came across the set-up code for using SimpleFoc with the DRV8302 driver board, and i noticed these lines:

  // configure driver
  driver.voltage_power_supply = 12;

How does internally the code limits or sets the voltage for the motors?

Let’s say my power supply is set to 33V, but I want to set the max to 30V? Is it possible? How does it work in the driver internally? It limits the max PWM? Does it measure the real voltage?


Yes, this is correct - the voltage output to the motor phases is modulated using the PWM signals to the driver. So by limiting the PWM duty cycle we can set a voltage limit in software.

No, not unless you add your own code to do so. So if the actual PSU voltage differs from the configuration of the driver, all voltages calculated by SimpleFOC will be wrong in proportion to this difference.