You are here

LISP and ADC loop interfering

2 posts / 0 new
Last post
zapshe
Offline
Last seen: 1 year 6 months ago
VESC Free
Joined: 2022-06-19 10:41
Posts: 7
LISP and ADC loop interfering

Hey,

I've been using LISP in order to get handbraking. It works great when I have "Control Type" in App Settings set to off - which ignores my ADC input. I've been using "(app-adc-detach 1 1)", and can confirm that it DOES make the ADC input no longer control the motor.

However, even using app-adc-detach, if Control Type is not set to "off" the handbrake won't work. I realized that it had to do with the control loop. Even though app-adc-detach has made it ignore the ADC signal, the App ADC control loop is still going strong. If I set the ADC Update Rate to 1Hz and crank up LISP's update rate, the handbrake works.. and then it'll be interrupted once every second by the ADC control loop.

I wanted to have hybrid control, where under a certain ADC value LISP would ignore ADC input and engage the handbrake, then once the value was above the threshold surrenders control back to regular operations. Is this possible? Am I doing something stupid?

 

Here's the code so far:

```
(define rate 1)
(define braking 0)

(define one 1)
(define zero 0)

(print(get-adc 0))
(print(get-rpm))

(defun brake()
    (progn
      (print "Braking")

     (if (eq braking 1)
      
      (progn
      (print "1")
      (set-handbrake 25)
      )
      
      (progn
      (print "2")
      (app-adc-detach 1 1)
      (set-handbrake 25)
      (define braking one)
      )
      
     )
    )
)

(defun unBrake()
     (progn
      ;(print "unBraking")
      
      (if (eq braking 1)
      (progn
      (app-adc-detach 1 0)
      (set-handbrake 0)
      (define braking zero)
      )
      )
     )
)

(defun loop()

    (progn
    
        (if (< (get-adc 0) 0.5)
            (brake)
            (unBrake)
        )
        
        (yield (/ 1000000 rate))
        (loop)
    )
)

(loop)

```

zapshe
Offline
Last seen: 1 year 6 months ago
VESC Free
Joined: 2022-06-19 10:41
Posts: 7

The solution was using this: (conf-set 'app-to-use 0)