My Grizzly G0619 mill

More
28 Jun 2021 08:12 - 28 Jun 2021 08:13 #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.

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
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: 28 Jun 2021 08:13 by BeagleBrainz.
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
28 Jun 2021 08:31 #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 :)
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
28 Jun 2021 09:34 #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.
The following user(s) said Thank You: Clive S, rodw, my1987toyota

Please Log in or Create an account to join the conversation.

More
28 Jun 2021 11:11 #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.

More
28 Jun 2021 13:11 #213131 by BeagleBrainz
Replied by BeagleBrainz on topic My Grizzly G0619 mill
I usually wake up like a baby, crying, hungry and you know the rest ;)
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
29 Jun 2021 00:42 #213200 by my1987toyota
Replied by my1987toyota on topic My Grizzly G0619 mill

rodw post=213102 userid=20660I 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!

Warning: Spoiler!

Don't sweat it rodw. I am still very much in my infancy when it comes to programing anything. Some day I hope to actually know what I'm doing.
Most of my MPG file was sections of my original hal. cut and pasted till I got a dedicated MPG hal. I am still trying to figure out why it works with
a 7i76e board but wont work with my 6i25 / 7i76 combo boards. Oh and thank you and Beaglebrainz both for the other MPG examples .

Please Log in or Create an account to join the conversation.

More
01 Jul 2021 00:34 #213394 by my1987toyota
Replied by my1987toyota 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.

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
 
[/code]
 

I am getting the feeling I just scratched the surface with what you posted here BeagleBrainz. Is their a document I should look into for writing components or is it all listed in the manual somewhere?

Please Log in or Create an account to join the conversation.

More
01 Jul 2021 01:03 #213400 by BeagleBrainz
Replied by BeagleBrainz on topic My Grizzly G0619 mill
RTFM ;)

Just joking.

In all serious there is some info in the online manual, under the hal, section I think, it gives a few basic examples.
Not being familiar with python I tend to lean more towards the C way of doing it. In realty the basics are all that hard, like anything else working out the logic of how to get want you done is the tricky bit.
Halcompile makes things easy, just make sure you have the linuxcnc-dev package installed if you already haven’t. That contains halcomplie and the other bits and pieces needed to build a module.
The good part is in the manual it has examples of how to use halcmd (I hope I got right) to load a module and manipulate it with having to load a full Linuxcnc config.
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
01 Jul 2021 01:55 #213402 by my1987toyota
Replied by my1987toyota on topic My Grizzly G0619 mill
  It took me a few min. to figure out what RTFM meant. LOL.  I am still wading my way through the close to 1000 pages manual.
I just came across section 14.10 I am just hope I'm not getting in over my head.

Please Log in or Create an account to join the conversation.

More
01 Jul 2021 03:04 #213405 by rodw
Replied by rodw on topic My Grizzly G0619 mill
Try this link
linuxcnc.org/docs/devel/html/hal/comp.html

Also review how some of the simplest components are written (eg and2.comp) and play around compiling a couple 

github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

Time to create page: 0.117 seconds
Powered by Kunena Forum