finally pas on vesc with 3 wire sensor!!

Nice, I saw that video a couple days ago, makes me want to try out PAS on one of my VESC bikes.

EDIT:
I am attaching the .lisp(just change .zip to .lisp)script referenced in the video here for posterity
 

Attachments

  • pas_vedder.zip
    2.4 KB · Views: 129
Last edited:

Is this your video/script?
As just wondering if I remove the following it would keep adc1 (throttle) available to override pa's immediately if needed?

(defun set-assist (assist1)
(progn
(define assist (if assist1 1 0))
(if assist1
(progn
(define assist_cnt 0)
(app-adc-detach 1 2) ; detach ADC1 from the APP ADC
(app-adc-override 0 1.5) ; override ADC1 value
)
; else
(app-adc-detach 1 0) ; engage throttle current, attach ADC1 to enable the motor
)
)
)
 
This is not a good script in my opinion. I tried it as base for my flixbike project months ago, and ended up ditching it because it's way too resource heavy. The main loop runs at a 1000Hz frequency which means that the scripts calls for 2x interrupts to read gpio status + systime call 1000 times per second. Given that the average pedal cadence of a human being is around 80rpm (=1.33Hz) this is a waste of cpu cycles: if you use a 12 signal PAS, that's a signal frequency of just around 16Hz...

I found that using a simple loop at 20Hz is good enough to start the pas. A sub-counter to check if signal is still alive can run at the faster frequency (100Hz) to ensure a quick stop and still be a lot more resource friendly. You can see it working in my script posted here: Vesclabs online!

Also, you don't start a motor by applying a fixed current, that can be quite damaging. Always use some sort of ramping: there are some good ramping examples listed in Vesc-tool: use them!
 
Last edited:
?! You don't have to poll the PAS pin. You can use an EXTI interrupt or even a Capture Compare interrupt to process the PAS signal. 🤷‍♂️
Nah, registering an input capture in lispBM is quite cumbersome since you need to start an icu driver and register an event handler. Polling the pin is actually faster in my experience if done parsimoniously. I use event handlers only for canbus transmission.
 
It's ridiculous to go to such lengths when the processor has hardware functions specifically for such applications. I can only shake my head in disbelief.o_O
Agreed. Though in the Vesc C# PAS app, gpio are also polled directly: bldc/applications/app_pas.c at master · vedderb/bldc

The clean way to do it would probably be to write a short C_lib allowing for hw capture compare and make it available to lisp.
 
Last edited:
Ok. I got this working on a test bench, but I'm still lacking the ability to change the PAS level becausew I do not have a display nor soft buttons. Can the PAS level be changed via android app? I have a spare thumb throttle that I could possibly use if I remove the spring. No idea how to implement that into the lisp code or what port shoul be used. Just read somewhere that's an option.
 
Last edited:
Hello everyone,

I’m working on a Bafang BBSHD mid-drive build and upgrading the controller to a Flipsky 75100 V2 Pro (VESC-based).
My goal is to achieve a riding experience similar to the stock Bafang PAS behavior, but with the flexibility and power of VESC / FOC.



My Setup:


  • Motor: Bafang BBSHD (mid-drive, Hall sensors connected)
  • Battery: 56V (17s) 20Ah LiFePO₄
    (Planning to upgrade to 72V / 22s LiFePO₄ later)
  • Controller: Flipsky 75100 V2 Pro
    • Firmware: 6.06
    • Hardware: 75_100_v2
  • Display: Flipsky TFT Display V2.0 (FW v2.1) via UART
  • PAS sensors:
    • BBSHD stock 4-wire PAS
    • KT-V12L (tested as alternative)
  • Motor temperature:
    • NTC 10k connected to TEMP pin on the Hall connector (working and must be preserved)



My Goals:


  1. PAS functionality (Bafang-like behavior)
    I want PAS levels 1–5 on the Flipsky TFT display to actually control motor assist (current or power), similar to the stock BBSHD behavior.
  2. External speed sensor
    Since this is a mid-drive and ERPM drops to zero when coasting, I need a wheel-based speed sensor for accurate speed display.
  3. Thermal protection
    I must keep motor temperature protection active using the existing NTC sensor.



Challenges / Questions:

  • The 75100 V2 Pro has no dedicated PAS input, unlike older FT85BS boards.
  • UART is already occupied by the TFT display.
  • My current firmware seems to have Lisp issues (I get eval_cps.c errors even with very simple scripts).
