M3 SOURCE CODE

More
21 Nov 2018 20:05 #121166 by andypugh
Replied by andypugh on topic M3 SOURCE CODE

That did not work. It raised a conflict with the following line;
net spindle-output <= pid.s.output mux2.0.in0


Ah, yes, sorry.

Create a complete new signal name for the lines with mux2.0.out and hm2_7i92.0.7i77.0.1.analogout4
(that's the link you need to make, mux2.0.out to analogout4)

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

More
21 Nov 2018 22:20 - 21 Nov 2018 22:21 #121180 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
Is it possible to feed MDI from python during an M6 routine without remapping?

forum.linuxcnc.org/10-advanced-configuration/35567-m6-remap-atc
Last edit: 21 Nov 2018 22:21 by COlger81.

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

More
21 Nov 2018 22:26 #121182 by andypugh
Replied by andypugh on topic M3 SOURCE CODE

Is it possible to feed MDI from python during an M6 routine without remapping?


Yes, using the linuxcnc.command() interface.

linuxcnc.org/docs/2.7/html/config/python-interface.html

Though depending on what you want to do a pure G-code remap routine can often work well for a tool changer.

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

More
21 Nov 2018 22:45 #121183 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
The linuxcnc.command() interface is what i'm using with gmoccapy. M6 ignores all MDI commands from python though.

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

More
21 Nov 2018 22:52 #121184 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
All MDI commands are ignored.

File Attachment:

File Name: ATC.py
File Size:5 KB
import time
import linuxcnc

import sys

s = linuxcnc.stat()
c = linuxcnc.command()

SO = hal.component("SO")
ATC = hal.component("ATC")
motion = hal.component("motion")

motion.newpin("spindle-gear", hal.HAL_FLOAT, hal.HAL_IN)
ATC.newpin("active-tool", hal.HAL_S32, hal.HAL_IN)
ATC.newpin("turret-actual-count", hal.HAL_S32, hal.HAL_IN)
ATC.newpin("tool-prep-number", hal.HAL_S32, hal.HAL_IN)
ATC.newpin("turret-status", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("tool-change", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-forward-in", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-reverse-in", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-active", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-forward-out", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("turret-reverse-out", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("from-gcode", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("tool-changed", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("tool-prepare", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("carousel-homing", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("turret-ready", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-toggle", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-on", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("readyorientforward", hal.HAL_BIT, hal.HAL_OUT)
ATC.newpin("turret-sensor", hal.HAL_BIT, hal.HAL_IN)
ATC.newpin("turret-ready-stop", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-atc-prepare", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-atc-prepared", hal.HAL_BIT, hal.HAL_OUT)
SO.newpin("so-atc-active", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-atc-readyorient", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-atc-turslide", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-atc-turslide-home", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-sen", hal.HAL_BIT, hal.HAL_IN)
motion.newpin("atc-position", hal.HAL_BIT, hal.HAL_IN)
SO.newpin("so-stat-out", hal.HAL_BIT, hal.HAL_OUT)
SO.newpin("so-or-lock", hal.HAL_BIT, hal.HAL_OUT)
SO.newpin("atc-turslide-in", hal.HAL_BIT, hal.HAL_OUT)
SO.newpin("atc-turslide-out", hal.HAL_BIT, hal.HAL_OUT)
SO.ready()
ATC.ready()

try:
    while 1:
        def ok_for_atc():
            s.poll()
            return ATC['tool-change'] == 1 and motion['spindle-gear'] == 0 and motion['atc-position'] == 1 
            return round(ATC['turret-actual-count'] - ATC['active-tool']) >= 1 or round(ATC['turret-actual-count'] - ATC['active-tool']) <= -1
        def ok_for_orient():
            return SO['so-atc-readyorient'] == 1 and SO['so-sen'] == 0
        def ok_for_turslide():
            s.poll()
            return not s.estop and s.enabled and s.homed and SO['so-atc-readyorient'] == 1 and SO['so-sen'] == 0 and SO['so-atc-turslide'] == 1 and SO['so-or-lock'] == 1 and motion['atc-position'] == 1
        def ok_for_turslide_home():
            s.poll()
            return not s.estop and s.enabled and s.homed and SO['so-atc-readyorient'] == 1 and SO['so-sen'] == 0 and SO['so-atc-turslide-home'] == 1 and SO['so-or-lock'] == 1 and motion['atc-position'] == 1
        def ok_for_turret():
            s.poll()
            return ATC['turret-ready'] == 1 and round(ATC['turret-actual-count'] - ATC['active-tool']) >= 1 or round(ATC['turret-actual-count'] - ATC['active-tool']) <= -1 #not s.estop and s.enabled and s.homed and  and 
        def ok_for_turret_stop():
            s.poll()
            return ATC['turret-ready-stop'] == 1  and int(ATC['turret-actual-count'] - ATC['active-tool']) == 0 and ATC['turret-sensor'] == 1
        def turret_forward():
            s.poll()
            return ATC['turret-forward-in'] == 1
        def turret_reverse():
            s.poll()
            return ATC['turret-reverse-in'] == 1 

        if ATC['turret-forward-in'] == 1 and ATC['readyorientforward'] == 0:
            c.mode(linuxcnc.MODE_MDI)
            c.mdi("M3 S50")
            ATC['readyorientforward'] = 1
        if SO['so-sen'] == 0 and ATC['readyorientforward'] == 1:
            c.mdi("M5")
            SO['so-or-lock'] = 1
            time.sleep(.1)
            ATC['readyorientforward'] = 0
            ATC['turret-forward-out'] = 1
        if ATC['turret-active'] ==0:
            time.sleep(.2)
            ATC['turret-forward-out'] = 0
            SO['so-or-lock'] = 0
            time.sleep(.1)

        if ATC['turret-reverse-in'] == 1:
            ATC['turret-reverse-out'] = 1
            ATC['turret-forward-out'] = 1
        if ATC['turret-active'] ==0:
            time.sleep(.2)
            ATC['turret-reverse-out'] = 0

        #while turret_reverse():
            #ATC['turret-forward-out'] = 1
            #ATC['turret-reverse-out'] = 1
        #if ATC['from-gcode'] == 1:
            #ATC['tool-prepare'] = 1
            #c.mdi("M65 P0")
            #pass
            #time.sleep(.2)
            #SO['so-atc-readyorient'] = 1
        #if ok_for_orient():
            #c.mdi("m5")
            #SO['so-or-lock'] = 1
            #time.sleep(.1)
            #SO['so-or-lock'] = 0
            #time.sleep(.1)
            #SO['so-atc-readyorient'] = 0
            #ATC['turret-ready'] = 1
        #if ok_for_turret():
            #ATC['turret-on'] = 1
            #time.sleep(.1)
            #ATC['turret-ready'] = 0
            #ATC['turret-ready-stop'] = 1
        #if ok_for_turret_stop():
            #ATC['turret-ready-stop'] = 0
            #pass
        #if ATC['turret-sensor'] == 1:
            #time.sleep(.1)
            #ATC['turret-on'] = 0
            #c.wait_complete()
            #time.sleep(.2)
            #ATC['tool-prepared'] = 1
            #time.sleep(.2)
            #ATC['tool-changed'] = 1


except KeyboardInterrupt:
    raise SystemExit
Attachments:

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

More
21 Nov 2018 23:18 #121187 by andypugh
Replied by andypugh on topic M3 SOURCE CODE
Is that a HAL component or a remap? It looks possibly like a bit of both.

I suspect that MDI inside a HAL component won't work because the system is in auto mode and MDI only works when idle.

Inside a remap you _can_ use the canonical interface to move axes, there is an example here in this remapped lathe roughing cycle:
github.com/LinuxCNC/linuxcnc/blob/andypu...python/remap.py#L441

I think if you need to use G-code in the tool change it is simpler to do all the tool change in G-code. (G code can read HAL pins as long as they are connected to the G-code analog and digital inputs)

There is an example of an all-G-code tool change routine here:
github.com/LinuxCNC/linuxcnc/blob/master...hange/toolchange.ngc

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

More
21 Nov 2018 23:36 #121189 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
Round and round i go... I have gone the remap with g code route, the last tool upon shutdown won't load, etc. etc...... I have all of the pieces together, as far as i can execute every step individually without issue. The python code i posted is not a remap. I would love to just remap in G code but then either M6 doesn't execute or it doesn't load last tool on startup. Please show me a path that leads to success. Either i can issue MDI or canonical commands without remapping, or i have to remap.

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

More
21 Nov 2018 23:43 #121190 by andypugh
Replied by andypugh on topic M3 SOURCE CODE
What happened to the idea of storing the tool in a persistent G-code parameter?

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

More
21 Nov 2018 23:45 - 21 Nov 2018 23:48 #121191 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
The last tool loads on startup just fine if i'm not remapping. As soon as i change INI and load remap from NGC then the tool does not load and M6 does not start tool change.
Last edit: 21 Nov 2018 23:48 by COlger81.

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

More
21 Nov 2018 23:47 #121192 by COlger81
Replied by COlger81 on topic M3 SOURCE CODE
Canonical commands sound great. Can you give me an example of how to rotate spindle at 50 rpm and how to move Z up to 4"?

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

Time to create page: 0.391 seconds
Powered by Kunena Forum