RC PWM trouble, code from the ec-pwm.md doesn't work for me

Hello!
ODrive hw3.6 fw0.54
Two hoverboard wheels are calibrated.

odrv0.config.gpio4_mode = GPIO_MODE_PWM
odrv0.config.gpio4_pwm_mapping.min = -2
odrv0.config.gpio4_pwm_mapping.max = 2
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis0.controller._input_pos_property

RC doesn’t work for me. How can I see what is the real pwm that come to the ports 3 and 4?
I use a servo and it feel the pwm.
I can activate input_vel from the odrivetool.
I’ve no idea where is a problem.

You can just read back input_pos to see what it thinks is the input position

bonjour
j’ai le meme probleme les sorties pwm ne fonctionnent pas, a tu trouver la solution

AttributeError Traceback (most recent call last)
File :1
----> 1 odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._remote_attributes[‘input_vel’]

AttributeError: ‘anonymous_interface_1321094372880’ object has no attribute ‘_remote_attributes’

Bonjour

Votre commande n’est pas correcte.

odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property

https://stijnsprojects.github.io/Cable-Cam/

Stijn

merci,cela fonctionne en revanche j’ai un autre soucis je debute completement voici le code il controle correctement 1 moteur avec la telecomande et j’aimerais qu’il en commande 2 . le gpio 3, fera avancer ou reculer .et sur le gpio 4 1 moteur avance et le deuxieme recule.

Connected to ODrive v3.6 205B305F594D (firmware v0.5.1) as odrv0
In [1]: odrv0.erase_configuration()
Oh no odrv0 disappeared

Reconnected to ODrive v3.6 205B305F594D (firmware v0.5.1) as odrv0
In [2]: odrv0.config.brake_resistance = True

In [3]: odrv0.config.dc_max_positive_current = 30

In [4]: odrv0.config.dc_max_negative_current = -2.0

In [5]: odrv0.config.max_regen_current = 0

In [6]: odrv0.save_configuration()

In [7]: odrv0.axis0.motor.config.pole_pairs = 15

In [8]: odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT

In [9]: odrv0.axis0.motor.config.resistance_calib_max_voltage = 4

In [10]: odrv0.axis0.motor.config.calibration_current = 10

In [11]: odrv0.axis0.motor.config.current_lim = 20

In [12]: odrv0.axis0.motor.config.requested_current_range = 25

In [13]: odrv0.save_configuration()

In [14]: odrv0.axis0.encoder.config.mode = ENCODER_MODE_HALL

In [15]: odrv0.axis0.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL

In [16]: odrv0.axis0.encoder.config.cpr = 90

In [17]: odrv0.axis0.controller.config.pos_gain = 20

In [18]: odrv0.axis0.controller.config.vel_gain = 0.02

In [19]: odrv0.axis0.controller.config.vel_integrator_gain = 0.1

In [20]: odrv0.axis0.controller.config.vel_limit = 100

In [21]: odrv0.save_configuration()

In [22]: odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

