Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vedderb/bldc/llms.txt

Use this file to discover all available pages before exploring further.

The PAS (Pedal Assist System) application is designed for e-bikes. It reads a crank rotation sensor and scales motor current proportionally to pedaling cadence or torque, providing assistance that feels natural under pedaling effort.

Sensor types

The firmware currently supports one sensor type:
typedef enum {
    PAS_SENSOR_TYPE_QUADRATURE = 0
} pas_sensor_type;
A quadrature PAS sensor outputs two phase-shifted pulse trains, allowing the firmware to detect both cadence (speed of pedaling) and pedaling direction.

Control types

typedef enum {
    PAS_CTRL_TYPE_NONE = 0,
    PAS_CTRL_TYPE_CADENCE,
    PAS_CTRL_TYPE_TORQUE,
    PAS_CTRL_TYPE_TORQUE_WITH_CADENCE_TIMEOUT
} pas_control_type;
TypeDescription
CADENCEMotor current scales with pedal RPM between pedal_rpm_start and pedal_rpm_end.
TORQUEMotor current scales with measured crank torque.
TORQUE_WITH_CADENCE_TIMEOUTTorque mode, but output cuts if cadence drops to zero for more than MAX_MS_WITHOUT_CADENCE (1000 ms).

Configuration struct

typedef struct {
    pas_control_type ctrl_type;
    pas_sensor_type sensor_type;
    float current_scaling;
    float pedal_rpm_start;
    float pedal_rpm_end;
    bool invert_pedal_direction;
    uint8_t magnets;
    bool use_filter;
    float ramp_time_pos;
    float ramp_time_neg;
    uint32_t update_rate_hz;
} pas_config;

Key parameters

FieldDefaultDescription
pedal_rpm_start10 RPMCadence at which assist begins.
pedal_rpm_end180 RPMCadence at which assist reaches maximum.
current_scaling0.1Fraction of maximum motor current applied at full assist.
magnets24Number of magnet pulses per crank revolution on the sensor.
invert_pedal_directionfalseSwap forward/reverse pedaling direction detection.
use_filtertrueSmooths cadence measurement with a moving-average filter.
safe_starttrueRequires pedaling to stop and restart before assist is allowed after power-on.
ramp_time_pos0.6 sRamp time for increasing assist.
ramp_time_neg0.3 sRamp time for decreasing assist.
update_rate_hz500 HzControl loop rate.

Timing constants

Defined in app_pas.c:
#define PEDAL_INPUT_TIMEOUT                  0.2    // seconds
#define MAX_MS_WITHOUT_CADENCE_OR_TORQUE     5000   // ms
#define MAX_MS_WITHOUT_CADENCE               1000   // ms
#define MIN_MS_WITHOUT_POWER                 500    // ms
If no sensor pulses arrive within PEDAL_INPUT_TIMEOUT (0.2 s), the pedal RPM reading is treated as zero. If cadence is absent for longer than MAX_MS_WITHOUT_CADENCE_OR_TORQUE (5 s), motor output stops entirely.

Wiring

Connect the PAS sensor to the expansion connector pins designated for quadrature input on your VESC hardware variant. The sensor requires:
  • Signal A and Signal B pulse outputs (open-drain or push-pull, 3.3 V compatible)
  • 5 V or 3.3 V supply
  • Common ground
Do not connect a 5 V sensor output directly if your VESC hardware input pins are 3.3 V only. Use a resistor divider or level shifter.

Combining with ADC throttle

Select APP_ADC_PAS to run both the ADC throttle application and PAS simultaneously. In this mode the ADC throttle acts as an override: if the rider applies the throttle lever, ADC output takes precedence over pedal assist.

Runtime API

void  app_pas_start(bool is_primary_output);
void  app_pas_stop(void);
bool  app_pas_is_running(void);
void  app_pas_configure(pas_config *conf);
float app_pas_get_current_target_rel(void); // Relative current target (0–1)
float app_pas_get_pedal_rpm(void);
void  app_pas_set_current_sub_scaling(float current_sub_scaling);
app_pas_set_current_sub_scaling lets another module (such as a throttle override) reduce the PAS output current without modifying the stored configuration.

Build docs developers (and LLMs) love