AdaptiveGrip is a gripper that senses through its motor: no force sensor, no position feedback. A Renesas RA6T3 reads the motor's phase currents 20,000 times a second, stops the finger within milliseconds of touching an object, and tells from how the load builds up whether it is rigid or soft, no external processing needed
Introduction
AdaptiveGrip is a robot gripper with no force sensor, no tactile pad and no position sensor in its control loop. A Renesas RA6T3 microcontroller reads the three phase currents of a small brushless motor 20,000 times a second, works out from them how hard the motor is being held back, stops the jaw within a few milliseconds of touching an object, and tells from the way the load builds up whether the object is hard or soft. This page covers how the control and detection method was developed, the bench tests that proved or broke each step, and a 3D-printed geared finger that grips with it.
Overview
A gripper that handles unknown objects has to know two things: when it has touched something, and how hard it may squeeze. The usual answer is more hardware in the fingers: a load cell, a tactile pad, a current-sense resistor plus an encoder. Each one adds wiring through a moving joint, cost, and something else that needs to be monitored. AdaptiveGrip takes the opposite route. The motor that closes the jaw is also the sensor. A brushless motor driven with a known current behaves like a spring between the rotating magnetic field and the rotor: the more the load holds the rotor back, the further it lags behind the field. That lag, the load angle, can be calculated from the phase currents and the voltages the controller is already applying. Nothing has to be added to the gripper. With those measurements, the firmware should do three things:
- Detect contact and stop the jaw before the motor loses step
- Classify the object as rigid or soft.
- Hold the object at a chosen current with a torque suitable for the object classification.
The project runs on a Renesas FPB-RA6T3 board. It was developed first in simulation, then on a bare motor with my hand as the object that played roles as a very firm grip and a loose slip until fully stopped simulating different objects. An encoder was fitted only as a witness to check what the estimator claimed and was watching during the entire evaluation. A printed screw vise I already had came next and showed that the mechanism with large friction can overpower the own motor torque and make the detection unreliable.
The gripper mechanism was rapdly prototyped as a single printed finger behind two stages of gears, designed for this motor, and finally able to tell rigid blocks from soft ones.
I put the weight of this write-up where the work was: the experimentation of a control and detection method, and the bench tests
From the proposal to the build
My proposal for this challenge first described a hydraulic gripper: two syringe actuators moving the jaws, a BLDC-driven master syringe, a pressure sensor for force, tactile sensors for slip, and a set of Renesas analogue and power parts around the RA6T3. My previous knowlege on peristaltic pumps driven by brushless motors could be very helpful on that, and I was wondering if the encoder used on that project could be reliably ommited.
What I built is different in its mechanics and have a simpler parts list retaining the main purpose so we can fit the build in the timeframe available: a gripper that detects contact, characterises the object and adapts its grip, with the RA6T3 doing the motor control and outputs the feedback for the monitoring system.
The changes were shaped by the constraints: I would use only parts that plug together directly, with no custom board and I would solve the control problem with the FPB-RA6T3 alone, trying to get from the motor itself what the proposal took from extra sensors.
Hardware and Firmware overview
Renesas FPB-RA6T3 - motor-control MCU (Arm Cortex-M33, 200 MHz, FPU), on-board J-Link debugger for data output visualization
SimpleFOCMini v2 - TI DRV8316 three-phase driver, 3 PWM inputs, one current-sense output per phase (0.15 V/A)
2804 gimbal motor - Brushless, 7 pole pairs, 0.4 A rated, 1 A maximum, about 0.03 Nm
MT6701 encoder board - Magnetic encoder under the motor, quadrature output, 4096 counts per turn
Bench supply - 12 V for the bare-motor work, 15 V on the mechanisms
Printed finger mechanism - A single finger on a pivot behind two stages of printed spur gears (30:1), closing against a fixed wall; my own design, modelled as a FreeCAD script
The wiring is eleven signal wires. Three PWM outputs from the RA6T3's GPT timers go to the driver inputs. Three current-sense signals and the divided supply voltage come back to four ADC inputs. One pin enables the driver. The encoder's two quadrature lines go to a spare timer (GPT5) that counts them in hardware.

What makes the RA6T3 a good fit for this project is how little glue the job needs:
- The GPT timers generate centre-aligned three-phase PWM at 20 kHz.
- The same timer triggers the ADC through the Event Link Controller at the centre of the low-side conduction window, when the driver's current-sense outputs are valid. The three phase currents are captured together by the sample-and-hold inputs. No software is involved in the timing.
- The Port Output Enable (POEG) unit can force all PWM outputs off without waiting for code, so a firmware fault cannot leave the motor energised.
- A 200 MHz core with an FPU runs the whole current loop, the load-angle estimator and the contact reflex in floating point could fit inside every 50 µs PWM period.

The loop in the upper half closes once every 50 µs, and only its last step is code: the timer asks for the conversion, the event link passes the request on, the ADC freezes all three currents at the same instant, and the interrupt at the end of the scan runs the control pass. The duties it computes wait in the timers' buffer registers until the next reload. POEG sits on the way out and can switch the outputs off without any code running.
That last step is one interrupt handler in the board port. By the time it runs, the conversion is over: it only reads the four results (in this wiring the signals of phases V and W arrive swapped), asks POEG whether the outputs were switched off behind its back, and calls the control pass, Motor_CurrentIsr, shown further down under Firmware. The pass ends in Pwm_WriteDuties, which hands the three compare values to the timers' buffer registers.
/* hal_ra6t3.c - the interrupt at the end of every ADC scan (excerpt) */
void adc0_callback(adc_callback_args_t *p_args)
{
if (ADC_EVENT_SCAN_COMPLETE != p_args->event)
{
return;
}
s_period_count++;
s_time_us += (1000000u / AG_PWM_FREQUENCY_HZ);
/* ... */
ag_hal_adc_frame_t frame;
uint16_t v = 0u;
(void) R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_0, &v); frame.raw[0] = v;
(void) R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_2, &v); frame.raw[1] = v;
(void) R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_1, &v); frame.raw[2] = v;
(void) R_ADC_Read(&g_adc0_ctrl, ADC_CHANNEL_4, &v); frame.vbus_raw = v;
/* ... black-box trace of the raw samples ... */
/* A POEG disable request that we did not issue ourselves is a hardware trip. */
poeg_status_t st;
if ((FSP_SUCCESS == R_POEG_StatusGet(&g_poeg0_ctrl, &st)) &&
(st.state & (POEG_STATE_PIN_DISABLE_REQUEST | POEG_STATE_GPT_OR_COMPARATOR_DISABLE_REQUEST)))
{
s_hw_trip = true;
}
frame.hw_overcurrent = s_hw_trip;
if (s_init.current_isr != NULL)
{
s_init.current_isr(&frame, s_init.current_ctx);
}
/* ... how far into the period the pass ended, for the timing figures ... */
}
static void Pwm_WriteDuties(void)
{
three_phase_duty_cycle_t d;
for (uint8_t ch = 0; ch < 3u; ch++)
{
uint32_t high = s_duty_counts[ch];
/* ... keep within 1 .. period - 1 ... */
d.duty[ch] = AG_PWM_PERIOD_COUNTS - high;
d.duty_buffer[ch] = d.duty[ch];
}
(void) R_GPT_THREE_PHASE_DutyCycleSet(&g_three_phase_ctrl, &d);
}
How a motor becomes a sensor
Lets start with the breakdown of each logical component of the system:

