Skip to main content

Posible bug sending motor home ?

Posted in

Hello, sorry for my English
I´m a beginner programming and may be that this is not a bug

when you send a motor to home you use:

void send_motor_home(byte motor) {

if( motor_home[motor] == 0 )
return;

boolean was_dir = motor_dir[motor];

if( motor_home < 0 ) {
set_motor_dir(motor, 1);
}
else {
set_motor_dir(motor, 0);
}
motor_pulse_steps_linear( motor, abs(motor_home[motor]) ); *************
set_motor_dir( motor, was_dir );
motor_home[motor] = 0;
return;

** but you define motor_home as long
long motor_home[3] = {0,0,0};

** and steps in motor_pulse_steps_linear as integer
void motor_pulse_steps_linear( byte motor, unsigned int steps )

** then, if you move a motor more than 65535 steps I think that the motor don´t goes home correctly.

I have modify your code to send via serial info to my computer and when I sent the next commands to the arduino via openmoco_slim
set_motor 0 home on
move 0 0 65000
move 0 0 2000
home 0
I get in the terminal this response
m= 0 d = 0 p = 65000

m= 0 d = 0 p = 2000

m= 0 d = 0 p = 1464

thus the direction and number of steps are not correct.

In other hand
in the help and examples of set_motor command you write
home

sets current motor axis position as home.
You may later ask the motor to return to this
position by using the "home" command.

Examples:

> set_motor 0 home

sets the current position of motor axis 0 as
home

and if you enter
[92] > set_motor 0 home
DBG: set_motor:0:home
[set_motor] ERROR: Not Enough Arguments
[93] >

and in my version of openmoco_slim the correct it works if you write

set_motor 0 home on

thank you for your work
best regards
Inco.

Inco - thanks! Most of what

Inco - thanks! Most of what you've reported we've found and fixed in the 0.82 (currently in-dev) version, except that typedef error between motor_home[] values and motor_pulse_steps_linear(). (And, that's a big one!)

If you haven't tried 0.82 yet, I highly recommend it - lots of issues fixed and new features. More info about it, and the related changes to the perl lib and the slim application are here: Engine 0.82 - Bi-directional serial communication, Timelapse lib on sourceforge: branches/0.03, and Slim on sourceforge: branches/0.12

This version of slim does have 'motor 0 home' and 'motor x enable' working w/o the extra option, but I think the action help may still have the arguments off.

I'll fix that typedef error in the next check-in, and check the help text.

!c