Questions:

  1. What is the best proven way to connect a PAS sensor on the 75100 V2 Pro without interfering with Hall sensors or temperature input?
    • PPM / Servo?
    • ADC (with RC filter)?
    • Custom Lisp script?
  2. What pin is recommended for an external wheel speed sensor?
    • RX2 / PC11?
    • Another GPIO with interrupt support?
  3. Is there a working example (Lisp script or firmware config) specifically for:
    Flipsky 75100 V2 Pro + TFT Display + BBSHD mid-drive?

Any practical experience or known-working setups would be greatly appreciated.

Thank you very much for your help!
 
Any practical experience or known-working setups

The BBSxx are using a quadrature PAS signal anyway, so it will work with the native PAS implementation of the VESC out of the box....
You can use the Luna BBSHD firmware as a blueprint.

But the Pro has no suitiable pinout. Why did you buy that one of all things?
1767549348796.png
 
Last edited:

The BBSxx are using a quadrature PAS signal anyway, so it will work with the native PAS implementation of the VESC out of the box....
You can use the Luna BBSHD firmware as a blueprint.

But the Pro has no suitiable pinout. Why did you buy that one of all things?
Hi stancecoke,
Thank you for youre reply!


I’m trying to build a setup on VESC that behaves as close as possible to the stock BBSHD controller:
– proper PAS behavior (cadence based, proportional assist)
– external wheel speed sensor
– torque via cadence + speed logic (not just throttle-like PAS)


My current situation:
– Controller: Flipsky 75100 Pro v2
– Motor: Bafang BBSHD
– RX2 is already occupied by the display
– ADC1 = throttle
– ADC2 = PAS sensor
– Servo pin still questionable / possibly free
– No free digital input left for a classic wheel speed sensor


Because of that, at the moment the only usable speed source is GPS speed, but many users report poor accuracy and lag, especially on climbs and low speeds.


Main questions:


  1. Is it realistically possible to implement BBSHD-like PAS + external speed sensing on this controller, or am I fighting hardware limitations?
  2. Would you recommend switching to a different controller for this task — for example FT85BS or a “simpler” 75100 instead of Pro v2?
  3. If yes, why specifically — GPIO availability, thermal behavior, firmware flexibility?

Why I chose 75100 Pro v2:
– high current headroom (long mountain climbs)
– very good thermal performance
– users report that regular 75100 tends to overheat
– FT85BS might also overheat under long sustained load


Riding conditions:
– long, steep climbs
– sustained high current
– PAS-based riding preferred over throttle


In your opinion:
– Is it better to change the controller, or
– Can this still be solved on 75100 Pro v2 (software tricks, alternative pin usage, different PAS/speed strategy)?


Any recommendation on the best overall approach would be greatly appreciated.
 
Any recommendation on the best overall approach would be greatly appreciated.
You will need at least (digital) I/O pins for
- PAS 1
- PAS 2
- UART Rx
- UART Tx
- Speed sensor
- Break sensor

Pins available on the Pro:
- ADC 1 (needed for throttle)
- ADC 2
- ADC 15
- Servo
- Temp
- RX
- TX

So enough pins in principle, but you would have to reconfigure a lot in the peripheral initialization (from analogue input to general I/O, e.g.) and the signal processing.
Perhaps there is someone who can do the necessary tweaks by a lisp script...

I don't know the advantage of the Pro over the normal Flipsky 75100 V2, that would need much less code modification (just quadrature PAS instead of the torquesensor) with my VESC branch and has the better (waterproof) housing for an EBike use.

Why do you want to use a VESC at all? Just use a Bafang UART protocol E-Bike controller. Much less struggle ;)
Especially Flipsky is known for poor quality....
 
Last edited:
; better version for use pas and throtle .past all to vesc dev tool lisp . only for KT-V12 and similar, use translate if dont
; understand . gemini write this script . i use and is good






; ==========================================================
; Proporcjonalne wspomaganie PAS dla KT-V12L (12 magnesów)
; Funkcje: Soft Start, Proporcjonalna Moc, Auto-Cutoff, MIKSER MANETKI
; ==========================================================

(gpio-configure 'pin-ppm 'pin-mode-in-pd)

; --- PARAMETRY KONFIGURACYJNE --- to trzeba pozmieniać pod swój system , parametry muszą być z . jak 1.0 nie 1
(define MAGNETS 12.0)
(define MIN_PULSE 0.5)
(define MIN_RPM 15.0)
(define MAX_RPM 80.0)
(define MIN_ADC 0.8)
(define MAX_ADC 3.2)
(define SOFT_START 0.05) ; 0.01 = bardzo wolny, 0.1 = szybki start