The top row is an ordinary current-controlled drive. The bottom row is what turns it into a sensor: the same voltages and currents give the back-EMF, the back-EMF gives the load angle, and the load angle both stops the jaw and classifies the object.
The motor is a poor choice on paper but it was the most readily available, and I kept it for that reason. The torque is tiny (0.03 Nm), its winding measures 3.9 Ω against a flux linkage of only 3.5 mWb, so its back-EMF is a few hundred millivolts on top of a resistive drop of more than a volt. If sensing through the motor works here, it can prove that very small signals on the back EMF can be used to estimate with adequate precision the motor position and bigger motors could scale this algorythm better.
Drive: a rotating field the rotor has to follow
The firmware does not try to know where the rotor is. It regulates a current vector of fixed amplitude (0.3 to 0.5 A) and rotates it at the speed the motor should move. The rotor's magnets should follow that field the way a compass needle follows a magnet in a called synchronous or I/f drive. As long as the rotor has not slipped a pole, the commanded field angle is the motor position and then, after the 30:1 reduction taken into account, the jaw position, all inferred with no position sensor. The "no slip" rule is the main reason that a low friction mechanism is the best approach.
Two PI regulators hold the current vector in the rotating (d/q) frame, 20,000 times a second. A plain I/f drive is badly damped and the rotor swings around the field like a pendulum, so a small correction to the field speed, taken from the high-passed load angle, calms it down.
In code the drive is inside the 20 kHz pass. Putting the whole current on the field's own axis (id_ref = i_mag, the other axis at zero) is what makes it a synchronous drive. The damping follows: the load angle minus its own slow average is the swing, and it is fed back into a small, bounded offset of the field angle. The functions called here are shown whole under Firmware.
/* motor.c - Motor_CurrentIsr(): the drive and its damping (excerpt) */
SyncField_IsrUpdate(&m->sf);
/* The field angle is the position reference plus a small, bounded damping offset (never a drift). */
float theta_cmd = AG_WrapPi(SyncField_ThetaE(&m->sf) + m->damp_offset_e);
float omega_cmd = SyncField_OmegaE(&m->sf);
float i_mag = SyncField_Current(&m->sf);
/* ... */
/* Synchronous drive: current vector on the commanded axis (id = I, iq = 0). */
float id_ref = i_mag;
/* ... */
v_ab = FOC_Update(&m->foc, &m->adc.phase, theta_cmd, id_ref, 0.0f, omega_cmd, v_max);
Motor_ApplyVoltage(m, v_ab, vbus);
/* ... the load-angle estimate of this period: delta_est ... */
/* I/f damping. The synchronous drive is a lightly damped spring (torque ~ sin(load angle)); feeding the
* load-angle deviation back into the field speed adds the missing damping term (the same idea as the
* e_d-based "open-loop damping" in vendor sensorless stacks). The slow LPF removes the steady operating
* point so only the oscillation is fed back. */
float gain = m->cfg->control.sync_damping_gain;
if ((gain > 0.0f) && delta_ok && SyncField_Moving(&m->sf) &&
(AG_Abs(omega_cmd) > m->cfg->motor.bemf_speed_floor_rad_s))
{
if (!m->damp_lpf.primed)
{
AG_LPF_Reset(&m->damp_lpf, delta_est);
}
float mean = AG_LPF_Update(&m->damp_lpf, delta_est);
float corr = -gain * AG_WrapPi(delta_est - mean);
float lim = 0.3f * AG_Abs(omega_cmd);
m->damp_corr = AG_Clamp(corr, -lim, lim);
/* Integrate into a bounded offset so the field can never walk away from the position reference. */
m->damp_offset_e = AG_Clamp(m->damp_offset_e + m->damp_corr * m->dt_isr, -0.3f, 0.3f);
}
Load Angle: How hard is the motor held back
The rotor never sits exactly on the field. It trails by an angle δ, the load angle, and the torque the motor delivers is
torque = Kt × I × sin(δ) with Kt = 0.0368 Nm/A for this motor (datasheet). A free rotor runs near δ = 0. As the load grows, δ grows up to 90 electrical degrees (1.57 rad) that is where the motor gives all its torque. Beyond that, the rotor falls out of step and δ can be then considered both the load measurement and the distance to failure. We never want to reach that on this algorythm.
The firmware gets δ from quantities it already has. In each PWM period it knows the voltage applied to the windings and the current it measures. Subtracting the resistive and inductive drops leaves the back-EMF, the voltage the turning magnets induce: e = v − R × i − L × di/dt
The back-EMF vector points where the rotor is. Its angle in the commanded frame is the load angle, and its size compared with what the commanded speed should produce tells whether the rotor is still turning at all.

