• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

planning software / hardware for a controller-replacement (vesc)

pcace

New here
Joined
May 8, 2025
Messages
17
Location
berlin
Hi there,

I got a very cheap Ampler ebike, with the following specs:
  • 48V 13S2P Battery
  • Q100C CST 36V350W Motor
  • Both PAS & Torque sensor on board
The issue: the original controller shorts out whenever the battery is connected. So, I'm replacing it with a Flipsky FESC 6.7 pro mini (VESC-based). Ordered an antispark switch as well.

My questions are mainly about integrating PAS and torque sensors:
Currently, I'm planning to use an Arduino to read the PAS signal and enable/disable the motor based on pedaling activity, and maybe to switch modes (like a half turn backwards could turn on the lights, or change the current limit). I’d use something like the VescUartControl library for the communication. The torque sensor I plan to connect as an analogue input directly to the VESC.

Now my questions:
  1. How are PAS and torque sensors combined in "professional" ebikes? Do they have different purposes, is one a backup, or do both get used in parallel? From my understanding, both can trigger assist independently – is that correct?
  2. Is there any way for the VESC to read the PAS sensor directly, without using an Arduino as a middleman? Or is an MCU always necessary
Thanks a lot for any clarification!
Cheers and greetings
 
How are PAS and torque sensors combined in "professional" ebikes?
In professional bikes the motor power is calculated by
Code:
motor power = assist factor * human power

human power = torque on crank * cadence (*2Pi)

motor torque = motor constant * motor current (*2Pi)
motor power = motor constant * motor current (*2Pi) * wheel speed

motor current = assist factor * torque on crank * cadence / (motor constant * wheel speed)

So you need both information, torque and cadence (PAS). If you combine a bottom bracket torquesensor with a hub motor.
In a middrive or when sensing the torque on the sprocket of a rear hubmotor, you don't need the cadence signal, since it is shortened from the formula.

I'm replacing it with a Flipsky
For the Flipsky 75100 there is a ready to use solution, with no additional hardware needed. ;)
 
Last edited:
Hi thank you for your reply!
The esc you linked is interesting, but way too big to fit into the ampler frame.
What are typical wattages companies program into their controllers? So how much support on what cadences and leg-power would they go for?
I am wondering if this would be a linear curve or something logarithmic?
Thanks a lot again!
 
I am wondering if this would be a linear curve or something logarithmic?
The assist factor is a constant in the easiest case. Bosch offers up to 400% assistance. So if the rider is pedaling with 100W, the motor provides 400W. Max power is 750W
Bosch offers different riding modes for various riding situations.
Here some typical profiles are suggested:
 
Very interesting!!
But in this example there is “only” speed and power in the equasion. How would cadence play a role here?
 
How would cadence play a role here?
Cadence is one contributor to the human power, as written above. Human power = Cadence * Torque on the crank. So it's always part of the motor power calculation.
Pedaling with a high candence at low torque is "rewarded" in the same way as high torque at a low cadence...
Of course you can program anything different, if you prefer. But my experience is: keep it as simple as possible. Complex math leads to a not bike like riding experience...
 
Last edited:
some ideas how to proceed
I guess you made the same error as me ;)
I did not find the part where you send the current setpoint to the VESC, but I think it's the setpoint for the motor current, not for the battery current.
The motor torque is proportional to the motor current (torque = motor constant * motor current)
So mechanical motor power = motor constant * motor current * wheel rpm (*2Pi)

With your calculation the mechanical motor power will increase linear with the speed as the voltage is nearly constant.
https://github.com/pcace/opensource...d2056647f30768/src/assist_calculation.cpp#L83
 
Hi that is a very very good catch! I am still not sure if i have understood it correclty, Do you think that this would fix the issue?
I now calculate the correct motor current for the desired mechanical power using this:

// Motor torque: T = K_t × I_motor
// Mechanical power: P_mech = T × ω = K_t × I_motor × ω_motor
// Therefore: I_motor = P_mech / (K_t × ω_motor)
float motor_rps = current_motor_rpm / 60.0;
float motor_omega = motor_rps * 2.0 * PI; // [rad/s]
target_current_amps = assist_power_watts / (MOTOR_CONSTANT_KT * motor_omega);
I calculated the motor constant from the Q100C specifications:

Q100C Specs:

  • Voltage: 36V nominal
  • Power: 350W nominal
  • Gear ratio: 14.2:1
  • Poles: 16 (8 pole pairs)
  • Typical wheel RPM: 201 RPM (26"/28" wheels)
Calculation:

  1. Motor RPM: 201 × 14.2 = 2854 RPM
  2. Nominal current: 350W ÷ 36V = 9.72A
  3. Motor torque: 350W ÷ (2854×2π/60) = 1.17 Nm
  4. Motor constant: K_t = 1.17 Nm ÷ 9.72A = 0.12 Nm/A

it seems like you have so much more experience with all this. would you say that my calculation now makes sense?
Since i have no idea what typical motor constants would be like, i am really only hoping the calculation is correct.. is this a plausible value?

Thank you so much again for your great catch ;)

Cheers


PS.: EDIT:
i did go through the motor datasheet again and figured these values:
opensourceAmpler/_documentation/Motor/files/Q100C-Curve.pdf at main · pcace/opensourceAmpler
Maximum Efficiency Point (80.4%):

  • Drehmoment: 7.17 Nm
  • Strom: 5.28 A
  • Drehzahl: 216.4 RPM
  • Leistung: 162.49 W
Maximum Torque Point:

  • Drehmoment: 20.04 Nm
  • Strom: 13.37 A
  • Drehzahl: 180.3 RPM
  • Leistung: 378.39 W
That means: the motor-constant is at max efficiency point:
K_t = Drehmoment / Strom = 7.17 Nm / 5.28 A = 1.36 Nm/A
and at max Torque point:
K_t = Drehmoment / Strom = 20.04 Nm / 13.37 A = 1.50 Nm/A

so i guess i can take the avg here? so for K_t i will use 1.43 Nm/A
(fix: 🐛 updated motor_constant from motor datasheet · pcace/opensourceAmpler@25b190b)
 
Last edited:
Since i have no idea what typical motor constants would be like,
Same for me, I'm just combining all constants like 2Pi, Kt etc. in one value (TS_COEF), that I find by testing. If the assistance is too high, I reduce it, if it's too low, I increase it. But my controller processor has limited resources, so I don't calculate in physical units, but directly in integer ADC values.


And I never fixed the missing wheel speed in the calculation, as I like the behaviour with increasing power with speed. ;)
 
Last edited:
Hi,
hahah ok!
i have updated the previouse post with hopefully more correct calculations!
 
more correct calculations
You can calculate Kt from Kv, that is easier to access:

𝐾ₜ = 8.27 / 𝐾ᵥ with 𝐾ₜ in Nm/A, 𝐾ᵥ in rpm/V
 
You can calculate Kt from Kv, that is easier to access:
hmm but does that also work for a geared motor? when i use your formula i get K_t = 8.27 / 80.4 = 0.103 Nm/A but with direct data (from the specification) i get 1.43 Nm/A.
i guess that differnce comes from the 1:~14 gearing ratio (?)

Cheers and thanks again for you extremely helpful comments!!
 
Back
Top