Analog joystick to control velocity - need pointers for FW changes

This is a re-post of the issue I posted a week ago; posting under ‘Support’ with more details of what worked and what doesn’t for me.
I am trying to control velocity with analog joystick and would like to use 0.4.11 firmware since I may have to use rev 3.6 56V board I have to use 36V hoverboard motors.
My fallback is to use rev 3.5 24V board, but not sure that I will get sufficient power at 24Volts
I had made changes to code in Nov '18 as suggested here: https://github.com/madcowswe/ODrive/pull/243
and they seemed to work. However, the motors do not completely stop at the joystick’s neutral position - likely because there is some noise coming from the potentiometers (need to check this).

I tried changing a few things in lowlevel.cpp:

  1. Tried to comment our RC PWM code - since I do not intend to use GPIOs for PWM. I did this because GPIO 3 and 4 can be used for PWM or analog mapping. This did not compile since 2 functions pwm_in_init and pwm_in_cb are used by other modules.
  2. Tried to limit iteration to GPIO 1 & 2 in function pwm_in_cb in lowlevel.cpp by changing GPIO_COUNT to 2 (hardcoded just to try). This compiled but no effect.
  3. In communications.cpp commented out pwm_mapping for GPIO 3 & 4. I did not think this would fix the problem but thought was worth trying since I do get lost between all different FW files. It does work to the extent that Odrivetool’s odrv0.config command does not show gpio3 and 4 for pwm mapping - only shows analog mapping.

I am currently trying the 3.5 24V board which worked with the Nov 18 version (with the changes mentioned above).

I really need the issue fixed urgently. I think the Nov version based on firmware rev 0.4.7 or earlier was quite different than 0.4.11 version.

To get going immediately, I can also temporarily use the source code for the Nov. 18 version and make the changes.

If anyone has suggestions on what I should try, please advise.

Thanks,

Anil

As far as I’m aware, there have been no changes to the GPIO analog mapping behaviour. You shouldn’t have to make any firmware changes.

What GPIOs are you plugging your joystick into?

I am using GPIO3 and GPIO4.
As I mentioned, it seemed to work with a version of 0.4.7 unreleased firmware. I think I have located those source files and should be able to compile and retry that code again. Since that FW works, I am suspecting a FW issue and not hardware problems.

3 & 4 are set to step/dir by default, so you have to disable that (odrv0.axis1.config.enable_step_dir = False).

And then you should be able to map it with an analog mapping, I think ?

I will definitely try that tomorrow for 0.4.11 FW
The source for the firmware that worked is at

I created a new binary from this base today and it seems to work. This is fyi since you may be able to compare this with the latest code to make sure that the solution you suggested is the only solution. I tried to compare low_level.cpp and main.cpp between the two code bases and did not find any relevant differences. But I am not a SW engr - in fact have been away from real HW , SW and FW for decades. So a bit slow (and sometimes clueless) on finding root causes.

Thanks again.

Hi Wetmelon,
I tried issuing odrv0.axis1.config.enable_step_dir = False (also for axis0) before

odrv0.config.gpio3_analog_mapping.min = -2000
odrv0.config.gpio3_analog_mapping.max = 2000
odrv0.config.gpio3_analog_mapping.endpoint =
odrv0.axis0.controller._remote_attributes[‘vel_setpoint’]
odrv0.config.gpio4_analog_mapping.min = -2000
odrv0.config.gpio4_analog_mapping.max = 2000
odrv0.config.gpio4_analog_mapping.endpoint =
odrv0.axis1.controller._remote_attributes[‘vel_setpoint’]

upon saving config and renbooting. when I issue
In [1]: odrv0.axis0.controller.vel_setpoint
I get Out[1]: 0.0

on rev 0.4.11 firmware but get the values reflecting the joystick inputs on the variant of 0.4.7 firmware from the repository above.

Is it possible to check the differences between the two versions related to this?

I have been stuck here for a while now.

Please help.

Anil

Hi Anil,

I was able to confirm that there was a regression in the analog input feature in recent firmware versions. Thanks for your clear report of the issue. I was able to fix it.

In [4]:  odrv0.config.gpio3_analog_mapping.min = -2000
   ...:  odrv0.config.gpio3_analog_mapping.max = 2000
   ...:  odrv0.config.gpio3_analog_mapping.endpoint = odrv0.axis0.controller._remote_attributes['vel_setpoint']

In [5]: odrv0.axis0.controller.vel_setpoint
Out[5]: -1042.96875

In [6]: odrv0.axis0.controller.vel_setpoint
Out[6]: -1053.7109375

In [7]: odrv0.axis0.controller.vel_setpoint
Out[7]: -1041.9921875

The fix is available on devel. Are you able to pull and flash devel to test?

Oskar,

That works perfectly! Thank you!!

I assume for 3.6- 56V version board, I change the config file accordingly?

Yes set it to your hardware version in the tup.config.