# Direct force input during position control for haptics

**URL:** https://community.simplefoc.com/t/direct-force-input-during-position-control-for-haptics/7007
**Category:** developement
**Tags:** bldc, foc-algorithm
**Created:** [March 30, 2025, 8:33pm UTC](https://community.simplefoc.com/t/direct-force-input-during-position-control-for-haptics/7007 "2025-03-30T20:33:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Harry\_de\_winton](https://community.simplefoc.com/user_avatar/community.simplefoc.com/harry_de_winton/32/5013_2.png) [@Harry\_de\_winton](https://community.simplefoc.com/u/Harry_de_winton)
#### Post date: [March 30, 2025, 8:33pm UTC](https://community.simplefoc.com/t/direct-force-input-during-position-control-for-haptics/7007/1 "2025-03-30T20:33:12Z")

</div>

I have a BLDC motor being position controlled using Simple FOC for a haptic knob. While I want to position to be controlled I would also like to generate impulses (separate from the position control) to create “ticking”/“clicking” effects.

Currently I request rapid/large position changes to effect these results but this involves tricking/over coming the position/velocity control loops to generate the result.

However, directly requesting torque (current) outputs appears to be the most transparent method of generating impulses.

Is there a means of modifying the current request from the velocity\_controller before it enters the current control torque\_controller?

Or do I need to extend the library?

---

<div class="post-metadata">

### Author: ![dekutree64](https://community.simplefoc.com/user_avatar/community.simplefoc.com/dekutree64/32/3398_2.png) [@dekutree64](https://community.simplefoc.com/u/dekutree64)
#### Post date: [March 30, 2025, 9:16pm UTC](https://community.simplefoc.com/t/direct-force-input-during-position-control-for-haptics/7007/2 "2025-03-30T21:16:05Z")

</div>

Yes, motor.current\_sp is the velocity controller output, which is set in motor.move. You can modify it before calling motor.loopFOC (which is what updates the PWM outputs to the motor).

If you’re using TorqueControlType::voltage then you’ll need to set motor.voltage.q = motor.current\_sp as well. Or recalculate it taking into account the motor velocity if you’re using voltage-based current limiting (probably not necessary for a haptic knob).

If you’d like to understand why, open BLDCMotor.cpp and look in the function BLDCMotor::move. In the MotionControlType::angle and MotionControlType::velocity cases, after running the velocity PID it checks for TorqueControlType::voltage and calculates the voltage. That code really should be moved to loopFOC.