Drawing 1 is what happens in the motor. Drawing 2 is the same angle found from voltages alone, which is all the firmware has. The inductive drop is left out of drawing 2: at this speed it is about 0.05 V.
The weak point is the R × i term. With 3.9 Ω and 0.3 A it is 1.2 V, while the back-EMF at 20 rad/s is under half a volt. An error of a few percent in R is a large error in e. The estimate is therefore only trusted above a minimum speed, which the firmware tries to estimate from the current in use and from how well R is known. Below it, the motor is unreliable.

The minimum speed was not a tuned number. The firmware works it out at start-up as the speed at which the back-EMF is three times the voltage that the doubt in R could fake: 3 × 5 % × 3.9 Ω × 0.3 A / 3.5 mWb = 50 rad/s electrical, which is 7 rad/s at the motor shaft. The finger approaches at 20 rad/s, almost three times that.
A stalled rotor is the other end of the scale. The field still turns, so 0.49 V of back-EMF is expected and almost none is found. The angle is gone, but that ratio of found to expected is a signal of its own, and it is what the stall path of the reflex watches.
/* config.c - Config_Derive(): the speed below which the load angle is not used (excerpt) */
float v_err = cfg->motor.resistance_uncertainty * cfg->motor.phase_resistance_ohm * cfg->grip.approach_current_a;
float w_min = 3.0f * v_err / cfg->motor.flux_linkage_wb;
cfg->motor.bemf_speed_floor_rad_s = AG_Max(cfg->motor.bemf_speed_floor_base_rad_s, w_min);
The estimator is one function, called in every period with the voltage the regulators just asked for and the current just measured. It works in the commanded (d/q) frame, so the formula above gains one term per axis with omega_cmd: the inductive drop of a rotating vector. Two filter pairs run side by side, a slow one for the reading and a fast one (edf, eqf) for the reflex. e_floor is the trust condition: the back-EMF has to be larger than twice what the uncertainty of R could fake.
/* motor_load.c - MotorLoad_UpdateVoltageModel() (excerpt) */
/* Differentiate lightly filtered currents: sample noise through L/dt would otherwise swamp the back-EMF. */
float idf = AG_LPF_Update(&ml->idf_filter, i_dq.x);
float iqf = AG_LPF_Update(&ml->iqf_filter, i_dq.y);
float did = (idf - ml->prev_id) / ml->dt;
float diq = (iqf - ml->prev_iq) / ml->dt;
/* ... */
float ed_raw = v_dq.x - R * i_dq.x - Ld * did + omega_cmd * Lq * i_dq.y;
float eq_raw = v_dq.y - R * i_dq.y - Lq * diq - omega_cmd * Ld * i_dq.x;
ml->e_d = AG_LPF_Update(&ml->ed_filter, ed_raw);
ml->e_q = AG_LPF_Update(&ml->eq_filter, eq_raw);
ml->e_mag = sqrtf(ml->e_d * ml->e_d + ml->e_q * ml->e_q);
float edf = AG_LPF_Update(&ml->edf_filter, ed_raw);
float eqf = AG_LPF_Update(&ml->eqf_filter, eq_raw);
ml->e_fast = sqrtf(edf * edf + eqf * eqf);
/* ... */
bool speed_ok = AG_Abs(omega_cmd) > m->bemf_speed_floor_rad_s;
/* ... */
if (ml->lambda > 0.0f)
{
float e_inst = AG_Abs(omega_cmd) * ml->lambda;
ml->e_expected = AG_LPF_Update(&ml->exp_filter, e_inst); /* same lag as e_mag */
float e_exp_fast = AG_LPF_Update(&ml->expf_filter, e_inst); /* same lag as e_fast */
if (speed_ok && (ml->e_expected > 1e-3f))
{
ratio = AG_LPF_Update(&ml->ratio_filter, AG_Clamp(ml->e_mag / ml->e_expected, 0.0f, 2.0f));
ratio_fast = AG_Clamp(ml->e_fast / AG_Max(e_exp_fast, 1e-3f), 0.0f, 2.0f);
ratio_valid = true;
}
/* ... */
}
/* ... */
float e_floor = 2.0f * m->resistance_uncertainty * R * AG_Max(i_mag, 1e-3f);
bool angle_valid = speed_ok && (ml->e_mag > e_floor) && (ratio_valid ? (ratio > 0.1f) : true);
float sgn = (omega_cmd >= 0.0f) ? 1.0f : -1.0f;
ml->omega_sign = sgn;
float delta = angle_valid ? atan2f(sgn * ml->e_d, sgn * ml->e_q) : ml->out.load_angle_rad;
ml->delta_fast_valid = speed_ok && (ml->e_fast > e_floor);
if (ml->delta_fast_valid)
{
ml->delta_fast = atan2f(sgn * edf, sgn * eqf);
}
Contact reflex: stop before the pole slips
Contact has to be handled inside the 20 kHz interrupt. The first version reacted in the 1 kHz task and, in simulation, a stiff object made the motor slip poles before the task noticed. The reflex watches two conditions in every PWM period:
- Load-angle path: δ has reached the stop level (1.0 rad on the bare rotor; on the finger, 0.6 rad above the level its own gears run at). Confirmed for 2 ms.
- Stall path: the back-EMF has collapsed, meaning the rotor has stopped while the field goes on. Confirmed for 6 ms.
When either one is confirmed the field freezes where it is. The rotor is now held against the object with a known current and a known load angle, so the grip torque is known. The gripper then holds at a current chosen by object class and waits for the release.
In code the reflex is one counter with a limit of 6 ms (120 periods). A period in which the load angle is over its level adds three, so that path stops in 2 ms. A period in which only the back-EMF has collapsed adds one. A quiet period takes one away. The third branch is a lesson from the bench: when a firm grab makes the estimate flicker in and out, those periods hold the counter for up to 10 ms instead of running it down.