In [23]: odrv0.axis0.motor
Out[23]:
DC_calib_phB: -3.044856309890747 (float)
DC_calib_phC: -1.3685325384140015 (float)
armed_state: 0 (int32)
config:
acim_autoflux_attack_gain: 10.0 (float)
acim_autoflux_decay_gain: 1.0 (float)
acim_autoflux_enable: False (bool)
acim_autoflux_min_Id: 10.0 (float)
acim_gain_min_flux: 10.0 (float)
acim_slip_velocity: 14.706000328063965 (float)
calibration_current: 10.0 (float)
current_control_bandwidth: 1000.0 (float)
current_lim: 20.0 (float)
current_lim_margin: 8.0 (float)
direction: 0 (int32)
inverter_temp_limit_lower: 100.0 (float)
inverter_temp_limit_upper: 120.0 (float)
motor_type: 0 (int32)
phase_inductance: 0.0005604586913250387 (float)
phase_resistance: 0.39337942004203796 (float)
pole_pairs: 15 (int32)
pre_calibrated: False (bool)
requested_current_range: 25.0 (float)
resistance_calib_max_voltage: 4.0 (float)
torque_constant: 0.03999999910593033 (float)
torque_lim: inf (float)
current_control:
I_measured_report_filter_k: 1.0 (float)
Ibus: 0.0 (float)
Id_measured: 0.0 (float)
Id_setpoint: 0.0 (float)
Iq_measured: 0.0 (float)
Iq_setpoint: 0.0 (float)
acim_rotor_flux: 0.0 (float)
async_phase_offset: 0.0 (float)
async_phase_vel: 0.0 (float)
final_v_alpha: 0.0 (float)
final_v_beta: 0.0 (float)
i_gain: 393.37945556640625 (float)
max_allowed_current: 60.75 (float)
overcurrent_trip_level: 67.5 (float)
p_gain: 0.5604587197303772 (float)
v_current_control_integral_d: 0.0 (float)
v_current_control_integral_q: 0.0 (float)
current_meas_phB: 0.10371589660644531 (float)
current_meas_phC: 0.038558244705200195 (float)
effective_current_lim: 10.0 (float)
error: 0 (int32)
gate_driver:
drv_fault: 0 (int32)
is_calibrated: True (bool)
phase_current_rev_gain: 0.02500000037252903 (float)
timing_log:
adc_cb_dc: 12850 (uint16)
adc_cb_i: 2622 (uint16)
enc_calib: 55657 (uint16)
foc_current: 50612 (uint16)
foc_voltage: 7754 (uint16)
general: 19717 (uint16)
idx_search: 19076 (uint16)
meas_l: 7790 (uint16)
meas_r: 7706 (uint16)
sample_now: 25048 (uint16)
spi_end: 28598 (uint16)
spi_start: 11627 (uint16)

In [24]: odrv0.axis0.motor.config.pre_calibrated = True

In [25]: odrv0.axis0.encoder.config.calib_range = 0.05

In [26]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

In [27]: odrv0.axis0.encoder
Out[27]:
calib_scan_response: 1537.0 (float)
config:
abs_spi_cs_gpio_pin: 1 (uint16)
bandwidth: 1000.0 (float)
calib_range: 0.05000000074505806 (float)
calib_scan_distance: 50.26548385620117 (float)
calib_scan_omega: 12.566370964050293 (float)
cpr: 90 (int32)
enable_phase_interpolation: True (bool)
find_idx_on_lockin_only: False (bool)
idx_search_unidirectional: False (bool)
ignore_illegal_hall_state: False (bool)
mode: 1 (int32)
offset: 0 (int32)
offset_float: 0.0 (float)
pre_calibrated: False (bool)
sincos_gpio_pin_cos: 4 (uint16)
sincos_gpio_pin_sin: 3 (uint16)
use_index: False (bool)
zero_count_on_find_idx: True (bool)
count_in_cpr: 81 (int32)
error: 2 (int32)
hall_state: 2 (uint8)
index_found: False (bool)
interpolation: 0.5 (float)
is_ready: False (bool)
phase: -2.6179845333099365 (float)
pos_abs: 0 (int32)
pos_circular: 0.9027752876281738 (float)
pos_cpr: 0.9027776122093201 (float)
pos_cpr_counts: 81.24998474121094 (float)
pos_estimate: -17.100000381469727 (float)
pos_estimate_counts: -1539.0 (float)
set_linear_count(obj: object_ref, count: int32)
shadow_count: -1539 (int32)
spi_error_rate: 0.0 (float)
vel_estimate: 0.0 (float)
vel_estimate_counts: 0.0 (float)

In [28]: odrv0.reboot()
Oh no odrv0 disappeared

Reconnected to ODrive v3.6 205B305F594D (firmware v0.5.1) as odrv0
In [29]: odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

