Motor = spring ?how?

OMG!!! :slight_smile: :rofl: :rofl: :man_facepalming: :man_facepalming: :man_facepalming:

CONFIGURATION HAS TO BE SAVED BEFORE FULL_CALLIB

abs_spi_cs_gpio_pin=4
encoder.config.mode=257
cpr=2**14
save_configuration() !!!
full_calibration

1 Like

both boards are working :slight_smile:
I’ll try anticogging now

1 Like

I think you actually have to reboot to configure the encoders as absolute. This is the configuration I use for the AS5048A:

odrv0.axis0.encoder.config.mode = 257
odrv0.axis0.encoder.config.cpr = 2**14
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin = 8
odrv0.axis1.encoder.config.mode = 257
odrv0.axis1.encoder.config.cpr = 2**14
odrv0.axis1.encoder.config.abs_spi_cs_gpio_pin = 7

odrv0.axis0.config.startup_closed_loop_control = True
odrv0.axis0.config.startup_encoder_offset_calibration = True
odrv0.axis0.config.startup_motor_calibration = True

odrv0.save_configuration()
odrv0.reboot()

I just wrote an anticogging documentation, too, so definitely check that out. https://github.com/madcowswe/ODrive/blob/devel/docs/anticogging.md

:heart_eyes:

I think that lack of documentation is the weakest part of the ODrive :confused:
Fortunately you guys do a great job on forum and discord chat.

I’ll give a try anticogging later and give a shout how it works with better encoder resolution.

regarding this,
" Now, tune the motor to be very stiff - high pos_gain and relatively high vel_integrator_gain . This will help in calibration."
for people who just started playing with the ODrive it might be hard to guess those parameters.
any hints here?
my default values/gains are:
.pos_gain=20
.vel_gain=0.1666666
.vel_integrator_gain=0.3333

I’ve tried many different settings/combinations of the above.
Today I tried
100/default/3
and finally my anticogging_calib takes ~1min (previously >5)

odrv0.axis0.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL
CONTROL_MODE_POSITION_CONTROL - not defined
CTRL_… should work?
same here:
INPUT_MODE_PASSTHROUGH (weird, because it is defined in controller.cpp)

in the example (from your docs):
in spi mode, do we have to use
odrv0.axis0.encoder.config.use_index = True
?
(with the line above, calibration failed, so I guess no index needed in the spi mode)

Perhaps, you could also add to your example a few lines after reboot()
i.e. how to start anticogging and which calibration should be done at the beginning.
(there is a line controller.config.anticogging.pre_calibrated = True to reload it at the beginning, but do I need a full calib always after reboot?)
( The anticogging map can be reloaded automatically at startup by setting controller.config.anticogging.pre_calibrated = True
I think it will be True already;
maybe:
odrv0.axis0.controller.config.anticogging_enabled=True
instead?)

(Im slightly confused:
In SPI mode, I do anticogging only once, but do I have to do full calib after each reboot?;
my goal is to build a device which will be mechanically blocked at certain position - motor shaft will be able to do ~3 revolutions however it will always be connected to some other mechanics. Will I be able to use the ODrive at all? )

so, here Is my setup for D6374+AS5047p (SPI mode)

odrv0.axis0.encoder.config.mode=257
odrv0.axis0.encoder.config.mode.cpr=2**14
odrv0.axis0.encoder.config.abs_spi_cs_gpio_pin=4

odrv0.save_configuration() //YOU MUST SAVE&REBOOT OTHERWISE
odrv0.reboot() //IT WILL NOT WORK ?

odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
odrv0.axis0.encoder.config.pre_calibrated = True
odrv0.axis0.motor.config.pre_calibrated = True

#adjust gains here:
odrv0.axis0.controller.config.pos_gain=100
#my default gain was 20
#so…default gain x5

#odrv0.axis0.controller.config.vel_gain#leave it
#my default gain was 0.16

odrv0.axis0.controller.config.vel_integrator_gain=3
#my default gain was 0.33333
#default gain x 10

odrv0.axis0.controller.config.control_mode = CTRL_MODE_POSITION_CONTROL

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis0.controller.start_anticogging_calibration()

#after ~1 minute (the motor shaft slowly moves in one direction. when its finished it spins back to initial position?

#adjust gains back to the default values
odrv0.axis0.controller.config.pos_gain=20
odrv0.axis0.controller.config.vel_integrator_gain=0.3

odrv0.axis0.controller.config.anticogging.pre_calibrated = True
odrv0.save_configuration()
odrv0.reboot()

####################
odrv0.axis0.controller.config.anticogging.anticogging_enabled=True

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis0.controller.config.anticogging.anticogging_enabled=True/False - to check if it works

So, it looks like if you do the above sequence (spi encoder), after every boot you can go straight to closed loop control and everything shoud be done. Theres no need to do the motor and encoder calibration. ?

1 Like

FULL_CALIBRATION_SEQUENCE is just MOTOR_CALIBRATION followed by ENCODER_OFFSET_CALIBRATION in most cases. So you already did it.

And this should be done only once? Than I can attach the rest of mechanics and forget about it?

In SPI mode, yes. Don’t forget to set encoder.config.pre_calibrated=True before you save, though! And motor.config.pre_calibrated=True too

1 Like

It looks like few problems have been solved here :slight_smile: thank you guys!

Im running into a new one related to the power supply here: Power supply + battery?