/* motor.c - the contact reflex inside Motor_CurrentIsr() (excerpt) */
bool load_hit = m->load.delta_fast_valid &&
((sgn * m->load.delta_fast >= m->cfg->grip.load_angle_target_rad) ||
(use_map && (excess >= m->cfg->grip.contact_excess_rad)));
bool stall_hit = m->load.ratio_fast_valid &&
(m->load.ratio_fast < 0.7f * m->cfg->contact.bemf_ratio_threshold);
/* ... */
if (load_hit) { m->reflex_count += 3u; m->reflex_hold = 0u; }
else if (stall_hit) { m->reflex_count += 1u; m->reflex_hold = 0u; }
else if ((m->reflex_count > 0u) && !m->load.delta_fast_valid &&
(m->reflex_hold < (uint16_t) (0.010f / m->dt_isr)))
{
m->reflex_hold++;
}
else if (m->reflex_count > 0u) { m->reflex_count--; }
if (m->reflex_count >= m->reflex_limit)
{
SyncField_Hold(&m->sf);
m->mode = MOTOR_MODE_CURRENT_HOLD;
/* ... keep the load angle and the rise for the verdict ... */
m->contact_latched = true;
}
Soft or rigid: the way the load rises
My first plan was to probe the object after the stop: step the current and measure how far the rotor moves. That needs the rotor position at standstill, where there is no back-EMF. I tried to track it by integrating what little back-EMF each small movement produces. It passed every simulation and failed completely on the bench. The signal output was below the noise floor.
The replacement uses the last moments of the approach, while the motor is still turning and the estimator still works. Between the load angle crossing a start level (0.45 rad) and the stop, the field keeps advancing. Part of that advance only winds up the motor's own magnetic spring. The rest is the jaw actually moving into the object:
compliance = (field travel − Δδ / pole pairs) / (I × (sin δ1 − sin δ0))
The result is in radians of motor travel per amp of torque-producing current. A rigid object gives almost nothing: the load jumps and the jaw has not moved. A soft object lets the jaw travel while the load builds. An object so abrupt that the estimator cannot follow the rise at all is classed rigid on the spot.
The fast loop only remembers where the field was when the load angle left its free-running level, and where it was at the first sign of the stop. The arithmetic is done once, at the stop, in the 1 kHz task. On the finger both ends are taken above the learned friction level (base0, base1):
/* gripper.c - Gripper_DynamicCompliance(), run once per contact (excerpt) */
float d0 = m->latch_rise_delta0;
float d1 = m->latch_rise_delta1;
/* With a friction map the torque that went into the object is what the load angle shows above the
* learned level at each end (both bases are zero without a map). */
float dsin = (sinf(d1) - sinf(m->latch_rise_base1)) - (sinf(d0) - sinf(m->latch_rise_base0));
if (dsin > 0.05f)
{
float lead = (d1 - d0) / pp;
float moved = AG_Max(0.0f, m->latch_rise_travel_rad - lead);
r.measured_compliance = m->latch_rise_travel_rad / (i * dsin);
r.relative_compliance = moved / (i * dsin);
r.valid = true;
r.object_class = Compliance_Classify(g->cfg, r.relative_compliance, true);
}
The two ends are caught in the fast loop, next to the reflex. q is the load angle, or on the finger its averaged excess above the learned level; start is the level where the measurement begins. Falling back below it drops the start, so ripple during the free approach keeps moving it forward:
/* motor.c - Motor_CurrentIsr(): start and end of the load rise (excerpt) */
if (!m->rise_active)
{
if (q >= start)
{
m->rise_active = true;
m->rise_on_excess = use_map;
m->rise_theta_start = rise_mech;
m->rise_delta_start = d;
m->rise_base_start = base;
}
}
else if ((q < start - hyst) || (m->rise_on_excess != use_map))
{
m->rise_active = false;
m->rise_drop_isr = m->isr_count;
}
/* ... */
if ((m->reflex_count == 0u) && (load_hit || stall_hit))
{
/* First sign of the stop condition in this run of the debounce counter: the end of the rise. On
* the stall path the estimate is no longer usable there and the target is assumed. */
/* ... */
m->rise_theta_end = rise_mech;
m->rise_base_end = base;
m->rise_delta_end = load_hit ? (sgn * m->load.delta_fast)
: (use_map ? AG_Min(m->cfg->grip.load_angle_target_rad,
base + m->cfg->grip.contact_excess_rad)
: m->cfg->grip.load_angle_target_rad);
}
The firm grab runs near zero until the hand closes, then passes the measuring level and the stop level within a few milliseconds. The soft grab has been above the measuring level for the whole window, and the field has kept advancing all that time. That extra travel is what the compliance figure counts.

