- Posts: 476
- Thank you received: 52
Orient component revised
6 years 8 months ago #157082
by alkabal
Replied by alkabal on topic Orient component
Hi
Without the use of ini file i have try to add spindle homing immediatly after axis.0.homed = 1
But i have many trouble understanding what append with the spindle index-enable status and the checking process.
You suggest to check elsewhere in the linuxcnc code regarding to the homing sequence ?
Can i ask what do you think about :
1 - including some new pin for more easy setup in the actual component
2 - changing the command logic like i try to do with orientv4
Br
Without the use of ini file i have try to add spindle homing immediatly after axis.0.homed = 1
But i have many trouble understanding what append with the spindle index-enable status and the checking process.
You suggest to check elsewhere in the linuxcnc code regarding to the homing sequence ?
Can i ask what do you think about :
1 - including some new pin for more easy setup in the actual component
2 - changing the command logic like i try to do with orientv4
Br
Please Log in or Create an account to join the conversation.
6 years 8 months ago #158538
by andypugh
Replied by andypugh on topic Orient component
Sorry, I have been away from the forums for a while.
If you can be sure that the spindle will always turn past the index before the first tool change, then you could simply
sets spindle-index-enable 1
in the HAL file. (but spindle-index-enable should be replaced by whatever the signal that is attached to your spindle index really is called in your config)
A custom HAL component that the spindle speed commands pass through could work. It would also need a HAL pin to toggle and sense the index-enable.
ie, it sees asis.N.home go true, it over-rides the pass-through spindle commands to a low speed and sets the spindle-index-enable. It then returns to passive pass-through mode when the index-enable goes false.
If you can be sure that the spindle will always turn past the index before the first tool change, then you could simply
sets spindle-index-enable 1
in the HAL file. (but spindle-index-enable should be replaced by whatever the signal that is attached to your spindle index really is called in your config)
A custom HAL component that the spindle speed commands pass through could work. It would also need a HAL pin to toggle and sense the index-enable.
ie, it sees asis.N.home go true, it over-rides the pass-through spindle commands to a low speed and sets the spindle-index-enable. It then returns to passive pass-through mode when the index-enable goes false.
Please Log in or Create an account to join the conversation.
6 years 8 months ago #158882
by alkabal
Replied by alkabal on topic Orient component
Hi
Sorry for late reply, i'm a little busy converting my lathe from MK to LinuxCNC with mesa 7i76e + rpi4.
I check a little more for this component asap.
Br, thanks for reply
Sorry for late reply, i'm a little busy converting my lathe from MK to LinuxCNC with mesa 7i76e + rpi4.
I check a little more for this component asap.
Br, thanks for reply
Please Log in or Create an account to join the conversation.
6 years 7 months ago - 6 years 7 months ago #160238
by alkabal
Replied by alkabal on topic Orient component
Hello
Restarting to work with my component, but i have some trouble for direction calculation, i'm sure it's some simple error but...
Any help or report proble is really welcom, i will like to be very simple for setup and if i'm not in wrong direction i like to do a accurate orient process.
I have added a automatic spindle homing process immediately after first axis is homed.
Attached is component file
hal setup is here :
Restarting to work with my component, but i have some trouble for direction calculation, i'm sure it's some simple error but...
Code:
// 100% sure someone can write this calc more cleaner...
rev = position; // converting to int for extract full rev only for internal calc
tempcalc = (position - rev) * 360.0; // converting to degree in a -360 to 360 range
// converting to degree in 0 to 360 to 0 range
if (tempcalc < 0) scaled_angle_out = 360 + tempcalc; else scaled_angle_out = tempcalc;
angle_deviation = angle_scaled_out - angle;
// 100% sure someone can write this calc more cleaner...
Code:
if (angle_deviation < 0 && fabs angle_deviation > 180) cmd_to_pid_orient = -vel_speed; else cmd_to_pid_orient = vel_speed;
if (angle_deviation > 0 && fabs angle_deviation > 180) cmd_to_pid_orient = vel_speed; else cmd_to_pid_orient = vel_speed;
Any help or report proble is really welcom, i will like to be very simple for setup and if i'm not in wrong direction i like to do a accurate orient process.
I have added a automatic spindle homing process immediately after first axis is homed.
Attached is component file
hal setup is here :
Code:
#####################################################################
# Spindle orient mode
#####################################################################
loadrt orientv4 names=orient.orient-spindle
loadrt pid names=pid.orient-spindle
addf orient.orient-spindle servo-thread
addf pid.orient-spindle.do-pid-calcs servo-thread
# setup Orient Spindle PID
setp pid.orient-spindle.Pgain [ORIENT]P
setp pid.orient-spindle.Igain [ORIENT]I
setp pid.orient-spindle.Dgain [ORIENT]D
setp pid.orient-spindle.FF0 [ORIENT]FF0
setp pid.orient-spindle.FF1 [ORIENT]FF1
setp pid.orient-spindle.FF2 [ORIENT]FF2
setp pid.orient-spindle.bias [ORIENT]BIAS
setp pid.orient-spindle.deadband [ORIENT]DEADBAND
setp pid.orient-spindle.maxerror [ORIENT]MAX_ERROR
setp pid.orient-spindle.maxerrorI [ORIENT]MAX_ERROR_I
setp pid.orient-spindle.maxoutput [ORIENT]MAX_OUTPUT
setp orient.orient-spindle.vel-speed [ORIENT]VEL_SPEED
setp orient.orient-spindle.tolerance [ORIENT]AT_ANGLE_TOL
# encoder connections feedback
net spindle-pos => orient.orient-spindle.position
net spindle-pos-deg <= orient.orient-spindle.scaled-angle-out
# Index connection
net spindle-index-enable <=> orient.orient-spindle.index-enable
net spindle-index-enable => pid.orient-spindle.index-enable
# Spindle homing link for homing spindle with machine homing
net machinehomed <= joint.0.homed
net machinehomed => orient.orient-spindle.machine-is-homed
# Set asked mode from M19 P0/1/2
net spindle-orient-mode <= spindle.0.orient-mode
net spindle-orient-mode => orient.orient-spindle.mode
# If spindle is not homed report error and cancel orient process
net spindle-orient-error <= orient.orient-spindle.error-not-homed
net spindle-orient-error => spindle.0.orient-fault
# Spindle orient enable control signals
net spindle-orient-enable <= spindle.0.orient
net spindle-orient-enable => orient.orient-spindle.enable
# Pid enable from orient component
net spindle-orient-pid-ena <= orient.orient-spindle.ena-out-pid-muxed
net spindle-orient-pid-ena => pid.orient-spindle.enable
# enable out for controler from regular spindle or orient mode
net spindle-enable => orient.orient-spindle.ena-from-velocity
net spindle-orient-enable-out <= orient.orient-spindle.ena-out-muxed
# moved in the orient input/output but initially in spindle setup
net spindle-orient-enable-out => [HMOT](CARD0).7i83.0.0.analogena0
# Is oriented near signal + link position asked to component
net spindle-orient-degree-cmd <= spindle.0.orient-angle
net spindle-orient-degree-cmd => orient.orient-spindle.angle
net spindle-is-oriented <= orient.orient-spindle.is-oriented
net spindle-is-oriented => spindle.0.is-oriented
# Command to pid from component by velocity and velocity feedback
net spindle-orient-vel <= orient.orient-spindle.cmd-to-pid-orient
net spindle-orient-vel => pid.orient-spindle.command
net spindle-vel-rpm => pid.orient-spindle.feedback # feedback velocity mode
# Input speed velocity from normal mode inside component
# the component passthru the spindle velocity to the Card signal generator or send orient velocity
net spindle-orient-pid-in-out <= pid.orient-spindle.output
net spindle-orient-pid-in-out => orient.orient-spindle.cmd-from-pid-orient
net spindle-vel-cmd-out => orient.orient-spindle.cmd-from-pid-velocity
net spindle-orient-ctrl-out <= orient.orient-spindle.cmd-out-muxed
# moved in the orient input/output but initially in spindle setup
net spindle-orient-ctrl-out => [HMOT](CARD0).7i83.0.0.analogout0
Last edit: 6 years 7 months ago by alkabal.
Please Log in or Create an account to join the conversation.
6 years 7 months ago - 6 years 7 months ago #160778
by andypugh
- else +
+ else +
That seems inconsistent.
Also, doesn't it need to be fabs(something) ?
Consider angle_deviation = 100. Both conditions are false, so cmd_to_orient_pid is not set. Is that what you want?
I think I would have something like.
Replied by andypugh on topic Orient component
Code:
if (angle_deviation < 0 && fabs angle_deviation > 180) cmd_to_pid_orient = -vel_speed; else cmd_to_pid_orient = vel_speed;
if (angle_deviation > 0 && fabs angle_deviation > 180) cmd_to_pid_orient = vel_speed; else cmd_to_pid_orient = vel_speed;
- else +
+ else +
That seems inconsistent.
Also, doesn't it need to be fabs(something) ?
Consider angle_deviation = 100. Both conditions are false, so cmd_to_orient_pid is not set. Is that what you want?
I think I would have something like.
Code:
if ( angle_deviation > 0){
if (fabs(angle_deviation) > 180){
command_to_orient_pid = -vel_speed;
} else {
command_to_orient_pid = vel_speed;
}
} else {
if (fabs(angle_deviation) > 180){
command_to_orient_pid = vel_speed;
} else {
command_to_orient_pid = -vel_speed;
}
}
Last edit: 6 years 7 months ago by andypugh.
Please Log in or Create an account to join the conversation.
6 years 7 months ago - 6 years 7 months ago #160792
by alkabal
Replied by alkabal on topic Orient component
Yes sorry this is a tipo mistake inside last attempt, but unfortunatly nothing work 100% from this way else without this error
angle_deviation can be positive or negative and if more than 180% need to reverse direction.
Maybee i'm thinking about bad initialised variable because with your more cleaner solution this does not work fine from 0 as 120 and spindle go reverse, from 120 to 140 run reverse, from 140 to 120 run reverse (but is ok for this one lol)
also try
Thanks
angle_deviation can be positive or negative and if more than 180% need to reverse direction.
Maybee i'm thinking about bad initialised variable because with your more cleaner solution this does not work fine from 0 as 120 and spindle go reverse, from 120 to 140 run reverse, from 140 to 120 run reverse (but is ok for this one lol)
also try
Code:
if (fabs(angle_deviation) > 180){
if (angle_deviation > 0){
cmd_to_pid_orient = vel_speed;
} else {
cmd_to_pid_orient = -vel_speed;
}
} else {
if (angle_deviation > 0){
cmd_to_pid_orient = -vel_speed;
} else {
cmd_to_pid_orient = vel_speed;
}
}
Thanks
Last edit: 6 years 7 months ago by alkabal.
Please Log in or Create an account to join the conversation.
Time to create page: 0.063 seconds