Macro - Mcodes Parport activation
25 Jan 2016 04:56 - 25 Jan 2016 05:01 #69081
by cyrut2
Macro - Mcodes Parport activation was created by cyrut2
So im back after some weeks with a now running machine. 75% were i want to be. Still got some things to sort out. Ive read up a little on the options and the way linuxcnc runs but i have one area where im slightly stuck and not sure if i should go down this route.
!!!!! I cant stress enough how delicate safety is so if even a slight chance of causing movement when not wanted is extremely dangerous!!!!!!!
This is why i bring the help up. I have a 1 ton grinding wheel spinning at 6000 rpms so here goes,
I want to create a movement through buttons going into the parport. I can either create a macro which seems similar to what i use with fanuc. Use M101 to activate pin x then activate a macro to use gcode to make movements or advancements controlled via buttons.
This is my current idea hold button 1 with 3 equals advance i thousandth 1 and 4 retract one thousandth 3 alone is a millionth advance 4 alone is a retract a millionth 2 is a move to g54 stored position from any current location 5 is a home button 2 and 5 is update g54 with current position. For safety they need to be held for 1.5 seconds for safety from electrical noise environment led will light up and to accept the command cycle start needs to be pushed as well. Which is a two hand button switch i installed.
(Of course i need to be able to program feed rates thats why im leaning toward macros) ..... by the way is there a macro screen to place variables?
If any risk of movement can be had i was thinking just using hard buttons for cycle start and feed hold and put M01 after each command line and create programs for different scenarios. Dont like it cause if have to create a program for advance low, high and retract low and high so 4 programs is kinda not the way to attack this.
What do you guys suggest is the safest way to attack this issue?
!!!!! I cant stress enough how delicate safety is so if even a slight chance of causing movement when not wanted is extremely dangerous!!!!!!!
This is why i bring the help up. I have a 1 ton grinding wheel spinning at 6000 rpms so here goes,
I want to create a movement through buttons going into the parport. I can either create a macro which seems similar to what i use with fanuc. Use M101 to activate pin x then activate a macro to use gcode to make movements or advancements controlled via buttons.
This is my current idea hold button 1 with 3 equals advance i thousandth 1 and 4 retract one thousandth 3 alone is a millionth advance 4 alone is a retract a millionth 2 is a move to g54 stored position from any current location 5 is a home button 2 and 5 is update g54 with current position. For safety they need to be held for 1.5 seconds for safety from electrical noise environment led will light up and to accept the command cycle start needs to be pushed as well. Which is a two hand button switch i installed.
(Of course i need to be able to program feed rates thats why im leaning toward macros) ..... by the way is there a macro screen to place variables?
If any risk of movement can be had i was thinking just using hard buttons for cycle start and feed hold and put M01 after each command line and create programs for different scenarios. Dont like it cause if have to create a program for advance low, high and retract low and high so 4 programs is kinda not the way to attack this.
What do you guys suggest is the safest way to attack this issue?
Last edit: 25 Jan 2016 05:01 by cyrut2.
Please Log in or Create an account to join the conversation.
02 Feb 2016 13:12 #69434
by andypugh
Replied by andypugh on topic Macro - Mcodes Parport activation
It is possible to make HAL buttons run G-code subroutines.
You do this with the MDI_COMMAND entries in the INI file
linuxcnc.org/docs/2.7/html/config/ini-co....html#_halui_section
So, you set up some HAL logic so that a HAL output pin changes state under the conditions you require, and then wire that to the halui HAL pin.
This only works when G-code is not running. You have not said if you are also running G-code. halui.mdi-command is meant to allow you to press a button instead of typing a G-code command in the MDI window. It might not be appropriate for your application.
It isn't the most economical way to do it, but I think in your situation I would set up a LUT5 for every button combination.
linuxcnc.org/docs/2.7/html/man/man9/lut5.9.html
So, your advance 0.001 would be allocated to lut5.0 which would be set to only be "true" when 1 and 3 are true and not for any other combination.
You could then pass each LUT5 output through a debounce component and then finally an AND2 for the cycle-start button interlock.
linuxcnc.org/docs/2.7/html/man/man9/debounce.9.html
The reason I suggest the LUT5 approach is that it is easy to modify and to understand compared to lots of AND2 and XOR functions, and there is no chance that button 1 + button 3 will look like (button 1) and (button 1 + button 3)
I used this to calculate the LUT5 numbers:
docs.google.com/spreadsheets/d/1_VlL39jU...E3JitvLzs/edit#gid=0
Note that the example above is untested and needs to be exapanded in places where I have left elipses.
It also doesn't have the secondary interlock for the cycle-start button. I might be tempted to put that stage in the actual G-code subroutine that was called as an M65 wait-on-input
You do this with the MDI_COMMAND entries in the INI file
linuxcnc.org/docs/2.7/html/config/ini-co....html#_halui_section
So, you set up some HAL logic so that a HAL output pin changes state under the conditions you require, and then wire that to the halui HAL pin.
This only works when G-code is not running. You have not said if you are also running G-code. halui.mdi-command is meant to allow you to press a button instead of typing a G-code command in the MDI window. It might not be appropriate for your application.
It isn't the most economical way to do it, but I think in your situation I would set up a LUT5 for every button combination.
linuxcnc.org/docs/2.7/html/man/man9/lut5.9.html
So, your advance 0.001 would be allocated to lut5.0 which would be set to only be "true" when 1 and 3 are true and not for any other combination.
You could then pass each LUT5 output through a debounce component and then finally an AND2 for the cycle-start button interlock.
linuxcnc.org/docs/2.7/html/man/man9/debounce.9.html
The reason I suggest the LUT5 approach is that it is easy to modify and to understand compared to lots of AND2 and XOR functions, and there is no chance that button 1 + button 3 will look like (button 1) and (button 1 + button 3)
loadrt lut5 count=7
loadrt debounce cfg=6
addf lut5.0 servo-thread
addf lut5.1 servo-thread...
addf debounce.0 servo-thread
setp debounce.0 1500 # 1.5 seconds delay with a 1kHz base thread
setp lut5.0.function 32 # 1 with 3
setp lut5.1.function 512 # 1 with 5
setp lut5.2.function 16 # 3 alone
setp lut5.3.function 256 # 4 alone
setp lut5.4.function 4 # 2 alone
setp lut5.5.function 65536 #5 alone
setp lut5.6.function 262144 #5 with 2
net button1 parport.0.pin-01-in
net button2 parport.0.pin-02-in
net button3 parport.0.pin-03-in
net button4 parport.0.pin-04-in
net button5 parport.0.pin-05-in
net button1 lut5.0.in0 lut5.1.in0 lut5.2.in0 lut5.3.in0 lut5.4.in0 lut5.5.in0 lut5.6.in0
net button2 lut5.0.in1 lut5.1.in1 lut5.2.in1 lut5.3.in1 lut5.4.in1 lut5.5.in1 lut5.6.in1
...
net adv001-raw lut5.0.out debounce.0.0.in
net retr001-raw lut5.1.out debounce.0.1.in
...
net adv001-filt debounce.0.0.out halui.mdi-command-00
net retr001-filt debounce.0.1.out halui.mdi-command-01
...
I used this to calculate the LUT5 numbers:
docs.google.com/spreadsheets/d/1_VlL39jU...E3JitvLzs/edit#gid=0
Note that the example above is untested and needs to be exapanded in places where I have left elipses.
It also doesn't have the secondary interlock for the cycle-start button. I might be tempted to put that stage in the actual G-code subroutine that was called as an M65 wait-on-input
Please Log in or Create an account to join the conversation.
04 Feb 2016 17:11 #69588
by cyrut2
Replied by cyrut2 on topic Macro - Mcodes Parport activation
Wow this is what i was looking for exactly. 0x400 would be an input for a g function. I thought that it would have to run out side of a running program which is doable but as i move on with this project i can see where i would want it in a running macro sub routine. I want to add a marposs air gage that can automatically adjust the machine to 20 microns of roundness on a part. Take three measurements as the machine is grinding adjusting as it progresses.
Get the operator out of the loop. Adding a robotic arm and in and out feeding conveyor systems will add to the complexity of the system but i may create interfaces like those mentioned in other forums. Ether-cat communication with external plcs for faster processing without having the machine wait for secondary motions.
Sorry for the unnecessary info but i know that i will run into you again as you are one of the strongest supporters and highly knowledgeable in Linuxcnc and its interfaces. Thanks Andy and do i miss my Yamaha R1 everytime i see you respond.
Get the operator out of the loop. Adding a robotic arm and in and out feeding conveyor systems will add to the complexity of the system but i may create interfaces like those mentioned in other forums. Ether-cat communication with external plcs for faster processing without having the machine wait for secondary motions.
Sorry for the unnecessary info but i know that i will run into you again as you are one of the strongest supporters and highly knowledgeable in Linuxcnc and its interfaces. Thanks Andy and do i miss my Yamaha R1 everytime i see you respond.
Please Log in or Create an account to join the conversation.
04 Feb 2016 17:29 #69591
by cncbasher
Replied by cncbasher on topic Macro - Mcodes Parport activation
why not latch the buttons , and then and only after the 2 buttons are pressed , will the cycle start become operational
or say 2 buttons & then an ok to latch the pair , and then cycle start will be operational ?
i presume your doing this with a specific screen menu and not axis for example
or say 2 buttons & then an ok to latch the pair , and then cycle start will be operational ?
i presume your doing this with a specific screen menu and not axis for example
Please Log in or Create an account to join the conversation.
Time to create page: 0.081 seconds