BLDC Motor Simulation

Warning The miniHIL BLDC motor simulation described on this page is an addon and not part of the default release. Contact us for more information.

This document describes the BLDC motor simulation used on miniHIL. The simulation starts automatically when the actor is present in your model. The simulation can run at an update rate of up to 50 kHz.

Using the simulation

  1. Add the simulation actor to your project:

    ActorRef sim : ABLDCSimulation
  2. Wire the DUT to the miniHIL:

    • Connect the DUT’s PWM phase signals (high/low sides) to the corresponding PWM inputs on the miniHIL.

    • Connect the Hall sensor lines and/or current-measurement inputs as required by your controller.

  3. Adjust the motor parameters in the init transition of ABLDCSimulation. The following parameters are available and should be set to match your motor:

    • Bdamping - viscous damping coefficient representing frictional resistance in the motor [N·m·s/rad].

    • J - rotor moment of inertia [kg·m²]; affects angular acceleration.

    • Kw - back-EMF constant per phase [V/rad/s]; relates speed to induced voltage.

    • L - phase inductance [H]; influences current dynamics / electrical time constant.

    • NUM_POLES - total number of magnetic poles (not pole pairs).

    • R - phase resistance [Ω] (resistance between one phase and the star point, not phase-to-phase).

    • Tl - applied load torque [N·m]; opposes motor torque.

    • hallActiveRange - active angular range of the Hall sensor in radians.

    • VDC - DC bus voltage supplied to the inverter [V].

    • dt - simulation time step [s]; determines numerical integration accuracy.

  4. Run your scenario. The actor publishes the current state and answers requests via its port.

ABLDCSimulation actor (what it offers)

The Room model exposes the following protocol and actor:

Protocol PBLDCSimulation

  • Incoming commands (from test to simulation):

  • setLoad(float32) - set load torque [Nm].

  • setFriction(float32) - set friction [Nms/rad].

  • resetPosition() - reset mechanical/electrical angles.

  • requestSpeed() - request speed.

  • requestAverageSpeedIn_10ms(uint32) - average speed over n samples at 10 ms cadence.

  • requestPosition() - request current position (cm).

  • requestPositionContinuously() / stopRequestPositionContinuously() - stream/stop position each 100 ms.

  • startObstacleSimulation() / stopObstacleSimulation() - inject/remove obstacle simulation.

  • Outgoing data (from simulation to test):

  • currentMotorState(DBLDCMotorStateE) - full state snapshot (currents, voltages, back-EMF, angle, speed).

  • speed(float32) - response to requestSpeed() [RPM].

  • position(float32) - response to requestPosition() (cm).

  • averageSpeed(float32) - response to requestAverageSpeedIn_10ms(…​) [RPM].

Actor ABLDCSimulation

  • Starts the simulation logic in its init transition (initializes model).

  • Uses internal timers for periodic updates and optional averaging.

Example test (CaGe)

The following step sequence shows how to command a motor controller and verify a reaction using the simulation:

Sequence exampleObstacleSimulationTest:
    // Initialize the miniHIL and motor controller
    setup

    // Command the DUT via LIN to reach 1000 RPM
    setBldcTargetSpeedViaLin(1000)

    // Give the motor time to ramp up and reach stable speed
    wait 5 s

    // Verify that the motor (simulated) reached the expected speed range
    expectSpeedInRange(950,1050)

    // Check that the DUT does not report an obstacle error yet
    expectBldcControllerStatusObstacle(false)

    // Start simulation of an obstacle
    startObstacleSimulation

    wait 5 s

    // Expect the DUT detects the obstacle and reports an error
    expectBldcControllerStatusObstacle(true)
;

Notes