Hello Guest it is April 23, 2024, 09:03:46 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Cartierusm

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 »
102
I still have questions. I don't quite understand the layout of Lua.

I tried adding mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 X0.25 Z0.25") to make the tool changer goto this position before changing tools; I added it like this

--Mori Seiki Macro
function m6()

local inst = mc.mcGetInstance()
local Requested = mc.mcToolGetSelected(inst)
local Current = mc.mcToolGetCurrent(inst)
local ToolChange = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT01) --This is the signal that will start the click tool change.


   if Requested == Current then
       mc.mcCntlSetLastError(inst, "Current tool == Requested tool so there is nothing to do")
   else
         mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G00 X0.25 Z0.25")

         --Tell the Click to change to requested tool.
         local DS1 = mc.mcRegGetHandle(inst,"Clcik PLC/Requested Tool")
         mc.mcRegSetValue(DS1,Requested)

When I added this to the code and ran it, the tool changer moved, but not to the correct position and then gave me an error. When I tried this multiple times it moved to a different position every time. It's weird. I was trying to follow DaZ's tutorial on tool changer.

103
Thanks to Chaoticone as well, duh.

104
Ok it wouldn't let me post, weird. SO here's what I wrote before.


Ok this was as they said, pretty easy. You just have to understand what's going on. I don't understand everything, but I got it to work.

A BIG thanks to Chad!!

So I'll try to explain what Chad said so other can figure it out.

First thing: Get your tool changer working with a PLC. I think the click does everything you need, is inexpensive, easy to use and figure out and come with Tech Support from Automation Direct. I used an 8 Position Rotary switch with a regular momentary button to make my tool changer go manually.

After you get your PLC to change tools perfectly you can add to the same line as your manual switch the following code:

X001---------------------C1
                          |
                          |
DS1 = 1-----Y001

what's going on here is my manual switch triggers an internal bit in the click "C1" that runs my program for tool changes. So I added a DS1 which is a data set, when Mach sends a tool change, Tool 1 for instance, it will send a 1 to the DS1. That's how the Click will know what tool to change to. DS1 just holds a number that's it, the Y001 is the actual signal to make the tool changer move. So in the M6 Macro, the one Chad Posted is perfect other than having to change the variables for how you program your PLC, Mach sends a number for the tool change it's going to make then send an output command, Y001, and that makes the tool change. Then at the end of the tool change in the plc I have it set an output of Y005 to verify the tool change was completed successfully. This output in the PLC also is read by Mach to continue with the rest of macro and thereby continue your GCode.

Now you've got a tool change program working in the PLC and it can take an input to make the tool change to the correct one and an output to verify the tool was changed.

In mach it's really easy to setup Modbus. I used an Ethernet PLC. When I start my Click PLC software a screen pops up to connect to the PLC or open a project. If you connect it will show you all the information you need for the PLC's address, I'm assuming it will have the same info for a PLC that is connected via serial cable. Write that down.

Open Mach 4. Goto Configure > Plugins > Modbus. In mine there were some test modbus' I deleted them. After taking a picture of each in case.

Click the Add a new modbus connection > I named Mine something simple, you should too as it matters later on. I called mine Click PLC, set the connection type to what you're using, for ethernet you'll just put in the IP addy. Leave the other settings the same unless they pertain to your PLC.

Then click on the yellow add modbus function > Read coil > name the function Y005 (or whatever your verification signal is in your click, it has to be an output or input that has a modbus address, you can find if it is in the PLC software) > the address of your input or output you put that in the modbus register (or a Y output use the full address for an X input use just the last 2 numbers, mind you this is for a click PLC) > Register Prefix I put the same Y005. Click next. Then click on the name fields and change them to Y005, Mach adds a 0 for some reason.

Next add a write single register 16 > function name DS1 > modbus register 1 (in a Click PLC a DS1 is a 1 automatically in Mach) > click next and change the names in the fields to DS1 again as Mach adds a 0.

Then add a write coil for Y001 and fill out as with the Y005. Close out of Modbus.

Then open up your PLC software and get it to a state where you can see the functions working in real time. In a click plc software you have to upload the project to a PLC then it will show you in real time the functions.

Then in Mach open up Diagnostic >Click PLC > click on the + sign and go down to DS1 > double click on it and change the value from 0 to 1 > in your PLC software the DS1 value should now show a 1. You can try this with any number and it should change in the PLC software. This is really helpful because it bypasses lots of stuff and shows that mach is correctly communicating with your PLC.

Next go to Mach > config > inputs > use one of the inputs to click and the Y005. Then goto Outputs and use one for Y001. DS1 is a register and will automatically work.

Then just copy Chad's macro and change the values to suit you. Such as:

--Your Tool Changer
function m6()

