Howdy everyone,
I noticed that vesc firmware seemingly has a Pedal assist (PAS) + ADC app for ebikes. I just built an ebike with a vesc based controller, and I was wondering if anyone knows if its been fully implemented and how it would interface with hardware? Thanks


Good question. It is disappointing that some many interesting and useful posts go unanswered. What is wrong with this forum?
Lack of email notification I think.
Here is my code implementing PAS assist using PPM input for this sensor https://nexun.pl/en/products/pas-sensor-isis-hollowtech-version-d2-waterproof-higo-connector-947.html
Upload it from Lisp tab in VESC Dev Tools. ADC APP need to be configured. I used ADC1 for throttle but it can be changed in the code to ADC2.
how to configure the adc app, what are the parameters please, thanks for sharing!
Como mudar para adc2 no script?
wonder if would be possible to use adc3 pin on some controllers to make it a torque sensor with lisp
; ==========================================================
; 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) ( (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 ( (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)
)
)