Gearchange comp. - Problem with spindle speed
30 Dec 2019 12:39 #153548
by Cynas
Gearchange comp. - Problem with spindle speed was created by Cynas
Hello, I'm trying to run a gear change using the component
everything works fine if it uses:however, the value changes when I use the spindle speed potentiometer, and this is incorrect for me.
I found a constant value for the spindle speed
unfortunately the gearbox doesn't want to work properly. The spindle always starts in low gear despite the fact that the HAL METER values are correct and visible.
I also tried to use the converter with float-> s32 and s32-> float
Anyone know why this is happening ??
Is there another signal that would be helpful to me?
Thank you for your help
component gearchangefadal "A component to choose spindle gears according to spindle speed";
pin in float speed-command;
pin in bit spindle-on;
pin in bit manual-low;
pin in bit manual-high;
pin in bit brake-enable;
pin out float motor-speed;
pin out bit low-gear;
pin out bit high-gear;
pin out bit brake;
param rw float low-ratio=3;
param rw float high-ratio=1;
param rw float max-low = 50;
author "andy pugh";
license "GPL";
function _;
;;
FUNCTION(_){
static int old_M3;
if (spindle_on) {
if (!old_M3){ // spindle off to on transition
if (manual_high) {
high_gear = 1;
low_gear = 0;
brake = 0;
}
else if (manual_low){
high_gear = 0;
low_gear = 1;
brake = 0;
} else if (speed_command <= max_low){
high_gear = 0;
low_gear = 1;
brake = 0;
} else {
high_gear = 1;
low_gear = 0;
brake = 0;
}
}
} else { //spindle off
brake = brake_enable;
}
old_M3 = spindle_on;
if (high_gear){
motor_speed = speed_command * high_ratio;
} else if (low_gear){
motor_speed = speed_command * low_ratio;
}
}
everything works fine if it uses:
net spindle-vel-cmd-rpm-abs => gearchange.0.speed-command
I found a constant value for the spindle speed
net spindle-speed-cmd-rps <= motion.spindle-speed-cmd-rps
net spindle-speed-cmd-rps => gearchange.0.speed-command
unfortunately the gearbox doesn't want to work properly. The spindle always starts in low gear despite the fact that the HAL METER values are correct and visible.
I also tried to use the converter with float-> s32 and s32-> float
Anyone know why this is happening ??
Is there another signal that would be helpful to me?
Thank you for your help
Please Log in or Create an account to join the conversation.
30 Dec 2019 15:14 #153551
by PCW
Replied by PCW on topic Gearchange comp. - Problem with spindle speed
Can you post your hal file?
The following user(s) said Thank You: Cynas
Please Log in or Create an account to join the conversation.
31 Dec 2019 16:56 #153615
by Cynas
Replied by Cynas on topic Gearchange comp. - Problem with spindle speed
Thank you for your interest
I solved the problem. I don't know why when I was sending the ABS value to the component it did not work properly.
I am using now:
and in the component I changed:
I tried to add: else if ( absf ( speed_command ) <= max_low), but it displays an error, and I took shortcuts
best regards
ps: I will give it all, maybe someone will be useful
I solved the problem. I don't know why when I was sending the ABS value to the component it did not work properly.
I am using now:
net spindle-speed-cmd-rps <= motion.spindle-speed-cmd-rps
net spindle-speed-cmd-rps => gearchangefadal.0.speed-command
and in the component I changed:
else if (speed_command >= (max_low)*(-1) && speed_command <= max_low){
high_gear = 0;
low_gear = 1;
brake = 0;
I tried to add: else if ( absf ( speed_command ) <= max_low), but it displays an error, and I took shortcuts
best regards
ps: I will give it all, maybe someone will be useful
component gearchangefadal "A component to choose spindle gears according to spindle speed";
pin in float speed-command;
pin in bit spindle-on;
pin in bit manual-low;
pin in bit manual-high;
pin in bit brake-enable;
pin out float motor-speed;
pin out bit low-gear;
pin out bit high-gear;
pin out bit brake;
param rw float low-ratio=3;
param rw float high-ratio=1;
param rw float max-low = 50;
author "andy pugh";
license "GPL";
function _;
;;
FUNCTION(_){
static int old_M3;
float fabsf;
if (spindle_on) {
if (!old_M3){ // spindle off to on transition
if (manual_high) {
high_gear = 1;
low_gear = 0;
brake = 0;
}
else if (manual_low){
high_gear = 0;
low_gear = 1;
brake = 0;
} else if (speed_command >= (max_low)*(-1) && speed_command <= max_low){
high_gear = 0;
low_gear = 1;
brake = 0;
} else {
high_gear = 1;
low_gear = 0;
brake = 0;
}
}
} else { //spindle off
brake = brake_enable;
}
old_M3 = spindle_on;
if (high_gear){
motor_speed = speed_command * high_ratio;
} else if (low_gear){
motor_speed = speed_command * low_ratio;
}
}
The following user(s) said Thank You: J Green
Please Log in or Create an account to join the conversation.
Time to create page: 0.064 seconds