Link

Options

SimpleFOClibrary has many options, and the following tables summarize the important ones, collected in one convenient place for your immediate reference.

Driver Options

Driver options are set before calling driver.init(), and normally never changed after intialization.

OptionDefault valueSupported onDescription
driver.pwm_frequencydepends on MCUBLDC, StepperPWM frequency, in Hz
driver.voltage_power_supply12VBLDC, StepperPower supply voltage in volts
driver.voltage_limitNOT SETBLDC, StepperHard limit on output voltage, in volts. Effectively limits PWM duty cycle proportionally to power supply voltage.
driver.intialized BLDC, StepperRead-only. true if initialized successfully, false otherwise
driver.enable_active_hightrueBLDCIf true, driver is enabled by writing ‘1’ to enable pin. If false, driver is enabled by writing ‘0’ to enable pin.
driver.dead_zone0.02BLDCDriver6PWMAmount of dead-time for each pwm cycle, as a proportion of 100% duty cycle. A float in the range [0,1]. Values under 10% make sense.

Motor Options

OptionDefault valueDescription
motor.controllerMotionControlType::torqueMotion control mode
motor.torque_controllerTorqueControlType::voltageTorque control mode
motor.motion_downsample0Set to values > 1 to reduce how often move() is executed compared to loopFOC(). On fast MCUs it makes sense to reduce how often move() gets called.
motor.phase_resistanceNOT SETMotor phase resistance. If set, used to calculate current limits based on voltage limits. Value in Ohms.
motor.KV_ratingNOT SETmotor KV rating, RMS value. Can also be set via motor constructor, where you can specify KV in RPM/V.
motor.phase_inductanceNOT SETmotor inductance, in H. Units Henry. Can also be set via motor constructor.
motor.voltage_limit12VGlobal voltage limit. Limits Q-axis voltage.
motor.current_limit2AGlobal current limit. Limits Q-axis current.
motor.velocity_limit20rad/sGlobal velocity limit. Value in rad/s.
motor.foc_modulationFOCModulationType::SinePWMFOC modulation mode.
motor.modulation_centered1 (true)1/True: centered modulation around driver.voltage_limit÷2 or 0/False: pulled to 0
motor.sensor_offset0Offset of motor zero to sensor zero. Can be used to make position 0 take on a specific motor orientation. For user convenience. Value in rad.
motor.voltage_sensor_alignmotor.voltage_limitLimits voltage (and therefore current) during motor alignment. Value in Volts.
motor.velocity_index_searchNOT SETLimits motor velocity during motor initialization. Give value in rad/s.
motor.zero_electric_angleNOT SETNeeded for FOC control. Normally set during motor FOC initialization. Can be stored and supplied as a parameter to motor.initFOC().
motor.sensor_directionNOT SETNormally set during motor FOC initialization. Determines sensor direction vs positive motor direction (can be opposite, depending how you connect your motor cables). Can be stored and supplied as a parameter to motor.initFOC().
motor.motor_statusFOCMotorStatus::motor_uninitializedRead-only. Tracks the motor initialization status. You can check it to see if initialization succeeded, calibration is complete, etc.

PID Tuning Options

OptionModes usedDescription
motor.PID_velocity.PAll closed loop modesVelocity PID controller P value. Varies by situation. Typical values are 0.2 to 0.6, but could be quite different.
motor.PID_velocity.IAll closed loop modesVelocity PID controller I value. Varies by situation. Typical values are 2.0 to 20.0, but could be quite different.
motor.PID_velocity.DAll closed loop modesVelocity PID controller D value. Normally set to 0. Typical values are 0, or a very low value like 0.001.
motor.PID_velocity.rampAll closed loop modesVelocity PID controller maximum change. Typical value 1000.0, set lower to limit accelleration.
motor.PID_velocity.limitAll closed loop modesVelocity PID controller output limit. Set to limit velocity to this maximum.
motor.P_angle.PClosed loop position controlAngle P controller P value. Varies by situation. Typical values are 10.0 to 20.0, but could be quite different.
motor.LPF_velocity.TfAll closed loop modesVelocity low pass filter time constant. Values larger than 0, max 1.0. The lower the value, the slower the effect of velocity changes from the sensor.
motor.LPF_angle.TfAll closed loop modesAngle low pass filter time constant. Values larger than 0, max 1.0. The lower the value, the slower the effect of angle changes from the sensor.
motor.PID_current_q.PTorque current controlQ-Axis current controller P value.
motor.PID_current_q.ITorque current controlQ-Axis current controller I value.
motor.PID_current_q.DTorque current controlQ-Axis current controller D value.
motor.PID_current_q.rampTorque current controlQ-Axis current controller maximum change.
motor.PID_current_q.limitTorque current controlQ-Axis current controller output limit.
motor.PID_current_d.PTorque current controlD-Axis current controller P value.
motor.PID_current_d.ITorque current controlD-Axis current controller I value.
motor.PID_current_d.DTorque current controlD-Axis current controller D value.
motor.PID_current_d.rampTorque current controlD-Axis current controller maximum change.
motor.PID_current_d.limitTorque current controlD-Axis current controller output limit.
motor.LPF_current_q.TfTorque current controlQ-Axis current low pass filter time constant.
motor.LPF_current_d.TfTorque current controlD-Axis current low pass filter time constant.