I am using Python to control an Odrive for a project I’m working on. I wanted to use the Odrive to report the status of a button press on the system.
I have been through as much documentation as I can bear to read including old posts here on the forum, and the only related topics are either years old with “update coming soon” responses or “use get_adc_voltage(gpio)” which only returns nan for a digital pin despite it being set to either digital or analog mdoes.
Returns the logic states of all GPIOs. Bit i represents the state of GPIOi.
Above from the documentation returns the modes of GPIOs, but does not return the states of the GPIO pins from what I can tell. It also has the “Bit i represents the state of GPIOi.” comment which makes me think that I could input a bit mask and get something from it, but there is no documentation explaining how to use it.
Is there a way to read the state of a gpio pin, or how to extrapolate that data from get_gpio_sates() using the python library?
I have checked the wiring, and I am getting the expected outputs from the switch positions, but no matter what position I have the switch I am always getting a “False” as the output of the two threads reading the IO.
G02 and G05 both have pull-ups, so you may want to switch to using pins G05/G08
If using pins on the ISOLATED IO (J12) connector, ISO_VDD and ISO_GND need to be externally powered with 5V/GND. If the endstops are powered from the ODrive FEEDBACK IO (J8) 5V/GND, that 5V/GND can be used to power the ISO_VDD/ISO_GND, as long as no other devices are connected to ISOLATED IO, and no other devices are connected to the ODrive FEEDBACK IO other than the encoder (this is to avoid ground loops).
Have you ran an roll_drv.save_configuration() after configuring the gpio modes and endstop configuration?
Hey again, I hope everyone had a happy new year and holidays.
I wanted to ping here again and see if anyone has any more help on this topic.
Using: (odrv0.get_gpio_states() & (1 << num)) != 0 where num is the gpio pin I am attempting to monitor, I am always getting True as a response. This is with odrv0.config.gpio1_mode set to GpioMode.DIGITAL_PULL_UP or GpioMode.DIGITAL_PULL_DOWN or if the button is pressed or not pressed that is hooked up to the GPIO pin I am trying to monitor (using gpio1 as the example in this, but I have tested a few pins now).
I am not trying to use this switch as an end stop, so I have not configured it so. I have used the save_config() after changing the GpioMode per the documentation.
Any thoughts, or is standard GPIO monitoring not supported?
Yes, I ran a save_configuration() after changing the GPIO mode.
After some extensive testing, I was able to get GPIO pins 1 and 2 working in the DIGITAL_PULL_UP mode.
Strangely, the documentation indicates that G0-G02, G04-G09, G11-G12, G14-G16, G18 are all user-facing GPIO inputs that I should be able to monitor. Since I was trying to use 2 and 5, they should have worked all the same.
Either way, thank you for the help. Pins 1 and 2 are working as expected for me, and they are the only pins I need for the foreseeable future.