The figure becomes a class through two limits (15 and 16 rad/A on the finger), and the class picks the current the grip is held with. Both functions, whole:
/* compliance_estimator.c */
ag_object_class_t Compliance_Classify(const ag_config_t *cfg, float relative_compliance, bool valid)
{
if (!valid)
{
return AG_OBJECT_UNKNOWN;
}
if (relative_compliance >= cfg->grip.compliance_soft_threshold)
{
return AG_OBJECT_SOFT;
}
if (relative_compliance <= cfg->grip.compliance_rigid_threshold)
{
return AG_OBJECT_RIGID;
}
return AG_OBJECT_MEDIUM;
}
/* adaptive_grip.c */
float Adaptive_HoldCurrent(const ag_config_t *cfg, ag_object_class_t object_class)
{
float a;
switch (object_class)
{
case AG_OBJECT_SOFT: a = cfg->grip.hold_current_soft_a; break;
case AG_OBJECT_MEDIUM: a = cfg->grip.hold_current_medium_a; break;
case AG_OBJECT_RIGID: a = cfg->grip.hold_current_rigid_a; break;
default: a = cfg->grip.hold_current_unknown_a; break;
}
return AG_Clamp(a, 0.0f, cfg->grip.grip_current_max_a);
}
Firmware on the RA6T3
The firmware is plain C in three layers:
- A portable core with no vendor headers: current control, field drive, load-angle estimator, contact reflex, gripper state machine, console, fault handling.
- The RA6T3 port on Renesas FSP 5.4.0: GPT three-phase PWM, ADC triggered through the ELC, POEG shut-down path, GPT5 as quadrature counter, the 1 kHz tick. It builds with CMake and the GNU Arm toolchain.
- A host port that replaces the board with a simulated motor and a simulated object (a spring with friction), so the whole chain from PWM duty to gripper state runs on a PC. The test suite built on it has 1038 checks, including full grip cycles on rigid and soft objects.
Two rates share the work. The 20 kHz interrupt fires when the ADC scan ends: scale the currents, transform to the rotating frame, update the back-EMF estimate, run the contact reflex, run the two PI regulators, write the next PWM duties. The 1 kHz task runs the gripper state machine, the console and the telemetry.
One PWM period, step by step
Everything that senses and controls happens once per 50 µs period, in this order:
- The timer reaches the trough of its triangle. All three low-side switches conduct, so the driver's current-sense outputs are valid. A few counts later GPT1 raises its A/D start request.
- The ADC samples without software. The Event Link Controller carries that request to ADC0. Its three sample-and-hold circuits freeze the phase currents at the same instant; the ADC then converts them and the divided supply voltage.
- The scan-end interrupt starts the control pass. Counts become amps, the offsets taken at enable are removed, and what the three readings have in common is taken out, because real phase currents sum to zero. Two over-limit samples in a row trip the stage.
- The field advances. The position reference moves by one step of the commanded speed, plus a small bounded damping correction.
- Current control. Clarke and Park transforms, two PI regulators with decoupling, a limit on the voltage vector, then space-vector modulation into three duties. They go into the timers' buffer registers and take effect at the next reload.
- The motor is read as a sensor. The voltage just applied and the current just measured give the back-EMF, and from it the load angle and the ratio of real to expected back-EMF.
- Contact reflex. On the finger the learned level for this position is taken off first. The debounce counter runs, and when it is full the field freezes.
- Bookkeeping. One sample goes to the contact recorder, and a snapshot is published for the 1 kHz task.
Measured on the board with the stage on, the pass takes 32 µs as a rule and 43 µs at most, of the 50 µs it has available. The skeleton of it, from the firmware:
/* motor.c - Motor_CurrentIsr(), called at the end of every ADC scan (excerpt) */
void Motor_CurrentIsr(motor_t *m, const ag_hal_adc_frame_t *frame)
{
AdcCurrent_Process(&m->adc, frame, &m->ps);
float vbus = m->adc.vbus_v;
/* ... offset calibration, over-current and fault checks ... */
SyncField_IsrUpdate(&m->sf);
/* The field angle is the position reference plus a small, bounded damping offset (never a drift). */
float theta_cmd = AG_WrapPi(SyncField_ThetaE(&m->sf) + m->damp_offset_e);
float omega_cmd = SyncField_OmegaE(&m->sf);
float i_mag = SyncField_Current(&m->sf);
float v_max = PowerStage_MaxPhaseVoltage(&m->ps, vbus);
/* Synchronous drive: current vector on the commanded axis (id = I, iq = 0). */
v_ab = FOC_Update(&m->foc, &m->adc.phase, theta_cmd, id_ref, 0.0f, omega_cmd, v_max);
Motor_ApplyVoltage(m, v_ab, vbus);
/* Load estimation uses the voltage model: it reacts within a millisecond. */
MotorLoad_UpdateVoltageModel(&m->load, m->foc.v_dq, m->foc.i_dq, omega_cmd, i_mag);
/* ... I/f damping, friction map, contact reflex, contact recorder ... */
Motor_PublishState(m, theta_cmd, omega_cmd);
}
Steps 4 and 5 are where the field is calculated, and they are three short functions, shown here whole. The first advances the field angle by the commanded speed; that speed comes from a motion profile in the 1 kHz task. The second turns the three measured currents into a voltage vector that keeps the current on the field's axis. The third turns that vector into three duties. Left out are only the textbook helpers they call: the Clarke and Park transforms, the PI regulator and the space-vector modulation.
/* sync_field.c - step 4: the field angle moves on by one period of the commanded speed */
void SyncField_IsrUpdate(sync_field_t *sf)
{
float v = sf->vel_cmd;
SyncField_AddMech(sf, v * sf->dt_isr);
sf->omega_e = v * sf->pole_pairs;
sf->theta_e = AG_WrapPi(sf->theta_e + sf->omega_e * sf->dt_isr);
sf->i_ref = AG_Ramp_Update(&sf->current_ramp, sf->i_target);
}
/* foc.c - step 5: measured currents in, voltage vector out */
ag_vec2_t FOC_Update(foc_t *f, const ag_phase_currents_t *i, float theta, float id_ref, float iq_ref, float omega_e, float v_max)
{
AG_SinCos(theta, &f->sin_t, &f->cos_t);
f->i_ab = AG_Clarke3(i);
f->i_dq = AG_Park(f->i_ab, f->sin_t, f->cos_t);
f->v_limit = v_max;
AG_PI_SetLimits(&f->pi_d, -v_max, v_max);
AG_PI_SetLimits(&f->pi_q, -v_max, v_max);
/* Cross-coupling feed-forward: v_d -= w L_q i_q, v_q += w L_d i_d (+ w*lambda, the back-EMF, left to the PI). */
const ag_motor_params_t *m = &f->cfg->motor;
float Lq = (m->phase_inductance_q_h > 0.0f) ? m->phase_inductance_q_h : m->phase_inductance_h;
float ff = f->cfg->control.current_ff_decoupling;
float ff_d = -ff * omega_e * Lq * f->i_dq.y;
float ff_q = ff * omega_e * m->phase_inductance_h * f->i_dq.x;
ag_vec2_t v;
v.x = AG_PI_UpdateFF(&f->pi_d, id_ref - f->i_dq.x, ff_d);
v.y = AG_PI_UpdateFF(&f->pi_q, iq_ref - f->i_dq.y, ff_q);
float mag2 = v.x * v.x + v.y * v.y;
f->saturated = (mag2 > v_max * v_max);
if (f->saturated)
{
/* d has priority so the field (current alignment) survives saturation. */
float d = AG_Clamp(v.x, -v_max, v_max);
float rem2 = v_max * v_max - d * d;
float q = (rem2 > 0.0f) ? sqrtf(rem2) : 0.0f;
v.x = d;
v.y = (v.y < 0.0f) ? -q : q;
}
f->v_dq = v;
f->v_ab = AG_InvPark(v, f->sin_t, f->cos_t);
return f->v_ab;
}
/* motor.c and power_stage.c - step 5, continued: voltage vector to three duties */
static void Motor_ApplyVoltage(motor_t *m, ag_vec2_t v_ab, float vbus)
{
ag_phase_currents_t v = AG_InvClarke(v_ab);
PowerStage_ApplyThreePhase(&m->ps, v.a, v.b, v.c, vbus);
}
void PowerStage_ApplyThreePhase(power_stage_t *ps, float va, float vb, float vc, float vbus)
{
float d[3];
ps->modulation_index = AG_SVPWM(va, vb, vc, vbus, ps->duty_min, ps->duty_max, d);
ps->saturated = (ps->modulation_index > 1.0f);
ps->duty[0] = d[0];
ps->duty[1] = d[1];
ps->duty[2] = d[2];
if (ps->enabled)
{
AG_HAL_PwmSetDuties(ps->duty, 3u);
}
}
The state machine is short: DISABLED, OPEN, APPROACH, CONTACT, HOLD, RELEASE, and FAULT. The board's user button steps through it (enable, close, release), so the demonstration needs no computer. One LED is steady while the jaw closes or grips and blinks otherwise. The second LED gives the verdict on the board itself: steady for a rigid object, blinking for a soft one, dark when no object held or it was not identified. Reset button is used when you want to go directly to the disabled state.