; --- ZMIENNE ROBOCZE ---
(define pulse 0)
(define last_pulse 0)
(define last_pas_pin 0)
(define last_pas_t 0)
(define assist 0)
(define assist_cnt 0)
(define pas_rpm 0)
(define target_adc 0)
(define current_adc 0)

; --- FUNKCJA STERUJĄCA ---
(defun set-assist (enable)
(progn
(define assist (if enable 1 0))
(if enable
(app-adc-detach 1 2) ; Przejęcie kontroli nad systemowym ADC
(progn
(app-adc-detach 1 0) ; Oddanie pełnej kontroli manetce
(app-adc-override 0 0)
(define pas_rpm 0)
(define assist_cnt 0)
(define current_adc 0)
)
)
)
)

(set-assist nil)

; --- GŁÓWNA PĘTLA ---
(loopwhile t
(progn
(define pas_pin (gpio-read 'pin-ppm))

(if (!= pas_pin last_pas_pin)
(if (= pas_pin 0)
(progn
(define last_pulse pulse)
(define pulse (secs-since last_pas_t))
(define last_pas_t (systime))

; Obliczanie RPM
(define pas_rpm (* 60.0 (/ (/ 1.0 MAGNETS) pulse)))

; Logika Startu (wymaga 2 impulsów)
(if (and (= 0 assist) (< pulse 0.4))
(progn
(define assist_cnt (+ assist_cnt 1))
(if (>= assist_cnt 2) (set-assist t))
)
)

; Obliczanie mocy z pedałów (Target ADC)
(if (= 1 assist)
(progn
(define rpm_factor (/ (- pas_rpm MIN_RPM) (- MAX_RPM MIN_RPM)))
(if (< rpm_factor 0) (define rpm_factor 0))
(if (> rpm_factor 1) (define rpm_factor 1))
(define target_adc (+ MIN_ADC (* rpm_factor (- MAX_ADC MIN_ADC))))
)
)

; Szybkie wyłączanie przy gwałtownym zwolnieniu pedałowania
(if (and (= 1 assist) (> pulse (* last_pulse 1.45)))
(set-assist nil)
)
)
)
)
(define last_pas_pin pas_pin)

; ==========================================================
; LOGIKA SOFT START i MIKSERA MANETKI (wykonywana co 1ms)
; ==========================================================
(if (= 1 assist)
(progn
; 1. Płynne narastanie napięcia z PAS (Soft Start)
(define diff (- target_adc current_adc))
(define current_adc (+ current_adc (* diff SOFT_START)))

; 2. Odczyt fizycznego napięcia z manetki (ADC1 -> kanał 0 w Lisp)
(define throttle_adc (get-adc 0))

; 3. Wybór wyższej wartości (Manetka czy PAS?)
(define final_adc (if (> throttle_adc current_adc) throttle_adc current_adc))

; 4. Wysłanie wygranej wartości do silnika
(app-adc-override 0 final_adc)
)
)

; Timeout bezpieczeństwa (całkowite zatrzymanie pedałów)
(if (and (= 1 assist) (> (secs-since last_pas_t) 0.4))
(set-assist nil)
)

(sleep 0.001)
)
)
 
Last edited:
for other types of p.a.s with a signal in both directions , dont use if not have this type pas . if you have quadranture pas 2wire signal conect 1 to servoppm
 

Attachments

  • pas (2).zip
    2.5 KB · Views: 20
Last edited:
for other types of p.a.s with a signal in both directions , dont use if not have this type pas . if you have quadranture pas 2wire signal conect 1 to servoppm
Thanks for the script! I'm currently using it and have some success, but the throttle signal cuts out randomly.

if i understand correctly, in this type of PAS (3 wire, sends a signal when pedaling in both directions with different duty cycle) the Magnets on the disc are spaced unevenly. Do you know how large the difference between spacings is? I 3D-printed my own disc and am not sure of the correct spacing.
 
Thanks for the script! I'm currently using it and have some success, but the throttle signal cuts out randomly.

if i understand correctly, in this type of PAS (3 wire, sends a signal when pedaling in both directions with different duty cycle) the Magnets on the disc are spaced unevenly. Do you know how large the difference between spacings is? I 3D-printed my own disc and am not sure of the correct spacing.
I don't know. I have a KT12L. How did you print it if you don't know the dimensions? Buy one. It's only $10.

you followed the instructions ?
 
Last edited:
Back
Top