Simple Lcnc 2.9.# MPG HAL's
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 812
- Thank you received: 329
29 Mar 2023 11:27 - 29 Mar 2023 21:48 #267790
by my1987toyota
Simple Lcnc 2.9.# MPG HAL's was created by my1987toyota
FOR VERSION 2.9.#
This is currently a pre-release for the wired MPG jog pendant HAL . It is still a work in progress.
I have been updating my HAL from my 2.8 version and was finally successful.
I will be updating this topic as I polish the code . That said use at your own risk.
Stay Tuned
for now have a look
This is currently a pre-release for the wired MPG jog pendant HAL . It is still a work in progress.
I have been updating my HAL from my 2.8 version and was finally successful.
I will be updating this topic as I polish the code . That said use at your own risk.
Stay Tuned
for now have a look
# This file will not be overwritten when you run PNCconf again
#
# add the below 2 codes to your main hal file
#loadrt mux16 names=jogincr
#addf jogincr servo-thread
# if MPG outputs a quadrature signal per click set x4-mode to 1
# if MPG outputs 1 pulse per click set x4-mode to 0
# --- JOG INCREMENTS---
# section 1
# --- JOG-INCR-A ---
net jog-incr-a <= [HMOT](CARD0).7i76.0.0.input-25
# --- JOG-INCR-B ---
net jog-incr-b <= [HMOT](CARD0).7i76.0.0.input-26
# --- JOG-INCR-C ---
net jog-incr-c <= [HMOT](CARD0).7i76.0.0.input-27
# --- JOINT SELECTIONS ---
# section 2
# --- JOINT-SELECT-X ---
net axis-select-x <= [HMOT](CARD0).7i76.0.0.input-20
# --- JOINT-SELECT-Y ---
net axis-select-y <= [HMOT](CARD0).7i76.0.0.input-21
# --- JOINT-SELECT-Z ---
net axis-select-z <= [HMOT](CARD0).7i76.0.0.input-22
# section 3
# uncomment the axis you need
# comment out the ones you dont
# a and c are typically used
# the selections must also match the selections made in sections 8-10
#
# --- JOINT-SELECT-4TH ---
#net axis-select-a <= [HMOT](CARD0).7i76.0.0.input-23
#net axis-select-b <= [HMOT](CARD0).7i76.0.0.input-23
net axis-select-c <= [HMOT](CARD0).7i76.0.0.input-23
# --- JOINT-SELECT-5TH ---
#net axis-select-a <= [HMOT](CARD0).7i76.0.0.input-24
#net axis-select-b <= [HMOT](CARD0).7i76.0.0.input-24
#net axis-select-c <= [HMOT](CARD0).7i76.0.0.input-24
# ---jogwheel signals to mesa encoder - shared MPG---
# if you are using your spindle encoder for your MPG
# uncomment the first selection
#
# if you are using the MPG inputs from TB5 then uncomment
# the second selection
#
# only one selection can be uncommented
# section 4
net axis-selected-count <= [HMOT](CARD0).encoder.00.count
#net axis-selected-count <= [HMOT](CARD0).7i76.0.0.enc0.count
# ---mpg signals---
# section 5
# for axis x MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.x.jog-vel-mode 0
setp axis.x.jog-vel-mode 1
#
net selected-jog-incr => axis.x.jog-scale
net axis-select-x => axis.x.jog-enable
net axis-selected-count => axis.x.jog-counts
# section 6
# for axis y MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.y.jog-vel-mode 0
setp axis.y.jog-vel-mode 1
#
net selected-jog-incr => axis.y.jog-scale
net axis-select-y => axis.y.jog-enable
net axis-selected-count => axis.y.jog-counts
# section 7
# for axis z MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.z.jog-vel-mode 0
setp axis.z.jog-vel-mode 1
#
net selected-jog-incr => axis.z.jog-scale
net axis-select-z => axis.z.jog-enable
net axis-selected-count => axis.z.jog-counts
# 1 of the below axis must be be commented out ( sections 8-10 )
# the other 2 must match the selections from section 3
# a and c are typically used
#
# section 8
# for axis a MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.a.jog-vel-mode 0
#setp axis.a.jog-vel-mode 1
#
#net selected-jog-incr => axis.a.jog-scale
#net axis-select-a => axis.a.jog-enable
#net selected-count => axis.a.jog-counts
# section 9
# for axis b MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.b.jog-vel-mode 0
#setp axis.b.jog-vel-mode 1
#
#net selected-jog-incr => axis.x.jog-scale
#net axis-select-b => axis.x.jog-enable
#net selected-count => axis.x.jog-counts
# section 10
# for axis c MPG
# uncomment the jog-vel-mode you want to use
# comment out the ones you dont
# mode 1 is typically used
#setp axis.c.jog-vel-mode 0
setp axis.c.jog-vel-mode 1
#
net selected-jog-incr => axis.c.jog-scale
net axis-select-c => axis.c.jog-enable
net axis-selected-count => axis.c.jog-counts
# jog increment
# section 11
# note jog increments are in inches or standard measurements
#
# make sure the setp jogincr.in## has a - next to its scale number
#
# if you want to reverse the encoder direction remove the -
# from its scale number
setp hm2_7i76e.0.encoder.00.counter-mode 1
net jog-incr-a => jogincr.sel0
net jog-incr-b => jogincr.sel1
net jog-incr-c => jogincr.sel2
net jog-incr-d => jogincr.sel3
net selected-jog-incr <= jogincr.out-f
setp jogincr.debounce-time 0.200000
setp jogincr.use-graycode false
setp jogincr.suppress-no-input false
setp jogincr.in00 0.0000
setp jogincr.in01 -0.0001
setp jogincr.in02 -0.0010
setp jogincr.in03 0.0000
setp jogincr.in04 -0.0100
setp jogincr.in05 -1.0000
setp jogincr.in06 -0.1000
setp jogincr.in07 0.0000
setp jogincr.in08 0.0000
setp jogincr.in09 0.0000
setp jogincr.in10 0.0000
setp jogincr.in11 0.0000
setp jogincr.in12 0.0000
setp jogincr.in13 0.0000
setp jogincr.in14 0.0000
setp jogincr.in15 0.0000
Attachments:
Last edit: 29 Mar 2023 21:48 by my1987toyota.
Please Log in or Create an account to join the conversation.
30 Mar 2023 04:15 #267885
by spumco
Replied by spumco on topic Simple Lcnc 2.9.# MPG HAL's
As requested, here's my take on it.
Note 1: This has not been curated to be a generic example; input numbers and other machine-specific values will have to be adjusted accordingly.
Note 2: I discovered that some - maybe all - generic MPG's (the 4/5/6 axis Amazon/ebay & similar non-USB) basically use 12-position selector switches. The number of detents is adjustable, and the manufacturer just sets the number of positions for that model and slaps the appropriate sticker on the front. Mine had screw terminals connected to 9 of 12 axis switch positions, but the switches could easily have conductors connected directly.
In addition, the coiled cable usually has a number of spare conductors permitting expansion of the various functions & increment selections. A quick soldering job changed my 4-axis, 3-increment MPG in to a 4-axis + 3 overrides, 4-increment MPG.
Note 3: The bulk of the MPG logic is in MPG.hal, but I've attached IO.hal as the SRO/FRO functions are handled in that one. IO.hal is used for all the physical pushbuttons on my control panel.
Note 4: The jog-speed function is pretty straight-forward. Turn the selector to "JRO" and twiddle the MPG encoder. The speed for a continuous jog is adjusted as a percentage of the maximum rate set in the INI file (or in the knob2float component). To jog, the selector is moved back to the desired axis and a panel button is pressed for pos or neg (continuous) or the MPG is turned (incremental).
Note 5: all 'loadrt' and 'addf' are located in a 'main' hal file. I didn't think it necessary to add that one, too.
Note 1: This has not been curated to be a generic example; input numbers and other machine-specific values will have to be adjusted accordingly.
Note 2: I discovered that some - maybe all - generic MPG's (the 4/5/6 axis Amazon/ebay & similar non-USB) basically use 12-position selector switches. The number of detents is adjustable, and the manufacturer just sets the number of positions for that model and slaps the appropriate sticker on the front. Mine had screw terminals connected to 9 of 12 axis switch positions, but the switches could easily have conductors connected directly.
In addition, the coiled cable usually has a number of spare conductors permitting expansion of the various functions & increment selections. A quick soldering job changed my 4-axis, 3-increment MPG in to a 4-axis + 3 overrides, 4-increment MPG.
Note 3: The bulk of the MPG logic is in MPG.hal, but I've attached IO.hal as the SRO/FRO functions are handled in that one. IO.hal is used for all the physical pushbuttons on my control panel.
Note 4: The jog-speed function is pretty straight-forward. Turn the selector to "JRO" and twiddle the MPG encoder. The speed for a continuous jog is adjusted as a percentage of the maximum rate set in the INI file (or in the knob2float component). To jog, the selector is moved back to the desired axis and a panel button is pressed for pos or neg (continuous) or the MPG is turned (incremental).
Note 5: all 'loadrt' and 'addf' are located in a 'main' hal file. I didn't think it necessary to add that one, too.
The following user(s) said Thank You: my1987toyota, eduard
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 812
- Thank you received: 329
30 Mar 2023 09:29 - 30 Mar 2023 09:37 #267897
by my1987toyota
Replied by my1987toyota on topic Simple Lcnc 2.9.# MPG HAL's
WOW spumco that's a nice setup you got their. I see you also use the 7i73. One of these day I will have to get
one and try it out. Does the encoder output a quadrature signal or a 1 count per click? If quadrature how do
you deal with the 4 count?
The JRO section is of special interest to me . I am making an HMI panel for my mill and the JRO override with
push button + and - buttons is on my to do list.
forum.linuxcnc.org/show-your-stuff/39443...mill?start=60#262607
Thanks again for posting your setup I am sure it will help a lot of people out.
one and try it out. Does the encoder output a quadrature signal or a 1 count per click? If quadrature how do
you deal with the 4 count?
The JRO section is of special interest to me . I am making an HMI panel for my mill and the JRO override with
push button + and - buttons is on my to do list.
forum.linuxcnc.org/show-your-stuff/39443...mill?start=60#262607
Thanks again for posting your setup I am sure it will help a lot of people out.
Last edit: 30 Mar 2023 09:37 by my1987toyota. Reason: adding info
Please Log in or Create an account to join the conversation.
30 Mar 2023 14:07 #267912
by spumco
Replied by spumco on topic Simple Lcnc 2.9.# MPG HAL's
The 7i73 has direct encoder inputs that work seamlessly with bog-standard 100-detent MPG encoders. The MPGs have quad A/B (or differential A/A-, B/B-) outputs that are connected to 5v-tolerant encoder-specific inputs. I'm ignorant of the actual details, but the 7i73's firmware is pre-configured so that you simply have "7i73.encN-counts" available for use in HAL. No need to set up a HAL software encoder component as the 7i73 just outputs counts up or down.
Super-easy, and there's enough encoder inputs that you can have separate MPG, FRO, SRO, and JRO (or RRO).
Minor complaint I have about the 7i73 is that only the encoder inputs (plus an additional single input) are 5v tolerant. The bulk of the inputs are 3v. Which means if you want to use some of the cheap 12-detent knob encoders for FRO/SRO that have a built-in pushbutton switch you have to figure a way to kludge up something to drop the voltage since the encoder switch outputs 5v.
Second complaint is that there are no pull-up/pull-downs on analog inputs, so if you want to use them as on/off IO you have to hand-wire some resistors. Not the end of the world, but having pull-ups/downs on-board with jumpers or dip switches would be favorite.
So while it's fine for the intended use (LCD + matrix keypad + MPG), it's a little challenging to use as a universal control panel interface if you want to standardize on the typical 24vdc and not have a bunch of different voltages in your panel to keep track of.
My keypad matrix is a DIY hand-wired 4x8 keypad based on some CherryMX keyboard switches. Some of the switches have LED's driven by 7i73 outputs (see the blink comp in previously posted io.hal). Also pretty easy to interface with LCNC & the 7i73 once I read the matrixkb comp instructions about 10 times.
Super-easy, and there's enough encoder inputs that you can have separate MPG, FRO, SRO, and JRO (or RRO).
Minor complaint I have about the 7i73 is that only the encoder inputs (plus an additional single input) are 5v tolerant. The bulk of the inputs are 3v. Which means if you want to use some of the cheap 12-detent knob encoders for FRO/SRO that have a built-in pushbutton switch you have to figure a way to kludge up something to drop the voltage since the encoder switch outputs 5v.
Second complaint is that there are no pull-up/pull-downs on analog inputs, so if you want to use them as on/off IO you have to hand-wire some resistors. Not the end of the world, but having pull-ups/downs on-board with jumpers or dip switches would be favorite.
So while it's fine for the intended use (LCD + matrix keypad + MPG), it's a little challenging to use as a universal control panel interface if you want to standardize on the typical 24vdc and not have a bunch of different voltages in your panel to keep track of.
My keypad matrix is a DIY hand-wired 4x8 keypad based on some CherryMX keyboard switches. Some of the switches have LED's driven by 7i73 outputs (see the blink comp in previously posted io.hal). Also pretty easy to interface with LCNC & the 7i73 once I read the matrixkb comp instructions about 10 times.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 812
- Thank you received: 329
31 Mar 2023 10:35 #267961
by my1987toyota
Replied by my1987toyota on topic Simple Lcnc 2.9.# MPG HAL's
yes that is a nice MPG and HMI assembly
The following user(s) said Thank You: spumco
Please Log in or Create an account to join the conversation.
29 Oct 2023 20:26 - 29 Oct 2023 20:29 #284072
by Mecanix
Replied by Mecanix on topic Simple Lcnc 2.9.# MPG HAL's
So simple, yet incredibly powerful, purposeful and effective.
Quite rare nowadays, considering that over-engineering for incentives and eternal bugs is normally the smart way to do it.
Well done, my1987toyota. Thank you.
Quite rare nowadays, considering that over-engineering for incentives and eternal bugs is normally the smart way to do it.
Well done, my1987toyota. Thank you.
Last edit: 29 Oct 2023 20:29 by Mecanix.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
29 Oct 2023 23:26 - 29 Oct 2023 23:34 #284088
by cornholio
Replied by cornholio on topic Simple Lcnc 2.9.# MPG HAL's
74lvc245 are good for the 5v to 3.3 translation for inputs, used them a bunch of times.
I also modded MESA firmware (the firmware used for Smart Serial remote on the 7i90) to run on a Colorlight RV901T, get rid of the 74hct245s, replace them with 74cbt245s, run the board from 4.2 volts and you have 5v tolerant inputs and add a Aliexpress RS422 to ttl converter. Current iteration has 56 pins that can be either input or outputs and has inputs for 4 MPGs.
I also modded MESA firmware (the firmware used for Smart Serial remote on the 7i90) to run on a Colorlight RV901T, get rid of the 74hct245s, replace them with 74cbt245s, run the board from 4.2 volts and you have 5v tolerant inputs and add a Aliexpress RS422 to ttl converter. Current iteration has 56 pins that can be either input or outputs and has inputs for 4 MPGs.
Last edit: 29 Oct 2023 23:34 by cornholio.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
Time to create page: 0.260 seconds