You are here

Vesc PAS (Pedal Assist)

5 posts / 0 new
Last post
Evwan
Offline
Last seen: 4 months 3 days ago
VESC Free
Joined: 2021-01-30 20:22
Posts: 2
Vesc PAS (Pedal Assist)

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

 

Screenshot 2022-07-01 223621.png

jimmyoco@gmail.com
Offline
Last seen: 10 months 18 hours ago
Joined: 2023-06-04 00:46
Posts: 1

Good question. It is disappointing that some many interesting and useful posts go unanswered. What is wrong with this forum?

Snabelost
Offline
Last seen: 4 months 5 days ago
Joined: 2022-08-24 10:05
Posts: 22

Lack of email notification I think.

blowman
Offline
Last seen: 2 months 3 weeks ago
Joined: 2023-05-18 16:48
Posts: 1

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.

 

; Single line PAS sensor waveform
;      ____          ____   
;      |  |          |  |   
;-------  ------------  ----
;         ^-pulse width-^
;
; On reverse direction of pedaling the signal is at high state all the time

; When not pedaling(or very slow) the motor is disabled
; When pedaling is detected the ADC APP is enabled and throttle sets assists current
; I removed a spring from the throttle and put a piece of felt inside so 
; the throttle stays at set position

(gpio-configure 'pin-ppm 'pin-mode-in-pd) ; use PPM input

(define MAGNETS 12)
(define MIN_PULSE 0.3) ;seconds, above this pulse width assist is disabled

(define pulse 0) ; PAS pulse width
(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 riding_stops2 0) ;debug


(defun set-assist (assist1)
  (progn
    (define assist (if assist1 1 0))
    (if assist1
      (app-adc-detach 1 0) ; engage throttle current, attach ADC1 to enable the motor
      (progn ; else
        (define assist_cnt 0)
        (app-adc-detach 1 2) ; detach ADC1 to disable the motor
      )
    )
  )
)

(set-assist nil) ; disable assist at startup

; main loop
(loopwhile t ;run at 1000Hz (sleep 0.001)
  (progn
    (define pas_pin (gpio-read 'pin-ppm)) ; read PAS pin
    (if (!= pas_pin last_pas_pin)
      (if (= pas_pin 0) ; measure pulse width on falling edge
        (progn
          (define last_pulse pulse)
          (define pulse (secs-since last_pas_t))
          (define last_pas_t (systime))

          ;(define pas_rpm (* 60 (/ (/ 1.0 MAGNETS) pulse)))

          (if (and (= 0 assist) (< pulse MIN_PULSE)) ; detect pedaling when pulse is shorter than MIN_PULSE sec
            (progn
              (define assist_cnt (+ assist_cnt 1))
              (if (>= assist_cnt 2) ; enable assist when at least 2 short pulses detected
                (set-assist t)
              )
            )
          )

          (if (and (= 1 assist) (> pulse (* last_pulse 1.25))) ; detect rapid PAS slowdown
            (progn
              (set-assist nil)
              (define riding_stops2 (+ 1 riding_stops2)) ; debug
            )
          )

          ;(define pulse_change (/ pulse (+ 0.0001 last_pulse))) ; debug
        )
      )
    )
    (define last_pas_pin pas_pin)

    ; detect very-slow/not pedaling
    (if (and (= 1 assist) (> (secs-since last_pas_t) MIN_PULSE))
      (set-assist nil)
    )

    (sleep 0.001)
  )
)

 

Sandro luis
Offline
Last seen: 2 days 2 hours ago
VESC Free
Joined: 2023-10-22 16:05
Posts: 7

how to configure the adc app, what are the parameters please, thanks for sharing!