Hi everyone,
I’m completely new to the ODrive world and I’m both excited and cautious.
I’m planning to control my ODrive S1 using a Raspberry Pi Pico 2 over UART, and I’d like to use two mechanical end switches as hard stops.
Despite reading the documentation and forum posts, I want to be 100% sure that my setup is both electrically and logically correct before powering it up.
This is what I’m planning:
Endstops:
G03 (pin 17) → min endstop
G02 (pin 19) → max endstop
Both switches connect to GND (pin 16)
ODrive config:
odrv.config.gpio2.mode = GPIO_MODE_DIGITAL_PULL_DOWN
odrv.config.gpio3.mode = GPIO_MODE_DIGITAL_PULL_DOWN
odrv.axis0.config.min_endstop_gpio_pin = 2
odrv.axis0.config.max_endstop_gpio_pin = 3
odrv.axis0.config.enable_min_endstop = True
odrv.axis0.config.enable_max_endstop = True
odrv.axis0.config.endstop.config.debounce_ms = 50
UART connection:
G06 (pin 7) = UART TX (ODrive to Pico)
G07 (pin 8) = UART RX (Pico to ODrive)
Also connected:
ISO VDD (pin 9) to Pico 3.3V
ISO GND (pin 10) to Pico GND
UART config:
odrv.config.gpio6.mode = GPIO_MODE_UART_AUX
odrv.config.gpio7.mode = GPIO_MODE_UART_AUX
odrv.config.uart1.enabled = True
odrv.config.uart1.baudrate = 115200
My question:
Is this configuration valid and electrically safe?
Can I power this up with confidence?
Thanks in advance
Hi! Welcome, I hope your setup experience is nice and smooth!
This configuration is electrically safe, but it’s not valid 
A few notes:
- First, I’d strongly recommend setting up the ODrive (and UART) in the GUI. That’ll be a lot easier.
- I’m guessing you used ChatGPT or something for this code? Some stuff in there I don’t recognize as having ever been part of our API. If so, I’d recommend against using LLMs for ODrive stuff – they always get it wrong.
- GPIO2/GPIO3 are great places to connect your endstop. However, note there’s strong internal pullups on those pins (see here), so you should just use GpioMode.DIGITAL, not DIGITAL_PULL_UP or DIGITAL_PULL_DOWN.
- Also, this means that the GPIO state will be high when the endstop isn’t pressed. As such, you have to set
is_active_high
to False for each endstop (to show that high is the idle/neutral state)
- This is also incorrect configuration for the UART, there’s no need to set the GPIO mode, and you should use
uart0
– I don’t think S1 has uart1
(and GPIO_MODE_UART_AUX
isn’t a parameter).
I think a more correct setup would look like this:
odrv0.config.uart_a_baudrate = 115200
odrv0.config.enable_uart_a = True
odrv0.config.gpio6_mode = GpioMode.UART_A
odrv0.config.gpio7_mode = GpioMode.UART_A
odrv0.config.gpio2_mode = GpioMode.DIGITAL
odrv0.config.gpio3_mode = GpioMode.DIGITAL
odrv0.axis0.min_endstop.config.gpio_num = 3
odrv0.axis0.min_endstop.config.enabled = True
odrv0.axis0.min_endstop.config.is_active_high = False
odrv0.axis0.min_endstop.config.debounce_ms = 50
odrv0.axis0.max_endstop.config.gpio_num = 2
odrv0.axis0.max_endstop.config.enabled = True
odrv0.axis0.max_endstop.config.is_active_high = False
odrv0.axis0.max_endstop.config.debounce_ms = 50
odrv0.save_configuration()
1 Like