Jog increments using a 6 position selector switch
Rick
Please Log in or Create an account to join the conversation.
To clear up a possible mis-conception first. You don't have to interface with Axis, Axis is an interface. It is emc and hal that you have to connect with.
Are you talking jog speeds or jog increments? Are you using a MPG?
For a MPG, 6 increments seems a lot, all I have on my lathe is 1.00 and 0.1 and that gives me a normal jog and a slow jog which is all I need.
You can do this with a mux4 component
setp mux4.0.in0 1
setp mux4.0.in1 0.1
net scale1 mux4.0.sel0 <= parport.N.pin-NN-in
If you want to set more and have sufficient IO, you could retain the original switch and connect each pole on the switch to a different pin.
Then you could for instance set halui.jog-speed via a halui.mdi-command
linuxcnc.org/docs/2.5/html/gui/halui.html
regards
Please Log in or Create an account to join the conversation.
Continuous
1in
.1in
.01in
.001in
.0001in
We have our INI setup for this,and the drop down displays this, and the slides make the corresponding moves from the manual buttons on the screen but, now i want to hook up the selector to function alongside the display buttons. We have left the manual joystick and jog increment for the x and z moves on the rolling guard to retain as much familiarity for our operators.
Please Log in or Create an account to join the conversation.
One possible solution - would be a userspace component that sets the values for jog increments based upon the active switch pole.
This is back of a gedit envelope stuff.
What is not sorted out yet is what axis does for continuous jog and whether the flag that indicates that mode is accessible.
If you didn't want to use the axis buttons to jog, it wouldn't matter.
In continuous mode Axis presumably uses jogspeed and halui.jog.selected.plus instead of halui.jog.selected.increment-plus, when the [>] button is pressed.
Need to look at the code.
component jogswitch "This component toggles 6 jog states";
pin in bit in1 = false "switch input";
pin in bit in2 = false "switch input";
pin in bit in3 = false "switch input";
pin in bit in4 = false "switch input";
pin in bit in5 = false "switch input";
pin in bit in6 = false "switch input";
pin in s32 selected " selected joint connected to halui.joint.selected";
param rw float speed = 10 "Jog speed";
param rw float A = 1.0000;
param rw float B = 0.1000;
param rw float C = 0.0100;
param rw float D = 0.0010;
param rw float E = 0.0001;
option singleton yes; // makes no sense to have more than one of these components running
option userspace yes;
author "ArcEye arceye@mgware.co.uk";
license "GPL";
;;
#include <stdio.h> /* Standard input/output definitions */
#include <stdlib.h>
#include <stdint.h> /* Standard types */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <errno.h> /* Error number definitions */
void user_mainloop(void)
{
char buff[60];
int last = 0; // check not already set before making call
while(1)
{
usleep(1000000);
FOR_ALL_INSTS()
{
bzero(buff, 60);
if(in1 && (last !=1))// continous jog
{
last = 1;
sprintf(buff,"halcmd setp halui.jog-speed %f", speed);
system(buff);
}
else if(in2&& (last !=2))
{
last = 2;
sprintf(buff,"halcmd setp halui.jog.%d.increment %6.04f", selected, A);
system(buff);
}
else if(in3 && (last !=3))
{
last = 3;
sprintf(buff,"halcmd setp halui.jog.%d.increment %6.04f", selected, B);
system(buff);
}
else if(in4 && (last !=4))
{
last = 4;
sprintf(buff,"halcmd setp halui.jog.%d.increment %6.04f", selected, C);
system(buff);
}
else if(in5 && (last !=5))
{
last = 5;
sprintf(buff,"halcmd setp halui.jog.%d.increment %6.04f", selected, D);
system(buff);
}
else if(in6 && (last !=6))
{
last = 6;
sprintf(buff,"halcmd setp halui.jog.%d.increment %6.04f", selected, E);
system(buff);
}
else
{
//error msg here
}
}
}
exit(0);
}
regards
PS. This would work best and most easily, by just forgetting the axis jog buttons and creating a simple pyvcp screen with the jog buttons and increment indicators
Please Log in or Create an account to join the conversation.
It then dawned on me that you don't want to control the jogging increment with your switch, you want to control the the contents of a python widget text box with it, to do everything via Axis still.
No doubt that would be possible, someone like Dewey might be able to show how.
I have never used the somewhat crude and fiddly Axis jogging controls, largely because I already had a MPG pendant when I came to Linuxcnc and I just converted that.
( My MPG is of course on 0.1 and 0.01 increments not as stated - thats what comes of fading memory and not being at a workshop machine when writing )
regards
Please Log in or Create an account to join the conversation.
loadrt mux4 names=mpg-scale
# MPG Jog Speeds
addf mpg-scale servo-thread
# MPG encoder feedback
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0
setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0
net mpg-count hm2_5i20.0.encoder.03.count
net mpg-count => axis.0.jog-counts
net mpg-count => axis.2.jog-counts
setp mpg-scale.in0 .000025
setp mpg-scale.in1 .00025
setp mpg-scale.in2 .0025
# Axis Select
net mpg-x axis.0.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.054.in_not
net mpg-z axis.2.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.052.in_not
# Scale Select
# set the MPG scale based on the inputs from the selector switch
net pos2 mpg-scale.sel0 <= hm2_[HOSTMOT2](BOARD).0.gpio.037.in_not
net pos3 mpg-scale.sel1 <= hm2_[HOSTMOT2](BOARD).0.gpio.035.in_not
net axis-mpg-jog-scale axis.0.jog-scale <= mpg-scale.out
net axis-mpg-jog-scale axis.2.jog-scale <= mpg-scale.out
In your case use mux8
John
Please Log in or Create an account to join the conversation.
I am trying to use the original 6 position selector switch for my jog increments on our 10CC lathe project and am trying to figure out how to interface it with the AXIS dropdown box of increments. I have been reading about different configurations that must use 2 momentary pushbuttons to raise and lower the value but could not find anything on a selector switch style setup.
As far as I can see it is not possible to set the values in the Axis dropdown from hardware. This is partly because, whilst the physical switch could set the on-screen value, there is no way for the on-screen value to change the physical switch, so who gets to win?
I am also fairly sure that the Axis GUI jog drown doesn't control the jog speed with physical buttons, only with the keyboard or GUI. (though axisui does provide pins to hook them together, but only with the GUI as an output)
What you might want to do is hide the On-screen jog dropdown, which can be done with code added to a file called .axisrc in the home folder. (you will probably have to create the file, and because it begins with a "." it will be invisible.
I am hopeless with Python, so don't know the inaction offhand, but you might be able to figure it out if no-one else has a suggestion. (look in axis.py for how the spindle buttons get hidden when no spindle is configured)
The second part of your problem is converting 6 bit signals into one of 6 float values. I think that the easiest way in HAL is probably to sum the values of two mux8 components.
loadrt mux8 count=2
loadrt sum2 count=1
addf mux8.0 servo-thread
addf mux8.1 servo-thread
addf sum2.0 servo-thread
setp mux8.0.in1 1
setp mux8.0.in2 .1
setp mux8.0.in4 .001
setp mux8.1.in1 .0001
setp mux8.1.in2 .00001
setp mux8.1.in4 .000001
net switch-pin-1 mux8.0.sel0
net switch-pin-2 mux8.0.sel1
net switch-pin-3 mux8.0.sel2
net switch-pin-4 mux8.1.sel0
net switch-pin-5 mux8.1.sel1
net switch-pin-6 mux8.1.sel2
net fast mux8.0.out sum2.0.in0
net slow mux8.1.out sum2.0.in1
net jog-speed-out sum2.0.out
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
use a mux 16 and get the bonus of optional debounce and optional graycode
Mux16 has 4 select pins, not 6. A 6-pin mix would be mux64, and that seems unwieldy.
Please Log in or Create an account to join the conversation.
Thanks for all the info, I haven't been doing any programming due to some rebuilds on some tube mill equipment. I am going to try this on our next machine that I am going to put LinuxCNC on that will be hopefully getting underway in the next 3-4 weeks. This topic is a little over my head right now from reading all of the replies. I am still pretty green with linux. I want to get this 10" machine up and running, then get started on our 12" machine and implement this then. I have 4 machines in all that we are going to perform the retrofit on, hopefully by the end I will be answering and not asking the questions.
Thanks again
Rick
Please Log in or Create an account to join the conversation.