local inst = mc.mcGetInstance()
local Requested = mc.mcToolGetSelected(inst)
local Current = mc.mcToolGetCurrent(inst)
local ToolChange = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT01) --Change the output number to the one you used above.


   if Requested == Current then
       mc.mcCntlSetLastError(inst, "Current tool == Requested tool so there is nothing to do")
   else
         --Tell the Click to change to requested tool.
         local DS1 = mc.mcRegGetHandle(inst,"Click PLC/DS1 ") --Type in here the actual address of the PLC - what that means is when you setup Modbus you call it something. I called mine Click PLC, so the address of the DS1 is and what you type here is "Click PLC/DS1"
         mc.mcRegSetValue(DS1,Requested)
         
         --Send signal to the Click to start the tool change.
         mc.mcSignalSetState(ToolChange,1) --Y001, this spot is using the words "toolchange" to trigger outpout 01 above. Basically it's shorthand. You set output 01 above to be called out as toolchange. So you don't really need to change this, but I thought I'd explain.
         wx.wxMilliSleep(1000)
         mc.mcSignalSetState(ToolChange,0) --Y001
         
         --Wait for the signal from the CLick.         
         mc.mcCntlSetLastError(inst, "Wait for Click to complete tool change.")
         rc = mc.mcSignalWait(inst, mc.ISIG_INPUT0, mc.WAIT_MODE_HIGH, 20)--Time in seconds the Click has to complete the tool change. You also have to change the input to the input you setup in Mach Config.
         --Error check.  If the Click took too long.  Alarm out Mach4.
         if (rc~= 0) then
             wx.wxMessageBox("The Click did not complete the tool change in time.  Check for malfunction.")
             local Alarm = mc.mcSignalGetHandle(inst,mc.OSIG_ALARM)
             mc.mcSignalSetState(Alarm,1)
             CycleStop()
         else
             mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(Requested))
             mc.mcToolSetCurrent(inst, Requested)
             mc.mcCntlSetLastError(inst, "Tool Change Complete.")
         end

    end--Request == Current

end --m6

if (mc.mcInEditor() == 1) then
 m6()
end'


Couple of notes Mach can read an output from the click as an input.

Hope that helps someone.

105
Ok this was as they said, pretty easy. You just have to understand what's going on. I don't understand everything, but I got it to work.

A BIG thanks to Chad!!

So I'll try to explain what Chad said so other can figure it out.

First thing: Get your tool changer working with a PLC. I think the click does everything you need, is inexpensive, easy to use and figure out and come with Tech Support from Automation Direct. I used an 8 Position Rotary switch with a regular momentary button to make my tool changer go manually.

After you get your PLC to change tools perfectly you can add to the same line as your manual switch the following code:

X001-------------------C1

106
General Mach Discussion / Re: Cool CNC Features
« on: January 27, 2018, 10:43:32 AM »
That would be neat.

107
Mach4 General Discussion / Re: Mach Motion Lathe Wizards Bug? Help.
« on: January 25, 2018, 03:12:09 PM »
Correct. The lead out appears to lead out of the thread cutting at a taper. So instead of straight pulling out it pulls out going at a taper. The diagram on page 32 shows it.

108
Ok I'm clearly missing things. I understand what Chaoticone says about the bits and setting them and resetting them. Got that. Chad, I understand essentially what you're saying. I'm not understanding all the relationships in Click.

I've guessed now that a DS register does not trigger a physical action in Click. That's where I was getting hung up on. I figured that when mach sets a 1, for instance for T0101, to DS1 in click that would automatically start the tool change. But what you're implying is it just tells click this is the next tool to change to, but doesn't actually start the tool change program which rotates the tool changer.

Right now I'm using a physical button for each tool. So for tool 1 I'm using X001 to set C1 > then C1 starts the tool change program > when the requested tool, in this case tool 1, is completed it resets C1 and stops the motion.

My tool changer works perfectly like this.

I don't understand what you wrote in your last post about the ladder program.

I think I need to use DS1 to set the tool, then I'm assuming that the DS1 is set, after the correct tool has been physically changed then the DS1 would reset? In between I'll need to start the actual tool change program?

Yeah, I'm not sure how I would write that. I get that's what you wrote about. I'm just not getting it. Let mull it over maybe it'll come to me.


109
Ok I'm starting to wrap my head around this. I've re-read this whole thread a bunch of times tonight.

Chad, you said use the compare function in Click DS1 = 1 turn on C1. Got that, that's easy. I'm already using C bits for each tool, C1-C8.

Now, if I tell Mach M6 T0101, I'm guessing it will send a 1 to DS1 and the click will goto tool 1, then a 2 for T0202, etc..?

In your macro you mention Output 22, DS1 and Input 0. Input 0 I take it is the signal going to the click verifying a tool change has completed? and that in turn tells mach that the tool change has completed and to continue with gcode?

Is the DS1 referenced in your macro sending a signal to click or just getting the value and output 22 is actually sending the tool number?

I also don't get what this code is referencing?  --Send signal to the Click to start the tool change.
         mc.mcSignalSetState(ToolChange,1) --Y001
         wx.wxMilliSleep(1000)
         mc.mcSignalSetState(ToolChange,0) --Y001

to me it seems like there are 3 different things in your macro to get the tool changing started.

110
Thanks both of you! I'm starting to get a handle on the Lua. I don't understand how register's work, but I'm sure I can figure it out. PLC's are pretty easy to program.

Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 »