You are here

Vesc Pronto - Inputs of internal expansion

1 post / 0 new
speed3r
Online
Last seen: 5 min 47 sec ago
VESC Free
Joined: 2018-11-15 15:55
Posts: 13
Vesc Pronto - Inputs of internal expansion

Hello,

I recently bought a VESC Pronto.
 

I am struggling since two days with sth. that should be really easy:
Read the inputs of the IO-Expander but I do not find documentation about this.
(Why though ?!)

The slice of the schematic in the datasheet shows:
"Cruise", "Neutral", "Mode", "Reverse" and so on go to the TCA9535 which is connected over I2C to the ESP32.

So my attempt is:
Use I2C to readout the TCA9535 and forward this over CAN to the Pronto.

I can configure the TCA.
I can write and read back its registers.

My problem:
The inputs are always shown as 0, no matter if I pull the pin high or not.

My questions:
1) Is this the intended way to read the inputs of the expansion-chip?
2) If yes, am I missing something? My Testscript follows below. if someone could have a look.
3) I had to swap i2c-pins to read back the registers correctly. Is there maybe a mistake in the schematic or documentation or am I doing sth. wrong? 
4) How to contol "pull1" or "pull2" net? Am I correct that these are intended to be controlled?

Pull 1 Pull 2.jpg

I am using this script to read the inputs in the terminal:

;start i2c:
;(i2c-start 'rate-100k 20 21) <-- does not work?
(i2c-start 'rate-100k 21 20)    ;(i2c-start optRate optPinSda optPinScl) from

;prepare buffer for i2c-receive:
(def buf (array-create 1))

;write to register 0x6: configure all pins as inputs
(i2c-tx-rx 0x20 (list 0x06 0xFF 0xFF) nil)

;read back registers:
(i2c-tx-rx 0x20 (list 0x06) buf)
(print (str-merge "Config Port0: 0x" (str-from-n (bufget-u8 buf 0) "%02X")))

(i2c-tx-rx 0x20 (list 0x07) buf)
(print (str-merge "Config Port1: 0x" (str-from-n (bufget-u8 buf 0) "%02X")))

;function to read one register:
(defun read-port (reg)
    (i2c-tx-rx 0x20 (list reg) buf)
    (bufget-u8 buf 0)
)

;loop: read and print to terminal:
(loopwhile t
    (let (
        (p0 (read-port 0x00))    ;write to var p0
        (p1 (read-port 0x01))    ;write to car p1
    )
    {
        (print (str-merge "Port0_d: " (str-from-n p0)))
        (print (str-merge "Port0_b: " (str-from-n p0 "%08b")))
        (print (str-merge "Port1_d: " (str-from-n p1)))
        (print (str-merge "Port1_b: " (str-from-n p1 "%08b")))
        (sleep 0.2)
    })
)

 

I appreciate every help!
Thank you and have a nice weekend!

Edit: Add picture of Pull 1 / Pull 2