Thank you very much for the answer. I’d like to know a little more. Please answer a few more questions so that I understand which way to move.
About the smoothed motion and movement of the motor at the desired position with a constant current and different speeds -> I think that the most suitable way would still be to use SetPosition and delay commands.
Since the movement to the positive (pushing) load the motor will try to overtake its position and we will have to brake it.
The variant that was proposed in the cos-cycle Arduino demonstrates very clearly that it is possible to change the speed at a constant current.
for (float ph = 0.0f; ph < 6.28318530718f; ph += 0.01f) {
float pos_m0 = 20000.0f * cos(ph);
odrive.SetPosition(0, pos_m0);
delay(5);
}
The only question is how to know the current speed of the motor to calculate the stop/acceleration curve or track the desired speed to move.
It can be measured by obtaining a position at a specified interval
Please could you answer the question is it possible?
- I’ll call the drive command odrive.GetParameter (motor, drive.PARAM_FLOAT_ENCODER_PL_POS)
- I’ll call the odrive odrive.GetParameter again after some time
What is the minimum (or constant) time interval can be when working through сom-port via Teensy?
I have a Teensy 3.5 and I will work through com port with Odrive, because Arduino does not give stable results. I did some tests with Arduino and got this
I run the command odrive.SetPosition(0, 10000);
After process finished I run this commands for a few seconds
odrive.GetParameter(0, odrive.PARAM_FLOAT_ENCODER_PLL_POS)
odrive.GetParameter(0, odrive.PARAM_FLOAT_POS_SETPOINT)
And such unstable values was returned
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 9976.8818
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 18007.4003
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 18810.0000
PARAM_FLOAT_ENCODER_PLL_POS 9.0000
PARAM_FLOAT_ENCODER_PLL_POS 18006.0996
So , Oscar advised me to use Teensy.
He wrote
I assume you are using SoftwareSerial on the Arduino? SoftwareSerial is rally crap, and it’s better if you use a more powerful arduino like Teensy (recommended), or Arduino Mega.`
Another very important question for me is whether I need to start rewriting the FirmWare by myself or whether I can solve it with your help.
Here is on this video with test motor D5065 and Zindex encoder Omron 2500 cpr. I done the calibration successful.
And then changed randomly the initial position of the motor in the off and after turning on the index was found, and then the motor was taken to the position in which it was when turned on.
On the video i did folowing
- the motor is on in the position in which I calibrated the encoder with index signal. Therefore when i switched on everything is fine and CLOSED_LOOP retains Z index position.
- I changed the initial position of the motor and turned on the Odrive - the motor has shifted relative to the Z index and CLOSED_LOOP retains NON Z index position
What should be done to prevent this from happening ? How to reset (set to 0) or change offset so when the index is found, the motor automatically remains in the index position, even if the positions when turned on are different?
Oscar gave me a link to a function
void Encoder::enc_index_cb() {
if (config_.use_index && !index_found_) {
set_circular_count(0);
if (config_.pre_calibrated) {
offset_ = config_.offset;
is_ready_ = true;
}
index_found_ = true;
}
}
I still hope that I do not have to disassemble the FirmWare to rewrite the initialization algorithm encoder or maybe you can tell me how best. Because with further changes FirmWare will have to transfer all the code in to the new version.
Let me show you the picture of my manipulator.
Shoulders very long, the resolution of the encoder 17500.
It will be very difficult to make such a Home switch that the initial position is always exactly the same. Therefore i can’t
Mount the encoder in such a way that the index pulse occurs exactly at the intended home position
You wrote
Find the offset from index to home, and always use that
. How to do it?
Without an absolute encoder i never know the position in which the motor when turned on. I know only position of the Z index. The absolute encoder is not yet supported by Odrive but its resolution is up to 4096 and you will not be able to use pulleys, so Z index encoder itself is the best option in my opinion.
The easiest way out in my opinion is to make a new parameter in json config so that offset is set to 0 immediately after finding the index and no motor moves after this
“axis0”: {
“config”: {
“startup_motor_calibration”: true,
“startup_encoder_index_search”: true,
“startup_encoder_offset_calibration”: false,
“startup_closed_loop_control”: true,
“startup_sensorless_control”: false,
“enable_step_dir”: false,
“counts_per_step”: 2,
“ramp_up_time”: 0.4000000059604645,
“ramp_up_distance”: 12.566370964050293,
“spin_up_current”: 10,
“spin_up_acceleration”: 400,
“spin_up_target_vel”: 400,
Add smth like this
“set_position0_to_encoder_index”: true