A grip is two presses: one to close, one to open. Everything between them is decided by the firmware: the reflex ends the approach, the load rise gives the verdict, and the class sets the hold current. The first close after an enable is the learning pass, which runs to the end of the travel and comes back by itself.
Three things in the firmware exist only because I needed to see what was happening:
- A console through the debugger. The FPB-RA6T3 has no USB serial port, so commands and telemetry travel through the on-board J-Link as an RTT channel.the USB also acts as the power supply for the board itself
- A contact recorder. For each contact the fast loop keeps 256 samples at 2.5 kHz around the stop: load-angle estimate, back-EMF ratio, reflex counter, field position and the raw encoder count. A script reads it out afterwards. Nearly every finding in the next sections came from these traces.
- A live display. A small local web page running on my PC, fed from the console stream, shows the state in plain words, the load angle against its stop limit, and the verdict on the last grip.
The protections are layered. A software over-current trip acts in the fast loop, POEG can force the outputs off, a fault trap switches the stage off if the core itself crashes, a hold is limited in time, and a long hold drops back to the motor's rated current. The firmware also refuses to start a closing move that would be too slow for the estimator to see anything; why that rule exists is told below.
Bench test and results
A sensorless method invites self-deception: the firmware reports what it believes, and without a second opinion there is no telling whether it is right. We then used the motor carried a magnetic encoder (4096 counts per turn) that the control never reads. Every claim below was checked against it.
Most of the development was done before any mechanism existed. A bare rotor has no end stop, so I gave the firmware a virtual 150:1 reduction (a full close is 180 rad at the motor, about nine seconds) and used my hand on the spinning rotor as the object, following different grip behaviours, from hard stops to gentle holds until stall.
Does the rotor follow the field?
The back-EMF the firmware estimated was 0.154 V at 6.28 rad/s and 0.431 V at 17.65 rad/s. Flux linkage times electrical speed predicts 0.154 V and 0.432 V. Over five commanded turns (31.27 rad) the encoder counted 31.23 rad. The rotor is synchronous and the motor constants are right.
Is the load-angle estimate true?

Under load the estimate stays within about 0.15 rad of the truth, against a stop level of 0.8 to 1.0 rad. In a fast event it lags: the traces show it 8 to 10 ms behind the encoder when a firm grab stops the rotor, so the real load angle at the stop is about 1.2 rad when the target was 1.0. That is still inside the 1.57 rad limit, and it is the reason the target is not set higher.
Contact, hold and verdict, by hand
Four labelled grabs, two firm and two through a sponge, all stopped by the load-angle path:

More than a factor of ten separates the two kinds, with nothing but a hand and a bare rotor. I set the limits from this (rigid below 3, soft above 10 rad/A). Ten further labelled grabs followed in later sessions. The firm ones read between 0 and 2.2 rad/A and the soft ones 31, 41 and 58 rad/A. One very abrupt grab produced no reading at all; that became a rule of its own (next section), and the two abrupt grabs after it were classed rigid. A return move blocked by hand was stopped and reported after 0.73 s.
Endurance and heat
- Repeatability test: 126 close and release cycles in 49 minutes, unattended. Every cycle ended in "no object" and returned to open. No false contact, no fault, and the same 9.32 s closing time on every cycle. The telemetry stream of 59,357 rows never had a gap longer than 50 ms.
- Winding temperature: nine minutes holding at 0.5 A, above the motor's 0.4 A rating, warmed the winding by 13 to 18 K (measured from its resistance), with a time constant of about 6.5 minutes. Holds at 0.3 to 0.5 A are harmless. Scaled by the square of the current, 0.8 A is for seconds only, which is how the firmware treats it.
- Stack: peak use 1752 of 4096 bytes with the motor running.
What went wrong, and what it taught me
The simulation passed long before the hardware arrived. Then the bench found things the simulation could not, and the encoder found things I would never have noticed from the firmware's own reports.
The current loop never ran. On first power-up the PWM timer counted and the ADC was armed, but no conversion ever happened. I had used a direct timer-to-ADC trigger code that exists on the older RA6T1. On the RA6T3 the ADC takes timer triggers only through the Event Link Controller. I found it by reading the registers over the debugger, wrote the ELC link by hand to confirm (the scans started at once, 20.0 kHz), then fixed the source.
The standstill tracker believed its own story. After the first real contact the firmware loaded the object in small field steps, each time concluding that the rotor had followed. Over 12.8 s it advanced the field by more than nine electrical turns. The encoder showed the rotor had moved 0.03 rad: my hand held it and the field slipped past, pole after pole. The compliance it reported was 6.4 rad/A; the encoder said 0.2. The cause is this motor's small flux linkage: a voltage error of a few tens of millivolts integrates to a whole pole within the measuring window. The simulated motor had an exact voltage model, so it never showed this. I dropped the method and built the load-rise measurement instead.
The field jumped at the moment of contact. Plotting four contact traces showed the field stepping forward by 0.29 rad electrical in the single sample of the stop, in every grab. The damping correction was being reset to zero when the field froze. The true load angle went from 1.2 to 1.5 rad, the edge of slipping, exactly when the grip was established. The correction is now absorbed into the position reference instead. On the next grabs the load angle at the stop was 0.99 rad.
The open position crept. The test ran clean, but its encoder data showed the rotor resting 0.047 rad further away after each cycle. The position was a single-precision sum of 1 mrad steps, and near 180 rad every step rounds the same way. A compensated sum fixed it: the rest position is now the same to a milliradian over ten cycles. On a mechanism with end stops that drift would have walked it into one over a long run.
A blind move. On the screw vise I tried first, I raised the current to 0.6 A to overcome friction. That raised the estimator's minimum speed above the closing speed, and nothing warned me. The jaw ran into the closed end and the field turned against it without stop. The firmware now refuses a closing move it cannot sense.
Abrupt stops gave no verdict. A really hard, sudden stop halts the rotor in 10 to 16 ms. The estimator drops out before it has seen the load rise, so there was a stop but no measurement. Such a stop is now classed rigid without a figure, which is what it is.
The common thread: every one of these was found by measuring, most of them with the independent encoder or the contact recorder. None would have shown up as a failed demo; the gripper would simply have been wrong now and then.
The mechanisms
A printed vise, tried first
The first mechanism was a small vise I already had: its 3D-printed screw, turned 1:1 by the motor with no gearing, moved one jaw against the other. It was the hardest possible partner for this motor, and it changed the firmware more than any other test.
The vise is the Tiny Vise Clamp by VC Design, published on Printables. I had one printed and lying around, and it became the test mechanism. The design is not mine. Its files are under the designer's license, which does not allow redistribution, so this project links to the original and does not include them. I did not modify the vise. The only part I added is a small printed adapter of my own that couples the motor to its screw.
On the first try the motor could not turn the screw at all, even at 0.8 A (29 mNm). After reworking the fit and sanding the thread it ran, with a friction of 6 to 7 mNm. The motor has 11 mNm at the 0.3 A all the earlier work used, so the mechanism was eating most of the signal. I mapped the screw with the encoder and found a stretch of about five turns where it runs freely, with stiff places at both ends that the motor cannot pass and that look to the firmware exactly like a rigid object.
Inside that free stretch the vise did work, with settings of its own:

Friction forced four changes. The current is brought up before the field starts to turn, because a rotor that sticks and then breaks loose looked like a contact. The reflex is armed by speed, not by time. The opening move has its own, higher current, because a loaded printed thread needs more torque to break loose than it took to tighten. And the stop level came down so that the motor can always undo what it did.
With two test objects, a plastic block (hard) and a piece of foam (soft), in labelled runs: the plastic block read 0 to 0.7 rad/A and the foam 1.1 to 3.1 rad/A, twelve closes in all, and the live display showed RIGID and SOFT correctly. Empty closes run to the end and report "no object".

On the bare rotor the limits sit in a wide empty gap. On the vise both groups lie much closer to zero and to each other, and the limits have very little room.
That was as far as it went. The margin between the two classes was small, because friction already took a third of the load-angle range before anything was touched. A stop at full torque locked the printed thread harder than the motor could undo. And the jaw had to be parked by hand at the open end of the free stretch before every start. When the geared finger ran, on 25 November, I dropped the vise. What it left in the firmware is the four changes above and the friction map described below.
A geared finger, designed for this motor
The vise taught me what the mechanism has to be: back-drivable, with friction that is a small fraction of the motor's torque. The second mechanism is a single finger on a pivot behind two stages of printed spur gears (12:60 and 12:72, 30:1 in total), closing against a fixed wall. It has only rotating joints, so nothing can lock the way the screw did. The motor keeps its encoder stack underneath.
It is modelled as a script (FreeCAD), which also checks every pair of parts for collision at eight finger positions with the teeth in mesh. The estimated force at the finger pad is about 5.5 N at 0.3 A. I printed, assembled and ran on the same day

The gears take 1 to 3 mNm to turn, of the 11 mNm the motor has at 0.3 A; the screw took 6 to 7. So the finger runs on the bare-rotor settings, 0.3 A and 20 rad/s, with no separate opening current, and closes in under two seconds.
Learning the mechanism's own friction
The first grips were poor. With the gears running free the load-angle estimate sat between 0.35 and 0.55 rad and rippled by 0.1 rad. The fixed level at which the measurement starts lay inside that band, so the measurement restarted on every dip. A rigid block read 3 to 9 rad/A and a sponge 8 to 18: the two overlapped.

The bar under the plot shows when the measurement was running. While the gears run free the estimate rides on the start level of 0.41 rad, so every dip closes the measurement and every bump opens it again. The reading that came out of this grip, 8.6 rad/A, counts only the last 1.28 rad of travel.
The fix is a friction map, which I had started for the vise. The first close after every start, with the table empty, is a learning pass: the finger runs to the end of its travel and back in four seconds, and the firmware stores the load angle it saw at each position (636 points over 34 rad). On this mechanism that level runs from −0.05 to 0.33 rad along the travel. From then on, contact and object are judged on the load angle above the learned level: the measurement starts 0.15 rad above it and the stop comes 0.6 rad above it.