In [30]: odrv0.axis0.motor.config.pre_calibrated = True

In [31]: odrv0.axis0.encoder.config.calib_range = 0.05

In [32]: odrv0.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION

In [33]: odrv0.axis0.encoder
Out[33]:
calib_scan_response: 48.0 (float)
config:
abs_spi_cs_gpio_pin: 1 (uint16)
bandwidth: 1000.0 (float)
calib_range: 0.05000000074505806 (float)
calib_scan_distance: 50.26548385620117 (float)
calib_scan_omega: 12.566370964050293 (float)
cpr: 90 (int32)
enable_phase_interpolation: True (bool)
find_idx_on_lockin_only: False (bool)
idx_search_unidirectional: False (bool)
ignore_illegal_hall_state: False (bool)
mode: 1 (int32)
offset: -21 (int32)
offset_float: -0.48596876859664917 (float)
pre_calibrated: False (bool)
sincos_gpio_pin_cos: 4 (uint16)
sincos_gpio_pin_sin: 3 (uint16)
use_index: False (bool)
zero_count_on_find_idx: True (bool)
count_in_cpr: 2 (int32)
error: 0 (int32)
hall_state: 2 (uint8)
index_found: False (bool)
interpolation: 0.5 (float)
is_ready: True (bool)
phase: -0.014689207077026367 (float)
pos_abs: 0 (int32)
pos_circular: 0.030557870864868164 (float)
pos_cpr: 0.03055555932223797 (float)
pos_cpr_counts: 2.750000238418579 (float)
pos_estimate: 0.03333329036831856 (float)
pos_estimate_counts: 2.9999961853027344 (float)
set_linear_count(obj: object_ref, count: int32)
shadow_count: 2 (int32)
spi_error_rate: 0.0 (float)
vel_estimate: 0.0 (float)
vel_estimate_counts: 0.0 (float)

In [34]: odrv0.axis0.encoder.config.pre_calibrated = True

In [35]: odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

In [36]: odrv0.axis0.config.startup_closed_loop_control = True

In [37]: odrv0.save_configuration()

In [38]: odrv0.reboot()
Oh no odrv0 disappeared

Reconnected to ODrive v3.6 205B305F594D (firmware v0.5.1) as odrv0
In [39]: odrv0.axis0.controller.input_vel = 5

In [40]: odrv0.axis0.controller.input_vel = 0

In [41]: odrv0.config.gpio3_pwm_mapping.min = -20

In [42]: odrv0.config.gpio3_pwm_mapping.max = 20

In [43]: odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property

In [44]: odrv0.save_configuration()

In [45]: odrv0.reboot()
O

Bonjour

Je ne suis pas sûr je comprends ce que vous voulez. Quand vous voulez contrôler moteur 0 avec GPIO3 et moteur 1 avec GPIO4.

odrv0.config.gpio3_pwm_mapping.min = -20
odrv0.config.gpio3_pwm_mapping.max = 20
odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property

odrv0.config.gpio4_pwm_mapping.min = -20
odrv0.config.gpio4_pwm_mapping.max = 20
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._input_vel_property

Stijn

bonjour
non ce n’est pas ce que je souhaite.
il s’agit de roue de hoverboard
le gpio 3 doit commander les deux moteurs dans le sens horaire et anti horaire,(autrement dit la marche avant et arriere.)
et le gpio 4 les 2 moteurs egalement mais l’un dans le sens horaire et l’autre dans le sens anti horaire,(autrement dit la direction) car si l’un des moteurs avance et l’autre recule alors il tourne sur lui meme comme un char d’assaut

exemple https://youtu.be/P9L5MrHEN-k

cordialement benoit

Bonjour

Je ne pense pas que c’est possible. Je pense que c’est possible de controller les deux moteur avec une GPIO mais pas une moteur avec deux GPIO.

odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._input_vel_property

Cordialement

Stijn