Generated reference › Stall Detector — Robotics/Safety Supervision
kind: generated#block#robotics-safety-supervision

Stall Detector — Robotics/Safety Supervision

Robotics/Safety_Supervision/Stall_Detector · 2 input / 2 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Stall Detector

Robotics / Safety Supervision

Raises a flag when an actuator is being driven hard and is not moving. A sample counts as stalled when |τ| > Torque Threshold and |ω| < Speed Threshold; the block counts consecutive stalled samples – count ← stalled ? min(count + 1, Stall Samples) : 0 – and raises stall once that run reaches Stall Samples.

A stall is the one operating point where a motor turns its entire electrical input into heat in the windings, and neither signal reveals it alone: high torque is normal under load and zero speed is normal at rest. Only the two together, held long enough to rule out an ordinary reversal, are evidence – a controller reversing direction passes through zero speed at maximum torque, which is the healthy manoeuvre most likely to look exactly like a stall.

Both tests are on MAGNITUDES, so the block is direction-agnostic: a stall against a mechanical stop reads the same whichever way the motor is driven.

Ports

  • tau – the applied torque or its proxy, a scalar [1,1]: motor current, a commanded effort, a measured torque. Any units, as long as Torque Threshold is in the same ones.
  • omega – the resulting speed, a scalar [1,1]: a measured or estimated angular (or linear) velocity, in the same units as Speed Threshold.
  • stall – a scalar [1,1]: 1 while the condition has held for Stall Samples consecutive samples, 0 otherwise. Ready to drive a shutdown, a torque limit or an Assertion.
  • count – a scalar [1,1]: how many consecutive samples the condition has held for, saturating at Stall Samples. It climbs before stall fires, so it is usable as an early margin.

Parameters

  • Torque Threshold – a scalar ≥ 0: the effort above which the actuator is considered to be driving hard. Set it above the torque a healthy motion needs, so ordinary running does not arm the detector.
  • Speed Threshold – a scalar ≥ 0: the speed below which the actuator is considered not to be moving. Set it above the encoder's noise floor and well below the slowest commanded motion.
  • Stall Samples – a whole number ≥ 1: how many consecutive stalled samples raise the flag. It is a count, not a time – at a 10 ms rate 50 samples is half a second, which should comfortably exceed the longest healthy zero crossing under load.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Both thresholds and the sample count are baked into the body at export time; there is no tunable parameter object.

The three HDL targets are genuine synthesizable Q16.16: two absolute values, three comparisons and an increment, with no division and nothing transcendental. The counter is carried as a fixed-point whole number and compared against one, so it never has to be converted out of fixed point.

Simulink bridge

None. Motor and drivetrain supervision blocks ship in the Robotics System Toolbox and in Simscape Electrical, neither of which is installed on this machine, so there is no block whose parameters this one could be mapped onto or verified against. The bridge entry reports the block with that reason rather than dropping it silently, and no parity testbench is owed – the documented consequence of Support::None. Code export verification still covers all ten languages.

Notes

  • Stateful and inherently discrete (setDiscreteOnlyBlock(true)): the run length advances once per sample and has no derivative to integrate.
  • The counter starts at zero and cannot be seeded – a monitor begins having observed nothing.
  • It does not latch. stall clears as soon as one sample fails the condition, because the block reports the current state of the actuator. To hold the fault until an operator clears it, feed stall into Emergency Stop Ramp, whose latch is exactly that.
  • The counter saturates at Stall Samples rather than running free: a stalled actuator stays stalled until someone intervenes, and an unbounded counter would leave the fixed-point range on the HDL targets within minutes.
  • On the HDL targets both comparisons are made in Q16.16, so a sample sitting within one quantum (about 1.5e−5) of either threshold can be classified the other way from the software targets – a run length off by one, which can move stall by a sample. It is a decision output rather than a rounding error, the same caveat Argmax Decision carries. Place the thresholds where the signals do not dwell.
  • The pair to Watchdog Timer, which catches a dead sensor where this catches a dead actuator. The two share their counter rules deliberately, so a diagram holding both behaves consistently.
  • Nonlinear, and deliberately carries no state space. The comparisons and the counter are not describable by A/B/C/D, so model reduction correctly refuses the block.

Code facts#

FactValue
registered typeRobotics/Safety_Supervision/Stall_Detector
familyRobotics/Safety_Supervision
solver environment classICoreBlock_0_Robotics_1_Safety_Supervision_2_Stall_Detector
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Safety_Supervision/Stall_Detector/ICoreBlock_0_Robotics_1_Safety_Supervision_2_Stall_Detector.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Safety_Supervision/Stall_Detector/ICoreBlock_0_Robotics_1_Safety_Supervision_2_Stall_Detector.h
default size on canvas132 × 84 px
ports at insert2 in, 2 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoubletau
2inICoreDoubleomega
3outICoreDoublestall
4outICoreDoublecount

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Torque Threshold0.8
Speed Threshold0.1
Stall Samples10

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent available: motor and drivetrain supervision blocks belong to the Robotics System Toolbox and Simscape Electrical, neither of which is installed on this machine, and the base libraries carry no block that watches torque and speed together. Rebuild it on the Simulink side from two Abs blocks, two Compare To Constant blocks, a Logical Operator and a counter, keeping the saturating count and the non-latching flag this block documents

Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Stall Detector — is this actuator still turning? stalled = ( |tau| > Torque Threshold ) AND ( |omega| < Speed Threshold ) count = stalled ? min(count + 1, Stall Samples) : 0 stall = ( count >= Stall Samples ) ? 1 : 0

Torque into something that will not move is where a motor dissipates its whole electrical input in the windings, and neither signal shows it alone: high torque is normal under load, low speed is normal at rest. Only the CONJUNCTION, sustained, is evidence -- and the sustaining is not a refinement, because a controller reversing direction passes through zero speed at maximum torque, which is the healthy manoeuvre most likely to look like a stall.

The pair to Watchdog_Timer: that block catches a dead SENSOR (a signal that stopped moving), this one a dead ACTUATOR (a signal that will not move). They deliberately share three rules -- the saturating counter, the non-latching output, and the count > N - 0.5 alarm test -- so a diagram holding both does not have to remember which behaves differently.

ALL TEN TARGETS ARE EXACT and the three HDLs are GENUINE SYNTHESIZABLE Q16.16: two absolute values, three comparisons and an increment. No division, nothing transcendental, and the counter never leaves fixed point (so §4's fx_to_int is not needed).

Sample results#

Stall Detector — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sampleStall Detector — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-202012345t (s)in ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0out ICoreDouble-Out-1
tin ICoreDouble-Out-0in ICoreDouble-Out-0out ICoreDouble-Out-0out ICoreDouble-Out-1
0-2-200
0.40.50.500
0.8-2-200
1.20.50.500
1.6-2-200
20.50.500
2.4-2-200
2.80.50.500
3.2-2-200
3.60.50.500
4-2-200
4.40.50.500
4.8-2-200
5.20.50.500

Every 4th of 60 samples, from the table stimulus.

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0 … 0
rampRamp: slope 1 from t = 00 … 0
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias0 … 0
stepStep: 0 -> 1 at t = 1 s0 … 0

Plotted: table — Repeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample

Category static · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Robotics__Safety_Supervision__Stall_Detector.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).