This is the learning pass of 2026-11-27, read out of the board's memory: −0.07 to 0.29 rad over the single positions. The fine stripes repeat every 0.45 rad at the motor, which is twice per electrical turn (14 times per motor turn with 7 pole pairs). So they are ripple of the estimate itself, not gear teeth, whose pitch would be 0.52 rad. They repeat with position, so the map takes them out as well. Every enable learns a new map; the four passes on record top out between 0.29 and 0.40 rad.
In code the map is an average per position bin. During the learning pass the fast loop feeds it one sample per period; in every later close the same loop looks the level up, interpolated between two bins, and judges contact on what lies above it (excess):
/* motor.c - Motor_CurrentIsr(): feeding the map during the learning pass (excerpt) */
/* Friction map, learning pass: the estimate against the applied position, while the field moves. */
if (m->fmap.learning && m->load.delta_fast_valid && SyncField_Moving(&m->sf))
{
float dir_now = (omega_cmd >= 0.0f) ? 1.0f : -1.0f;
if (dir_now == m->fmap.dir)
{
FrictionMap_LearnSample(&m->fmap,
SyncField_MechAngle(&m->sf) + m->damp_offset_e / (float) m->cfg->motor.pole_pairs,
dir_now * m->load.delta_fast);
}
}
/* friction_map.c - one sample goes into the bin of its position; a finished bin stores its mean */
void FrictionMap_LearnSample(friction_map_t *fm, float pos_rad, float delta_rad)
{
if (!fm->learning)
{
return;
}
float x = fm->dir * (pos_rad - fm->origin_rad) / fm->bin_rad;
if ((x < 0.0f) || (x >= (float) AG_FRICTION_MAP_BINS))
{
return;
}
int32_t bin = (int32_t) x;
if (bin != fm->acc_bin)
{
FrictionMap_CloseBin(fm);
fm->acc_bin = bin;
}
fm->acc_sum += delta_rad;
if (fm->acc_n < 0xFFFFu)
{
fm->acc_n++;
}
}
/* motor.c - Motor_CurrentIsr(): the map in use during a close (excerpt) */
float base = 0.0f;
bool use_map = (m->cfg->grip.friction_map_enabled != 0.0f) && (sgn == m->fmap.dir) &&
FrictionMap_Lookup(&m->fmap, rise_mech, &base);
float excess = 0.0f;
if (m->load.delta_fast_valid)
{
/* ... */
float d = sgn * m->load.delta_fast;
/* ... */
excess = d - base;
/* ... */
}
The gears do not hold the finger when the power stage is off, so every start is a new home position and a new map. The travel ends a little short of the wall, so a close on nothing always ends with "no object". With the map in the fast loop, the 20 kHz pass takes 33 µs as a rule and 43 µs at most, of its 50 µs.
Rigid and soft blocks on the finger
Two rigid and two soft blocks, three grips each in a fixed order, each set flat against the wall:

The figures are in radians at the motor, behind a 30:1 reduction, so they do not compare with the bare rotor's. A rigid block reads 12 to 14 because the printed gears and finger give about 2 mm at the pad by themselves.
I set the limits from this run: rigid below 15, soft above 16, no verdict in between. A check run with those limits followed: eight grips, seven verdicts, none wrong. The eighth grip read 15.99 and left the LED dark; it stopped where one of the soft blocks does.
Two limits of this result:
- The two classes come close. The highest reading that got a rigid verdict in any run is 14.7 rad/A, and the lowest from a labelled soft block is 16.8. On the bare rotor a factor of ten lay between them. The band without a verdict is there so that a borderline grip shows nothing, not the wrong answer.
- A soft block has to recover. One of them read 41, 25 and 17 rad/A on three grips four seconds apart, and 47 then 27 in the next run, stopping further in each time. It had not sprung back so mukltiple testing could keep drifting when the material is compressed

How close the estimates were
On the bare motor everything electrical agreed with the encoder to a percent or to about a tenth of a radian. On the finger the geometry agreed as well, and the misses were mechanical. The table puts what was expected next to what was measured; the encoder is never in the control loop.

Three of these rows are misses. The datasheet's resistance does not describe the motor as the controller sees it, so the firmware identifies it at the bench. The standstill method reported motion that was not there, and I dropped it. And the printed finger is not rigid: a solid block reads 12 to 14 rad/A on it, where a firm grab on the bare rotor read 0 to 2.2. That last one sets how close the two classes can come.
On the finger the encoder cannot give an absolute load angle, only its change, so the comparison there is of the rise over the 93 ms before each stop. The estimate also ripples by about 0.1 rad with the gear teeth, which the bare rotor did not show.
Our Limitation
- It does not measure force in newtons. The grip torque at the motor is known from the current and the load angle. Turning that into jaw force needs the mechanism's efficiency and that was not mensured. This could be very difficult to settle considering a 3D printed mechanism that is not stiff enough
- It does not detect slip. The proposal's tactile slip sensing was not built. The grip force adapts once per material classification, at contact, and is not corrected afterwards.
- It is blind at low speed and at standstill. The jaw must approach above a minimum speed, and after the stop the firmware holds what it has; it cannot notice an object being pulled out of a hold and there is a specific speed that the mechanism must move, bringing inertia and making the solution as it is not ideal to sense things that cannot stand collision
- The soft or rigid verdict is relative. The limits were set on each mechanism with known objects. softer materials that give low load to the motor could not be detected at all. Since the mechanism is not fully rigid, variance on measurement does not allow detailed classification besides "soft" and "rigid". A more stable mechanism could bring up the precision and allow additional labeling.
- The margin between rigid and soft is small on the finger, about 2 rad/A, and only four blocks have been tried. A soft block gripped again at once reads stiffer. The first close after every start has to be on an empty jaw, to learn the mechanism's friction baseline.
- The only Renesas part is the FPB-RA6T3. The power stage is a plug-in TI DRV8316 board with its own current-sense amplifiers. The RA6T3's on-chip programmable-gain amplifiers, which could read shunt resistors directly, are not used at the moment.
Completed work
- Sensorless synchronous drive of a brushless motor on the RA6T3, with a 20 kHz current loop, verified against an encoder
- Load-angle estimate from the voltage model, within about 0.15 rad of the encoder under load
- Contact reflex in the fast loop: stop on load angle or on stall, in either direction of travel
- Stop-and-hold grip with a known torque, and a soft or rigid verdict from the load rise
- One-button operation, the verdict on the board's own LED (steady for rigid, blinking for soft), live display on a PC
- Console and telemetry through the on-board debugger, contact recorder, current-loop recorder
- 1038 automated checks on a PC against a simulated motor and object
- 126-cycle soak test, thermal measurement, stack measurement on the board
- A printed, geared finger gripping two rigid and two soft blocks and telling them apart
- A friction map learned at every start, so that contact is judged on the load above the mechanism's own friction
Working code repository can be found on my Github: https://github.com/lequibao/adaptivegrip