- Posts: 12170
- Thank you received: 4153
My Grizzly G0619 mill
- rodw
- Offline
- Platinum Member
-
Less
More
5 years 4 months ago #213102
by rodw
Replied by rodw on topic My Grizzly G0619 mill
I wasn't trying to be smart, I just wanted to give more food for thought. Its really good you are working with hal and trying to do some of the harder stuff. There was an example in the docs that I found useful but it still needed some work and converting to the mesa encoders..
I've actually been meaning to take my MPG code and move it into a dedicated hal file so it can be shared
Here is what I came up with excluding the loadrt and addf commands.. Still not sure the ilowpass has been done correct. First time I tried to use it I had a massive crash because 1 click was equal to one metre!
Hmm, I wonder where the preview has gone?
I've actually been meaning to take my MPG code and move it into a dedicated hal file so it can be shared
Here is what I came up with excluding the loadrt and addf commands.. Still not sure the ilowpass has been done correct. First time I tried to use it I had a massive crash because 1 click was equal to one metre!
Warning: Spoiler!
Code:
# ilowpass filter
setp ilowpass.0.scale 10
setp ilowpass.0.gain 0.01
# Setup Jog Pendant on each axis
setp axis.x.jog-vel-mode 0
setp axis.y.jog-vel-mode 0
setp axis.z.jog-vel-mode 0
# Scale Select metric (mm)
setp mux4.0.in0 0.0
setp mux4.0.in1 1.0
setp mux4.0.in2 0.01
setp mux4.0.in3 0.1
#Axis Select (0=off, 1=x, 2=z, 3=y, na, 5=6, 6=4, 7=5)
setp mux8.0.in0 0
setp mux8.0.in1 1
setp mux8.0.in2 2
setp mux8.0.in3 3
setp mux8.0.in4 4
setp mux8.0.in5 5
setp mux8.0.in6 6
setp mux8.0.in7 7
net mux8-sel0 <= hm2_7i76e.0.7i76.0.0.input-23
net mux8-sel1 <= hm2_7i76e.0.7i76.0.0.input-24
net mux8-sel2 <= hm2_7i76e.0.7i76.0.0.input-25
net mux8-sel0 => mux8.0.sel0
net mux8-sel1 => mux8.0.sel1
net mux8-sel2 => mux8.0.sel2
net mux-float conv-float-s32.1.in <= mux8.0.out
net mux-s32 <= conv-float-s32.1.out
net mux-s32 => select8.0.sel
net axis-select-x <= select8.0.out1
net axis-select-y <= select8.0.out3
net axis-select-z <= select8.0.out2
net axis-select-4 <= select8.0.out6
net axis-select-5 <= select8.0.out7
net axis-select-6 <= select8.0.out5
net axis-select-x => axis.x.jog-enable
net axis-select-y => axis.y.jog-enable
net axis-select-z => axis.z.jog-enable
# Encoder counts
net jog-counter <= hm2_7i76e.0.7i76.0.0.enc0.count
net jog-counter => ilowpass.0.in
net smooth-counter <= ilowpass.0.out
net jog-counter => axis.x.jog-counts
net jog-counter => axis.y.jog-counts
net jog-counter => axis.z.jog-counts
net mux4-sel1 <= hm2_7i76e.0.7i76.0.0.input-22
net mux4-sel0 <= hm2_7i76e.0.7i76.0.0.input-21
net mux4-sel1 => mux4.0.sel1
net mux4-sel0 => mux4.0.sel0
net jog-scale <= mux4.0.out
net jog-scale => axis.x.jog-scale
net jog-scale => axis.y.jog-scale
net jog-scale => axis.z.jog-scale
Hmm, I wonder where the preview has gone?
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
-
Less
More
- Posts: 12170
- Thank you received: 4153
5 years 4 months ago #213103
by rodw
Replied by rodw on topic My Grizzly G0619 mill
So I still have to work out how to use these pins to control overrides.
Code:
net axis-select-4 <= select8.0.out6
net axis-select-5 <= select8.0.out7
net axis-select-6 <= select8.0.out5
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- BeagleBrainz
- Visitor
-
5 years 4 months ago - 5 years 4 months ago #213105
by BeagleBrainz
Replied by BeagleBrainz on topic My Grizzly G0619 mill
I got lazy and modified a "all in one user comp" handles all the axis & step selection as well as having separate out pins for the joint & axis select pins. It's a bit rough but I've used it for about a year so far.
And the HAL file
Code:
component mpg_pendant "3 Axis Generic MPG";
description "For use with a generic 4 axis chinese ebay pendant inspired by the mpg component of Kurt Jacobson.";
//license "GPL";
author "Rob Murphy";
//function _;
//Input from non-multiplexed axis selector
pin in bit axis0;
pin in bit axis1;
pin in bit axis2;
pin in bit axis3;
//Input from non-multplexed scale selector
pin in bit scale0;
pin in bit scale1;
pin in bit scale2;
//Input from encoder
pin in s32 encoder_counts;
//Selectable jog scale values
param rw float mpg_scale0=1.00;
param rw float mpg_scale1=0.10;
param rw float mpg_scale2=0.01;
//Axis selection
pin out bit enable_axis_x;
pin out bit enable_axis_y;
pin out bit enable_axis_z;
pin out bit enable_axis_a;
//Joint selection
pin out bit enable_joint_0;
pin out bit enable_joint_1;
pin out bit enable_joint_2;
pin out bit enable_joint_3;
//MPG Scale
pin out float axis_mpg_scale;
pin out float joint_mpg_scale;
//Encoder Counts;
pin out s32 axis_encoder_counts;
pin out s32 joint_encoder_counts;
//Error Pins
pin out bit error_select_axis;
pin out bit error_select_scale;
function _;
license "GPL"; // indicates GPL v2 or later
;;
FUNCTION(_){
// Axis & Joint Selection
if (axis0 && !axis1 && !axis2 && !axis3) {
enable_axis_x = 1;
enable_axis_y = 0;
enable_axis_z = 0;
enable_axis_a = 0;
error_select_axis = 0;
}
else if (!axis0 && axis1 && !axis2 && !axis3) {
enable_axis_x = 0;
enable_axis_y = 1;
enable_axis_z = 0;
enable_axis_a = 0;
error_select_axis = 0;
}
else if (!axis0 && !axis1 && axis2 && !axis3) {
enable_axis_x = 0;
enable_axis_y = 0;
enable_axis_z = 1;
enable_axis_a = 0;
error_select_axis = 0;
}
else if (!axis0 && !axis1 && !axis2 && axis3) {
enable_axis_x = 0;
enable_axis_y = 0;
enable_axis_z = 0;
enable_axis_a = 1;
error_select_axis = 0;
}
// Only error if all axis select = 1
else if (axis0 && axis1 && axis2 && axis3) {
enable_axis_x = 0;
enable_axis_y = 0;
enable_axis_z = 0;
enable_axis_a = 0;
error_select_axis = 1;
}
// None selected
else if (!axis0 && !axis1 && !axis2 && !axis3) {
enable_axis_x = 0;
enable_axis_y = 0;
enable_axis_z = 0;
enable_axis_a = 0;
error_select_axis = 0;
}
enable_joint_0 = enable_axis_x;
enable_joint_1 = enable_axis_y;
enable_joint_2 = enable_axis_z;
enable_joint_3 = enable_axis_a;
// MPG Scale selection
if ( scale0 && !scale1 && !scale2 ) {
axis_mpg_scale = mpg_scale0;
error_select_scale = 0;
}
else if ( !scale0 && scale1 && !scale2 ) {
axis_mpg_scale = mpg_scale1;
error_select_scale = 0;
}
else if ( !scale0 && !scale1 && scale2 ) {
axis_mpg_scale = mpg_scale2;
error_select_scale = 0;
}
else if ( scale0 && scale1 && scale2 ) {
axis_mpg_scale = 0;
error_select_scale = 1;
}
else if ( !scale0 && !scale1 && !scale2 ) {
axis_mpg_scale = 0;
error_select_scale = 1;
}
joint_mpg_scale = axis_mpg_scale;
axis_encoder_counts = encoder_counts;
joint_encoder_counts = encoder_counts;
}
And the HAL file
Code:
Include your custom HAL commands here
# This file will not be overwritten when you run stepconf again
# This file was modified by R Murphy on Dec 24 2019 12:24:00
# This file was modified by R Murphy on Dec 28 2019 20:38:00
loadrt mpg_pendant
addf mpg-pendant.0 servo-thread
loadrt ilowpass
addf ilowpass.0 servo-thread
setp ilowpass.0.scale 1000
setp ilowpass.0.gain 0.01
setp mpg-pendant.0.mpg-scale0 .001
setp mpg-pendant.0.mpg-scale1 .0001
setp mpg-pendant.0.mpg-scale2 .00001
#net encoder-counts <= ilowpass.0.out
# Encoder count inputs
net jog_counts_in ilowpass.0.in <= hm2_7i92.0.7i73.0.1.enc0.count
net jog_counts_out mpg-pendant.0.encoder-counts <= ilowpass.0.out
# Axis/Joint select inputs
net jora_x_0_select_in mpg-pendant.0.axis0 <= hm2_7i92.0.7i73.0.1.input-10-not
net jora_y_1_select_in mpg-pendant.0.axis1 <= hm2_7i92.0.7i73.0.1.input-12-not
net jora_z_2_select_in mpg-pendant.0.axis2 <= hm2_7i92.0.7i73.0.1.input-14-not
# Scale inputs
net scale_select_0_in mpg-pendant.0.scale0 <= hm2_7i92.0.7i73.0.1.input-11-not
net scale_select_1_in mpg-pendant.0.scale1 <= hm2_7i92.0.7i73.0.1.input-13-not
net scale_select_2_in mpg-pendant.0.scale2 <= hm2_7i92.0.7i73.0.1.input-15-not
# Axis Jogging
# Axis encoder outputs
net axis_counts_out <= mpg-pendant.0.axis-encoder-counts
net axis_counts_out => axis.x.jog-counts
net axis_counts_out => axis.y.jog-counts
net axis_counts_out => axis.z.jog-counts
# Axis x-y-z select
net axis_x_enable_out axis.x.jog-enable <= mpg-pendant.0.enable-axis-x
net axis_y_enable_out axis.y.jog-enable <= mpg-pendant.0.enable-axis-y
net axis_z_enable_out axis.z.jog-enable <= mpg-pendant.0.enable-axis-z
# Axis scale
net axis_scale_out <= mpg-pendant.0.axis-mpg-scale
net axis_scale_out => axis.x.jog-scale
net axis_scale_out => axis.y.jog-scale
net axis_scale_out => axis.z.jog-scale
# Joint Jogging
# Joint encoder outputs
net joint_counts_out <= mpg-pendant.0.joint-encoder-counts
net joint_counts_out => joint.0.jog-counts
net joint_counts_out => joint.1.jog-counts
net joint_counts_out => joint.2.jog-counts
# Joint 0-1-2 select
net joint_0_enable_out joint.0.jog-enable <= mpg-pendant.0.enable-joint-0
net joint_1_enable_out joint.1.jog-enable <= mpg-pendant.0.enable-joint-1
net joint_2_enable_out joint.2.jog-enable <= mpg-pendant.0.enable-joint-2
# Joint scale
net joint_scale_out <= mpg-pendant.0.joint-mpg-scale
net joint_scale_out => joint.0.jog-scale
net joint_scale_out => joint.1.jog-scale
net joint_scale_out => joint.2.jog-scale
Last edit: 5 years 4 months ago by BeagleBrainz.
Please Log in or Create an account to join the conversation.
- rodw
- Offline
- Platinum Member
-
Less
More
- Posts: 12170
- Thank you received: 4153
5 years 4 months ago #213107
by rodw
Replied by rodw on topic My Grizzly G0619 mill
Its interesting to see that the component does not really shorten the number of lines of hal file required.
I think that this just shows how complex MPG's are
I think that this just shows how complex MPG's are
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- BeagleBrainz
- Visitor
-
5 years 4 months ago #213112
by BeagleBrainz
Replied by BeagleBrainz on topic My Grizzly G0619 mill
That wasn't the point......I just liked they way it was all "self contained".
Depending on the amount of selector pins there is the possibility of using a diode matrix.
If you have 4 individual inputs for each selector this would reduce to 2.
I don't actually think they are complex, just quite a few inputs to deal with, just a bit of repetition, more than anything else.
Depending on the amount of selector pins there is the possibility of using a diode matrix.
If you have 4 individual inputs for each selector this would reduce to 2.
I don't actually think they are complex, just quite a few inputs to deal with, just a bit of repetition, more than anything else.
Please Log in or Create an account to join the conversation.
- my1987toyota
- Offline
- Platinum Member
-
Less
More
- Posts: 1004
- Thank you received: 449
5 years 4 months ago #213119
by my1987toyota
Replied by my1987toyota on topic My Grizzly G0619 mill
WOW I go to sleep for a few hour and wake up to this . SWEET.
Please Log in or Create an account to join the conversation.
Time to create page: 0.229 seconds