Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: natefoerg on February 20, 2011, 03:38:29 PM

Title: Mach 3 toolchange for dummies???
Post by: natefoerg on February 20, 2011, 03:38:29 PM
Hello!

I have done several stepper/mach3 conversions to some of my machines. I most recently converted a Hardinge CHNC Lathe circa 1980.

I have removed the original toolchange internals and now have an 8 position turret that raises and lowers with a 4way solenoid. I have just finished making an 8" .375 pitch timing pulley that fits around the base of the original rotating turret (for stepper motor indexing of the turret)

Within the next few days, I will have an A axis G203V wired to the stepper that will index the indexer.

can you please tell me (in a nutshell) how I can get mach to call for and then execute the toolchange? I feel really lost.

Also, might you have a sample of code that you use to change tools?


Again, for clairity, heres what I want to do-

Call for tool change in G code to tool X
Move to safe tool change position
Activate turret air solenoid (raise)
Index turret to position X
Deactivate turret air solenoid (4 way valve will automaticly lower and lock turret)
Continue executing G code

I hope you can spare a moment to help me...I have almost got the toolchanger ready, and cant figure out how to run it!

Best,
Nate.

natefoerg@gmail.com
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 20, 2011, 04:43:00 PM
You can use the A axis as rot rollover so 360 will be the max then it will zero again. You can also choose the shortest path option so Mach will move the stepper the shortest path.

Basically what you will need to do is when you home the axis at startup you will also have to home the turret so that Mach knows its position, then the m6start macro will just activate the output needed for the solenoid, move the axis the amount for the requested tool then when finished will deactivate the output and once thats done the macro will exit and Mach will continue.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 20, 2011, 05:57:42 PM
Not the best at VB but just tried this and it seems to work as it should


 If GetSelectedTool() = GetCurrentTool() Then
End
 End If
 
 
 If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 2 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A45"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 3 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A90"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 4 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A135"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 5 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A180"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 6 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A225"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If 
 
 
 If GetSelectedTool = 7 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A270"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 
 If GetSelectedTool = 8 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A315"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If   

 
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 20, 2011, 08:22:12 PM
Thanks hood!

I cut and pasted what you wrote.

where do I store this macro? and what do I write in the g code to call a particular tool?

also any hints on activating "output2"? do I set up an output signal in mach to put out 5v on the output to activate a relay that will power the solenoid?

why did you call it output2?
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 20, 2011, 08:46:49 PM
You want to save that as m6start.m1s and place it in the macro folder of your profile. For example if you go to Operator menu in Mach  and then VB Script Editor a window will pop up, paste it there then file menu and save as option. Browse to your profiles macro folder (eg C:\Mach2\Macros\Mach3Turn) and call it m6start.m1s. There will likely be already one there so just overwrite it. If you have a custom profile it will be that instead of the Mach3Turn in the example above.

To call a tool in Turn its T0101 (orT101 is the same) T0202......... T0808 
The first two numbers are the turret position (1 to 8 in your case) and the last two are the offset number, in other words the number in the tool table that you have the tool set to. You could for example have a few tools set up ready to place into a turret position so you may want to call T0101 or T0109 or T0117 etc


Output 2 is just what I used in the macro, you can use any of the outputs but obviously you would need to change it in the macro if you used one of the others. For hooking it up you just assign the port and pin number to the OutPut you wil use (2 in this case) and then on the BOB you would hook up a relay to the pin you have chosen, the coil of the relay would need to be 5v and then the contacts of the relay would power your solenoid, whatever that voltage is.


I have not put a Tool Change position in the macro as I prefer to just do that in my code, two reasons mainly, first is I have twin turrets (front and rear) so going to a set position is not always best as I can have tools in the way. Second is I prefer to decide what the position will be for a toolchange depending on the size of the work, that way I dont have a long way to travel.

If you wanted to add a toolchange position in the VB it would be easy enough, just put
Code"G53 G0 X* Z*)
While IsMoving()
Wend

after the first line of each tool, eg
 If GetSelectedTool = 1 Then
 Code"G53 G0 X* Z*)
 While IsMoving()
 Wend
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If

The * would need to be the position you wish to go to, in machine coords.

Oh and one last thing, I put a Sleep 500 in that is a delay to allow your solenoid to operate before the stepper will move, it is 1/2 second so if you can get away with shorter you can change that, for example Sleep 100 would be 1/10th of a second.



Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 20, 2011, 08:49:58 PM
Oh yet another thing, make sure you have the A set as I mentioned in the first post, see pic.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 20, 2011, 08:54:48 PM
Oh and that should be C:\Mach3 in the above macro location LOL, its getting late here so thats my excuse for typos :D

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 20, 2011, 09:16:19 PM
Hot damn! (american slang for- excellent info, I am very excited about trying this out)
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 02:16:19 AM
LOL

After some sleep I see you wouldnt actually have to put the move to toolchange pos in each section, just having Code "G53 G0 X* Z*" after the first block would work fine.

Like this

 If GetSelectedTool() = GetCurrentTool() Then
End
 End If
 
Code "G53 G0 X* Z*"
While IsMoving()
Wend
 
 If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 2 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A45"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 21, 2011, 12:02:40 PM
Well, I tried It and had moderate success. I can now manually type in a tool number in Mach and then run the vb script editor and it will move the a axis stepper. I can't get it to mOve to position 1 though.

I also can't seem to get it to move to the correct angular position. I just have the a axis stepper sitting on my bench right now so I have the steps set to 200 for one rotation. I also tried 2000 thinking I might need 2000 because of the geckos microsteping.

Additionally, I can't get the a xis to move from g code. I tried inserting t0201 into my code and running it to see if it would index a axis to 90 deg.

Your thoughts?
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 12:10:51 PM
Ok, steps per will be divided by 360 as you are working in degrees, so if its 2000 per motor rev that will be 5.555555555555555555555 for steps per.

On General Config page change to Auto Tool Chnager, should now work from Code.


Not sure about position 1, what exactly does it do?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 21, 2011, 02:20:37 PM
Gotcha on the steps per...

I have enabled auto tool changer on the config page. I will try again later today, but I am sure that it was enabled when I was testing yesterday...

Position 1= tool position 1 ie: 0 degrees. for some reason I can get the A axis to move to tool 2-8, but I cant move to 1. 

Is there a list of terms for the Vbasic program? I would like to be able to decipher what you have written.

Thanks!

Nate.

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 02:27:05 PM
You are using a Turn Screenset? If using a mill screenset it wont work as that sets Mach to mill mode.

Ray Livingston wrote a VB manual http://www.machsupport.com/forum/index.php/topic,12730.msg83052.html#msg83052 there is also info on the wiki which may help.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 02:29:17 PM
Oh I also mentioned it at the beginning but better say again, you will need to home the turret when you start Mach or at the very least always stop in tool 1 so that Mach knows where it is. How you accomplish that will depend on whether you just manually want to rotate or whether you have a home switch and do it via the RefAll button.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 21, 2011, 02:30:21 PM
Yes, i'm using the stock default mach3 turn screen set.

I will look into the VB manual..

Thanks.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 02:34:33 PM
If you cant get it working then attach your xml and I will see if I can figure out where the problem lies.
If you add a DRO and a LED to the screenset for A axis and Output 2 respectively then it will let you see whats going on and might help in troubleshooting.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 21, 2011, 03:54:33 PM
I read through, and searched the PDF on macro language. (is this language called VB?) you can tell how green I am at this...

I found definitions for all the terms except-

WhileIsMoving
Wend
EndIf

I am guessing that they were so basic as programming commands that it was not deemed nessisary to define them?

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 21, 2011, 04:03:11 PM
While IsMoving()
Wend                       

   This is basically just telling the VB to wait until Mach has finished moving or doing whatever.


End If

 This is put at the end of an If staement so that the VB knows its finished with that part of things.

Hood

BTW notice the spacing, it needs to be correct or you will get syntax errors, I get them a lot ;D



Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 21, 2011, 06:53:18 PM
Alright "now we're cooking" american slang for- Things are moving right along now...

I found that I had saved the macro you wrote in the wrong mach 3 macro folder...

I can now index from G code to all 8 turret positions.

How can I add the DRO for the A Axis? I have never changed the standard mach3 screen...

Also, will that dro allow me to manually enter ********* number, press enter and have the a axis be then oriented to ********* number? 
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 22, 2011, 03:15:33 AM
Ha ha, we say that too, usually cooking by Gas is the term here :)
You can use one of the screen designers to add a DRO, quite easy to do, just make sure you save your new screen by a name other than standard, that way it wont be overwritten if you update Mach. Just use the View menu in Mach to load the new screen.

No the DRO will just be like an axis DRO giving the position. You can index from MDI or you can make up a VB button on the screen which can index the turret one place at a time.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: keithmech on February 24, 2011, 10:22:04 PM
here is another simple code to do tool change:
Sub Main()

NumSlots=8
OldTurretPos=(GetOEMDRO(803))
OldToolSlot=Abs(GetOEMDRO(803)*8)
NextTool = GetSelectedTool()
NextToolSlot = (NextTool-1)*360/NumSlots


If OldToolSlot = NextToolSlot Then
SetCurrentTool(NextTool)
Exit Sub
End If

If NextTool>8 Or NextTool<1 Then
Message("Next Tool out of range")
Exit Sub
End If

MoveDis = (NextToolSlot-OldTurretPos)

 If Abs(MoveDis) >180 Then
   If MoveDis < 0 Then     
     MoveDis = 360 - MoveDis     
   Else     
     MoveDis = MoveDis + 360   
   End If     
 End If
 
ActivateSignal(OUTPUT3)  'Release Turret holding pin
Code "G4 P0.5"
While IsMoving ()       
Wend
Code "G00 G91 a" & MoveDis       
While IsMoving ()       
Wend

DeActivateSignal(OUTPUT3)  'Engage Turret holding pin     

SetCurrentTool(NextTool)
Code "G90"
End Sub
         
Output 3 is what ever you use to engage/disengage turret lock.
803 is the oem code for the a axis.
set the a axis to angular on the General config page
check auto tool change
Title: Re: Mach 3 toolchange for dummies???
Post by: keithmech on February 24, 2011, 10:25:39 PM
that should be *8 and not the emoticon
Title: Re: Mach 3 toolchange for dummies???
Post by: keithmech on February 25, 2011, 09:25:11 PM
This should be the one.! it works on my hardinge.


Sub Main()

NumSlots=8
OldTurretPos=(GetOEMDRO(803))
OldToolSlot=Abs(GetOEMDRO(803))
NextTool = GetSelectedTool()
NextToolSlot = (NextTool-1)*45


If OldToolSlot = NextToolSlot Then
SetCurrentTool(NextTool)
Exit Sub
End If

If NextTool>8 Or NextTool<1 Then
Message("Next Tool out of range")
Exit Sub
End If

MoveDis = (NextToolSlot-OldTurretPos)

 If Abs(MoveDis) <180 Then
   If MoveDis > 0 Then     
     MoveDis = 360 + MoveDis     
   Else     
     MoveDis = MoveDis - 360   
   End If     
 End If
 
ActivateSignal(OUTPUT3)  'Release Turret holding pin
Code "G4 P0.5"
While IsMoving ()       
Wend
Code "G00 G91 a" & MoveDis       
While IsMoving ()       
Wend

DeActivateSignal(OUTPUT3)  'Engage Turret holding pin     

SetCurrentTool(NextTool)
Code "G90"
End Sub
 
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 02:11:18 PM
Thanks for everyones input so far. I am still trying to figure out one thing though...

how do I set up an output pin on the SS C25 BOB to trigger the relay on my C11 BOB?

I woulds like to be able to do the following-

Type a command into MDI that will trigger a relay that will power my air solenoid. I would also like to be able to trigger the relay in G code with the VB script, but right now my most important objective is to have a button or MDI input command that will fire my relay and thus acticate my air solenoid.

I have the following-

Mach 3
SS
SS C25 BOB
C11 BOB
24V PS for the air solenoid
Air solenoid

I have set up Mach/Config/portspins/outputsignals to have output 1 enabled on port 1 pin 14. I have it set to active high so that I can have output 1 activate pin 14 to be 5vdc. I can then run that 5vdc to the C11 BOB to activate the relay that will send the 24v to the air solenoid...

How do I get mach 3 to trigger output 1, and thus make pin 14 have 5VDC?

Then, how do i run the 5VDC into the C11 BOB and make it trigger one of the (onboard) relay?

Also, how do I wire the 24VDC into the C11 BOB relay and how do I wire the 24VDC out from the relay.

Sheoot, seems like the only thing I know how to do is run 24VDC to the solinoid to manually trigger the air solenoid. This is quite entertaining BTW, and I managed to throughly impress my GF!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 26, 2011, 08:12:25 PM
I have not checked through the manuals for any of these boards but I had a look at the pics of the boards and this is how I think they would connect.


It would seem the C25 is board that provides screw connections for the SS so if using the C11 as well you will have to cut the end off a PP cables and wire it to the terminals of the C25 and plug in the other ends to the C11. What you will do then is set the port and pin number for the relay output up for OutPut1, that will mean the relay is activated when output 1 is. The 24v side is simply the +24v from supply to one of the terminals on the relays contact and the other contact then would go to your solenoid then the other side of the solenoid would connect to your 24v powers supplies 0v terminal.



Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 08:20:01 PM
In the past several hours since I last posted I have removed the C25 board and connected the SS to the C11 with the ribbon cable.

I have mach 3 set up for output 1 being pin 1. when I run this-

"""""""""""""""""""""""""""""""""
ActivateSignal(OUTPUT1)


Sleep(8000)


DeactivateSignal(OUTPUT1) 
""""""""""""""""""""""""""""""""""
I get the C11 board activating pin 1 and triggering the relay for 8 seconds.

I have managed to wire up the solenoid to 24v- on one connection and the relay triggers the 24v+, this keeps the turret locked down until I run the script and the turret pops up for 8 seconds and then locks down again...

so...I am fairly functional. took me 11 hours though...

I also get the Estop triggering when the relay shuts off after 8 seconds.

I can run the above script, but I have not found any thing that I can enter into the MDI that will execute that code. Note I have the script saved as M11.m1s in the lathe macros folder. I made up M11, as I did not know what to name the script.

Any ideas?

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 26, 2011, 08:23:30 PM
m11 in MDI should do it, however best use a number at least over 100 for the macro as numbers under 100 are really meant for Mach itself.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 08:25:40 PM
I tried M11 in the MDI, no luck...

I will rename it and try it again.

Any idea why the estop triggers upon the relay "un-activating"?
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 08:29:34 PM
I renamed it M110 and I can now enter that in the MDI and it will trigger the relay.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 26, 2011, 08:38:13 PM
Noise is likely your problem, how you will cure it I am not sure, that is the reason I like simple BOBs as you can do these types of things with seperate relays further away than the bob. Might be worth an email to Arturo at CNC4PC and see if he can suggest a fix. You could try increasing the fitering in the SS plugin but dont go too high, start at 1.43 and go up a bit if it doesnt work.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 08:45:38 PM
Interesting. Noise makes sense as I can get the M110 code run without the SS hooked up and I can run the M110 without the estop triggering at the end.

So it only does it with the relay actually activating and un-activating...

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 26, 2011, 08:55:14 PM
Does your SS still have the small Cap and Resistor at the side of the USB socket, see here. http://www.machsupport.com/forum/index.php/topic,16386.0.html

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 09:23:35 PM
Yes, I bet it does. I have a SS thats 3 years old, and I have not done that modification.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 26, 2011, 09:33:48 PM
It might help then. I have 4 SS's on machines (one is the beta board) and I only   had random issues on the one machine, I removed the cap and res from it and it has behaved ever since.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 10:43:46 PM
I busted off both of those items and cut the trace and I still get the estop.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 11:01:15 PM
put the estop at 1.43 and it stoped the estop being triggered upon relay releasing, however, mach now "stops responding"...
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 11:07:27 PM
The relay deactivating with any noise filtering setting for the estop will cause the "init" initilatization led to stop flashing on the SS... so it looks like I either get an estop triggered, or I loose SS communication. *********.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 11:12:37 PM
Changed my estop active settings and went to 1.43 noise filtering and Voila! I can run MDI M110 and not get estop or loss of SS communication!
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 11:14:38 PM
Spoke too soon. still getting SS communication loss...
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 26, 2011, 11:43:23 PM
Well, I tried everything that I could think of. I even tried grounding the solenoid to the BOB, the lathe itself 15ft away from the BOB and having it not grounded at all.

Seems that it might not be feedback from the solenoid. I think that yo may be right about the relay being too close to everything else.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on February 27, 2011, 05:20:08 PM
As a test I would use a seperate relay and have it working via an output rather than the onboard relay. Also a diode across the coil may help although I would have though the BOB would have something like that already.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on February 27, 2011, 09:51:05 PM
I already have a CNC4PC 4 relay board on the way. I will set it in the base of the lathe with the solenoids and locate the 24VDC PS there also.

I will then set up an output from the BOB, and I am thinking that having the PS/relays and solenoids at the machine instead of the controller will get mach and the SS behaving correctly... 
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 06, 2011, 01:38:33 PM
"As a test I would use a seperate relay and have it working via an output rather than the onboard relay."

Bingo! (american slang for- your guess is correct!)

using an output and having the relay mounted at the machine cured the problem.

Its fully functional (the solenoid system)

Getting closer to having the turret operational!

See-

http://www.youtube.com/watch?v=i2chFvo0LLA
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 06, 2011, 01:39:37 PM
Hood-

Thanks again for all your help.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 06, 2011, 01:43:01 PM
Good to see :)
Never have been a fan of these all in one bobs.
Looking forward to see the first cuts ;)
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 06, 2011, 01:46:17 PM
I think you were right that 24VDC was a bit much for an onboard relay.

I bought one of the CNC4PC 4-relay boards, and its quite nice/affordable.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 10, 2011, 03:26:35 PM
Hey hood-

any ideas on this-

If I put 5.5555555 into mach motor tuning for each degree of 360 degrees rotation of the turret, I end up getting the turret not locating correctly.

Theoreticly, 5.5555555 steps per unit gives me 5.5555555steps per degree. if Mach is told to go to 45degrees in A axis, the total steps commanded should be 250. There must be a rounding error or something, because it locates close, but seems to get a small bit out of wack each turret change.

Can pretend that the turret has only 8 degrees per rotation and have the stepper move 25 steps per degree, this giving me 8 locations and a total of 200 steps per rotation?

Any idea how I can get this entered into mach? the more I think about it the more confused I get.

 
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 10, 2011, 03:43:20 PM
You dont really want to go the  8 positions per rev way as it will mean you cant use the rotational rollover and thus the short rotation.
What I would do is tweak the macro so that instead of 45 degrees its maybe 44 or 46 or whatever is needed. Any idea how far it is off?
Should be able to command parts of degrees as well although I have never messed with it so cant say for sure.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 10, 2011, 05:00:09 PM
Quote
If I put 5.5555555 into mach motor tuning for each degree of 360 degrees rotation of the turret, I end up getting the turret not locating correctly.
Something doesn't sound right.
At 10 micro steps, this works out to as near perfect as you can get.
If the move is off, are you sure it was in the correct position initially ?
Even if it were rounding, it would round to the + and - sides of the desired position as the moves accumulated.
Sounds more like you are skipping some steps. Might lower the accel a bit to verify.
 :)
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 10, 2011, 05:02:21 PM
Could be something in that Russ, possibly a longer dwell needed before the turret rotates as maybe the solenoid hasnt fully disengaged the turret before its starting to try and rotate.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 10, 2011, 05:31:46 PM
Also, this is from the first post:
Quote
I have removed the original toolchange internals and now have an 8 position turret that raises and lowers with a 4way solenoid. I have just finished making an 8" .375 pitch timing pulley that fits around the base of the original rotating turret (for stepper motor indexing of the turret)
Seems there must be some reduction going on here ?
Not clear how it is actually set up. (or I overlooked it)
Even if the latch timing is OK, there is still a pretty chunky mass there to start and stop !
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 10, 2011, 05:38:32 PM
Cant be much of a reduction I wouldnt have thought or the rotation would be a mile out, but if there is then yes steps per degree will need re-worked.
Will just have to wait for Nate to clue us up on things :)

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 10, 2011, 06:11:31 PM
I agree. It's either two 8" pulleys, not likely, or that big chunk is coupled directly to the motor shaft.
Inertia out the ying yang !
Russ
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 10, 2011, 09:07:15 PM
I am working on uploading two parts of a 2 minute video that will explain better.

The first design was the big ring design with the 70tooth pulley and a 10 tooth pulley driving it.

the design now has 2, 10 tooth pulleys driving the original internal gear train (three gears). this will nessicitate a detent arm to positively locate each position before locking down of the turret.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 10, 2011, 09:49:45 PM
http://www.youtube.com/watch?v=P6_2aV_GAy8&sns=em
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 10, 2011, 10:47:09 PM
Nicely narrated video.
With the micro stepping and the evident reduction through the original gear train, I would think that the arm you speak of would not be necessary.
That is if you are sure there is no loss of steps with the motor.
It should be dead nuts for each index.
I would count the teeth in the gear train and determine the exact ratios and set the steps per accordingly.
There is probably enough backlash through the gears (you can also create a little with the belt not super taught).
Can you access the gears to count the teeth easily ?

Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 10, 2011, 11:44:57 PM
The internal gear train (3 gears) has all of the three gears with the same number of teeth.

I have locked the last gear in place for testing and have found that I have about 3 degrees of slop at the turret. That's about 1.5 degrees of slop at each gear mesh point (2 mesh points in a three gear train.

So, the stepper will locate the turret numerically accurately, but the turret can be +- 1.5 degrees when it stops. depending on how fast the turret decelerates, it can be + 1.5 degrees or -1.5 degrees. if the turret is not located +- .5 degrees of the indexing location, it will not lower down onto the locating dogs correctly.

My location problem turned out to be not having the A axis homed. now, the locating accuracy problem is purely mechanical backlash, as the stepper is going exactly where it should. I am positive that the issue (currently) is that even though mach 3 and the stepper locate the first gear in the train accurately, after 2 gear mesh points, enough slop is introduced to have the turret off just enough to only lower down onto the dogs about half of the time.

if I make a detent arm, the detent arm will snap into each of the detent locations (8 total) with accuracy which is entirely dependant upon how much accuracy the detent locations are machined to. This assumes that the detent arm does not itself have any slop (backlash)

Fortunately, cutting detent locations on my mill will be very accurate as I have a high resolution Peiseiler 4th axis. The detent arm can be made to have almost zero slop if I make it right. I plan on having the detent arm made with the spring tension being adjustable. I think the detent slots should be V shaped for positive location locking.

I hope all this makes sense. 
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 11, 2011, 06:54:28 AM
Yes, I understand better now.
3* is quite a bit, must be quite a bit of wear.
Probably be too much involved in replacing the worn parts, common size gears/bushings are available from MCarr and others pretty cheap.
You've considered this of course.
Good luck,
Russ
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on March 11, 2011, 01:35:51 PM
Their is virtually no wear on the gear train. It was designed to rotate via air motor and stop location (index) was accomplished by an air cyllinder with a stop arm. The turret was designed with gear train backlash. It was designed to overshoot, only being halted by the stop arm...

I have come to the conclusion that a detent arm or pin is a must to completely allign the position after positioning by stepper motor, so that when the turret lowers, it will engage the locking dogs correctly. if the position is not very close, the turret lowers onto the dogs incorrectly if at all.

time to make some sort of detent locating arm...

 
Title: Re: Mach 3 toolchange for dummies???
Post by: Overloaded on March 11, 2011, 06:37:57 PM
Ah, now it makes even more sense, more and more details coming to light.
I'll leave you be now, you're on a roll !
 Be sure to post pics/vid of your final design, I'm certain it will be unique and interesting.
Russ
Title: Re: Mach 3 toolchange for dummies???
Post by: cncmill70 on March 22, 2011, 08:47:24 PM
Good afternoon Gents,

I'm new to mach3 mill and turn. I'm building a automatic tool changer for my cnc lathe. I currently use bobcad/cam as my cam package and Mach3 Turn for my operation. The G code that Hood posted (I thank him alot for taking the time). Can I insert this in my Mach3 post processor ? I thank you for your help!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 22, 2011, 08:57:57 PM
Not sure what code you are referring to but I think it is likely the VB code. This is for the m6start.m1s macro, this is a macro that tels Mach what to do when a tool change is requested and has nothing to do with your code or cam programme.
 I would imagine your post processor will already have the tool calls in it so likely you will not have to do anything  to the post processor. All that is required in the code is the tool call, for example T0101 or T0356. The first two numbers of a tool call (In Turn) are the tool number. The second two numbers are the offset number and that is what you have in the ToolTable.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: cncmill70 on March 22, 2011, 09:07:53 PM
Thanks Hood! My cam program does call out the tool # and offsets. So I should be able to setup Mach3 as you described and go from there. I think maybe my thought of how it operates is wrong. Do you have any other advice for an amateur? Thanks again!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on March 22, 2011, 09:21:51 PM
You will need to write the m6start macro to suit your tool changer and how it operates. It may be similar to the one posted earlier or it may be totally different, it all depends on your changer. My macro is totally different to that one I posted as my lathe has two turrets but they are mainly controlled in a PLC external to Mach so all my macro needs to do is switch on outputs to start the PLC and then wait for the PLC to tell it that the tool is in position.

If you can say how your changer will operate I am sure someone will be able to help you out.

Well 1:20am here so sleep time for me :)
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: cncmill70 on April 03, 2011, 09:39:02 PM
Hi Hood, I have my tool changer running well. Thanks to your post on tool changer M6 info. I do have a questions, if you would help. If I want my turret to rotate only one direction all the time how would I achieve this? Currently it turns to the direction of the closes tool. Again thanks for your help!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on April 04, 2011, 02:17:07 AM
Have you tried it with not  choosing the option on General Config for "Ang Short Rot on G0" moves?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: cncmill70 on April 05, 2011, 08:40:29 PM
Hey Hood,

I hope all is well with you. I did try the Ang Short Rot feature. It did not work. Would you have any other thoughts? Thank you again!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on April 06, 2011, 06:36:41 AM
Can you attach your xml please, also your m6start.m1s macro.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: cncmill70 on April 06, 2011, 09:39:03 PM
Hi Hood,

Not to be dense but what is a XML? Thanks again!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on April 07, 2011, 02:09:14 AM
The xml is the file that contains your config, it will be named after the profile you use and will be in your main Mach3 folder. When you look in Mach at the lower right of the screen you will see the name of the profile you are using so you want a file with that name and the xml extebsion. You will likely need to rename as the forum only accepts a file name once,   so copy to your desktop and rename it to cncmill70.xml then use the additional options button on the  reply page to attach.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 16, 2011, 03:16:18 PM
Back in action here guys!

I have abandoned the stepper version of the tool changer and am reverting back to the factory configuration (more or less)

Please see this thread for an update-

http://www.cnczone.com/forums/hardinge_lathes/129658-chnc_turret_plc_conversion_log.html The post has lots of pictrures, and even some videos. I am not trying to pull readers from this forum, I am including this link so I dont have to rehash everything here.

I am however stepping back into this post in an effort to get my tool change Macro written, my VB script written and everything running through my new Cubloc Plc.

This is gonna be a steep learning curve...

Thanks for everyone who has helped out in this post over the last few months. I kind of dissapoeared, but please dont think I am ungrateful...
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 16, 2011, 04:15:59 PM
Sorry dont know anything about the cubloc.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 16, 2011, 10:44:50 PM
Hey Hood. Good to see ya.

I'm told that the Cubloc can use VB script. Sadly, the guy who did this before me and had it all hashed out and working, cant provide me with the VB script he wrote. Seems that his computer that ran his machine took a turn for the worse and wont be resurected any time soon. I guess I have to start from scratch...

Here are my thoughts on how the tool changer (VB script) needs to work

Things I need the script/plc/mach to do


Solenoids-
Activate and deactivate turret solenoid. (activated is for up/rotate, deactivated is for down)
Activate and deactivate turret rotation braking solenoid.
Activate and deactivate turret stop solenoid.

Sensors-
Read and report current turret position.
Read and report status of turret up/down position.

Proposed order of operations for tool change request-

Request tool change to position 1-8.
Read turret rotational position, 1-8.
Read turret up/down position, up or down.
Report turret rotational position, 1-8.
Report turret up/down position, up or down.
If requested rotational position equals reported rotational position do nothing.
If requested up/down position equals down, do nothing.
If requested up/down position equals up, fault.
If requested rotational position is not equal to current rotational position, activate turret up/down/rotate solenoid.
When rotational position equals requested position 1 before requested position, activate braking solenoid.
When rotational position equals requested position, activate turret stop solenoid, deactivate turret up/down/rotate solenoid and deactivate turret braking solenoid.
Deactivate turret up/down/rotation solenoid.
Report turret rotational position, 1-8.
Report turret up/down position, up or down, if up, fault.



I wish their were a translator that could take the above and write it in VB!



Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 17, 2011, 02:20:03 AM
The thing is you will need to know how the cubloc wants talked to, for example I use DL06 PLC over modnus and I can use
GetInput(*)
 and
Set ModOutPut(*,*)

Not sure if the Cubloc is the same. Do a search for fdos and give him a PM as he has used it on his Hardings, whether he will have time to help you I dont know. I seem to remember he used a variation of my toolchange macro but that he used activate signal etc so thats why I am thinking the cubloc is not the same as my PLC.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 17, 2011, 10:22:42 AM
I believe that the Cubloc is fully capable of ModBus communication. Thats how Vince set up his Mach-Cubloc communication.

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 17, 2011, 01:35:29 PM
There are several flavours of communication over Modbus from Mach, I use the serial interface rather than the plugin, I am not sure what the cubloc will/can use.
Again I seem to remember Wayne (fdos) had more like normal I/O in his VB so PM and see if he can at least point you in the right direction.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 19, 2011, 04:50:02 PM
Well, after much reading and studying, I have the Cubloc triggering relays at least!

However, I cant do much until I get the Cubloc talking to Mach3. I followed Henriks guide to setting up modbus, but am still not sure if they are talking. I have been looking for the plugin "modio" but cant seem to find it available anywhere...

I personally dont care if it gets set up via the plugin or serial. I just want communication.

The videos that cover Modio, seem to only cover setup if you use the plugin, which I cant find.

Do you have a way to do a "hello world" type test to see if I have comm between the Cubloc and Mach3?

If you have it setup serial, can you recap your serial modbus settings?

Best,
Nate.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 19, 2011, 05:43:07 PM
This is my settings on the lathe (mill similar) but I am using a DL06 PLC  so likely your setting will be different.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 20, 2011, 06:24:39 PM
Hood-

I cant find those settings anywhere. Are you running the Modio plugin?

Are you setup on tcp modbus or serial?
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 21, 2011, 05:00:03 AM
Ports and Pins then enable  Modbus Input Output Support and then restart Mach. Once restarted go to Function Configs menu then down to Set up Serial Modbus Control.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 21, 2011, 11:35:21 AM
Yup, that worked. Turns out I had the "plugin enabled" section checked.

I would try the plugin, but I cant find it anywhere...

Anyway, I will get back to work on this this afternoon. Thanks again Hood.
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 21, 2011, 12:16:07 PM
Plugin is part of the Mach download, just needs enabled. I have  never used it and as far as I know you need to use Brains for it. Dont think you can use OEM triggers and other I/O but could be wrong. Likewise I am not sure if VB works with the plugin, think it does but.....
All of the above definitely work with the standard serial interface.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: jrobson on June 21, 2011, 12:54:56 PM
Sorry to go off topic but in the standard serial interface can you add more than one serial modbus?
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 21, 2011, 01:03:31 PM
Dont think so.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 21, 2011, 01:18:08 PM
Ok, so last night before my encoder trace problem surfaced, I finally had the Ah-Ha moment...

I realized what does what in this tool changer equation. I was getting the VB script for the toolchange Macro for Mach confused with the VB script that runs on the cubloc!

I discovered this when the cubloc studio VB editor would not reckognise VB commands that were used in Fdos's macro. When Cubloc studio did not reckognise these commands I realsied it was because I was trying to edit/run/test VB script that was native to Mach! Of course I could not use this in Cubloc studio! what was I thinking?

Now, I finally put it together that the VB script (macro) in Mach is a totally seperate piece of code from the VB script running in the Cubloc. Sure, they have to talk over modbus, but each has a distinct role to play.

Mach3 VB script Macro is used to call a toolchange (in MDI or Gcode). it determines what tool position it is in, and if it is not in the position that is requested by the toolchange, it changes the tool (only in Mach) it really only changes a DRO or Register.

Meanwhile, the Cubloc VB toolchange code has been monitoring the DRO or Register in Mach for any changes. If a change is detected, it preforms its toolchange physically by means of running its VB script that triggers relays which trigger air solenoids/airmotor. The VB script also interprets the position sensors for the turret rotational position and the turret up or down sensor. Using the information from these sensors allows the VB script to raise, lower, rotate, etc.. into the correct tool position.

Also, The Mach toolchange macro requests a move to safe Z&X locations suitable for a toolchange.

All thats left is for the Cubloc to report to the Mach macro that the tool has changed to the requested position, and that the turret is locked down correctly. The Mach macro can then allow the Gcode to resume with the new tool and its appropriate offset. IF the Cubloc does not sucessfully change the tool, the Mach macro should recieve a fault signal from the cubloc which triggers Mach to go into Estop mode.

I think I understand it all now!

Each piece has its role, and these roles must be kept seperate in my mind and in reality if this toolchanger is going to be made to work.

NOW, I am awaiting a call from Garret at Cubloc (Comfile) to ask him to help me setup Modbus communication between Mach and the Cubloc.
__________________

Does it look like my understanding of how this all works together is correct?
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 21, 2011, 03:34:13 PM
Between Hood helping me find the right settings window and a call to Garrett at Cubloc, I have finally got modbus communicationg between Mach3 and the Cubloc.

I dont have any information being passed back and forth yet, but I did test communication, and it did work!!!!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 21, 2011, 03:43:21 PM
GetInput(*)
and
SetModOutput(*,*)
is how I talk to the PLC in VB so should be similar.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 21, 2011, 11:08:20 PM
Thanks Hood, I am going to do testing with the following tool change macro-

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Toolchange Macro for Mach3 and Hardinge CHNC 8 station turret.
'June 20th 2011 (based upon Macros from Hood and Fdos & possibly others)
 

   
   
Tool = GetSelectedTool() 
If Tool = GetCurrentTool() Then           'Ignore and Exit if already there
  End
End If
 

   


If Tool <1 Then                  'If tool called is < 1
  MsgBox ("Error! Tool "& tool & " Out Of Range")   'error message
  DoOemButton (1003)                       'Stop Button
  End                                      'End macro
End If

If Tool >8 Then                  'If tool called is > 8
  MsgBox ("Error! Tool "& tool & " Out Of Range")
  DoOemButton (1003)                   
  End                                     
End If




Message ("Waiting for Turret Station " & tool)




If Tool=1 Then                            'tool = 1

  Call SetModOutput (66,1)            'Reg D12
    Do
      If GetInput (67) = tool  Then          'Reg D13
        Call SetModOutput (66,0)         'Reset D12
        Exit Do
      End If
    Loop
End If


 
If Tool=2 Then                            'tool = 2

  Call SetModOutput (66,2)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=3 Then                            'tool = 3

  Call SetModOutput (66,3)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=4 Then                            'tool = 4

  Call SetModOutput (66,4)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If
 
 
 
If Tool=5 Then                            'tool = 5

  Call SetModOutput (66,1)           
    Do
      If GetInput (67) = tool  Then         
        Call SetModOutput (66,0)         
        Exit Do
      End If
    Loop
End If


 
If Tool=6 Then                            'tool = 6

  Call SetModOutput (66,2)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=7 Then                            'tool = 7

  Call SetModOutput (66,3)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If


 
If Tool=8 Then                            'tool = 8

  Call SetModOutput (66,4)
    Do
      If GetInput (67) = tool  Then
        Call SetModOutput (66,0)
        Exit Do
      End If
    Loop
End If
 
 
Message ("Station " & tool & " OK")      'Status Msg       
SetCurrentTool( tool )

End
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



I have the above saved as M6Start.m1s in my mach3/lathe/macro folder. I know that the macro runs because I get a "Waiting for turret X" message when I manually enter in a toolchange like T0101.

Now that I have Modbus communication, the next step is to figure out how Fdos acomplished the following-



$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
For anyone thats interested here's the M6Start macro for the 4 station turret on my Hardinge.

It passes the requested station # to the Cubloc PLC via a holding register mapped to 66 in mach and D12 on the Cubloc.

The Cubloc always has it's actual station # available in D13 (67 in Mach) via it's turret encoder routine.   = 0 when invalid = 1 to 4 for valid stations.

I'll probably post the Cubloc program when it's developed a bit more.

The Macro below is partially based on Hoods Churchill Macro.  Thanks Robin...


Wayne.....
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

*********, I'm lost...
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 21, 2011, 11:17:57 PM
I sent Fdos an Email also, to see if he can chime in and give me some guidance. I hope he gets the email!
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 23, 2011, 07:36:15 PM
No luck raising Fdos. Sadly.


"It passes the requested station # to the Cubloc PLC via a holding register mapped to 66 in mach and D12 on the Cubloc.

The Cubloc always has it's actual station # available in D13 (67 in Mach) via it's turret encoder routine.   = 0 when invalid = 1 to 4 for valid stations."

Can anyone explain the above quote from Fdos?

It appears to say that holding register 66 in mach is autopolled and reported to D12 on the plc. Furthermore,  that the plc code writes a station number to D13 and Mach autopolls this and reports this on holding register 67.

Am I right?
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 23, 2011, 09:11:33 PM












Hood. I have your settings that allowed you to have communication between Mach and your PLC, if you could please share your Mach macro and the code on the PLC, I would then be able to decipher how they talk to each other and start to figure out how to write the code for my PLC.

I have searched, but have been unable to locate anyone who has posted both the VB they run as M6start in mach and the code they have running on their PLC. I can find lots of M6start examples, but nothing on the PLC side...

Is your PLC code in ladder or basic?










Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 23, 2011, 10:12:07 PM
Hi Nate,

Without knowing the history, as I'm at work and don't have time to study the whole thread.

If you have enabled the plugin version of Mach3s Modbus interface, you need to talk to the Modbus interface via Mach3 brains. So, your M6Start macro need to put data into user DROs, then you need to write a brain to read the User DRO and write it to a Modbus register.

To read Modbus data, you need to do the reverse. A brain reads the modbus data, puts it into a User DRO and then the M6Start macro reads it from there.

The other way to do it is to not use the Plugin Modbus interface, but the old legacy interface. Then you can read and write to this interface directly from the M6Start macro, using calls like Call SetModOutput (66,0)

I've done a number of toolchange interfaces using this method with the ModIO. Here is 1 example.

http://www.youtube.com/watch?v=YKb2g5xalEk

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 23, 2011, 11:25:48 PM
Peter-

Thanks so much for chiming in. I have been studing the things you have written about Modbus. I have also watched several of your videos. I would prefer to use the legacy interface.

Can you please explain to me with an example how to use GetInput(*) and SetModOutput(*,*)?

I dont think that I can really wrap my head around this until I see how they are used in an example.

I know you are very busy, but if it make a difference, everytime anyone (like you and Hood) helps me get closer, you are helping others get closer in the future also, as I am diocumenting my turret conversion here http://www.cnczone.com/forums/hardinge_lathes/129658-chnc_turret_plc_conversion_log.html in great detail. 

My goal is to doccument the process so throughly, that anyone in the future can do the same or simmilar with very little research or effort. I find it very frustrating, that I am having to "reinvent the wheel" I have found that everyone who has done this in the past has left large or small holes in their postings about how they did it. these holes are not easily filled. I am making a post that leaves NOTHING out. I want the next guy to be able to buy the right parts, wire them up, plug in my settings and have it work. I hope the next person does not need to spend weeks trying to tease enough information out of people/books/wikis to get it functional.

We should be building upon each others expierence and knowledge, not relearning the same stuff over and over again.

Ok, I'm done ranting now....   ;) 


Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 23, 2011, 11:52:57 PM
Hi Nate,

I'll get some stuff together over the weekend that should hopefully make it clearer.

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 23, 2011, 11:53:47 PM
That would be great. I'm dying over here...
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 23, 2011, 11:56:17 PM
BTW, have you tried controlling the turret by using the Modbus test page. With it you can manually set and read registers to walk through the operatiomns to ensure that the PLC side is doing it's thing.

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 24, 2011, 12:01:55 AM
Nate,

Also, have you read this page? It is a good introduction.
http://www.machsupport.com/MachCustomizeWiki/index.php?title=Modbus_in_Mach

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 24, 2011, 12:11:40 AM
Yes. About five times today already. I have printed it and will read it till it makes sense!
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 24, 2011, 06:22:18 AM
Nate, my PLC is ladder so nothing needed except the m6start.m1s for me.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 24, 2011, 12:07:50 PM
Thanks hood. I appriciate it.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 25, 2011, 06:02:47 PM
Hi Peter,

I'm stuck at the point of referencing registers from Cubloc. My test code in Cubloc is:

Do
   If _D(66) = 1 Then
      High 40
   End If

   If _D(66) = 0 Then
      Low 40
   End If
Loop

Basically, turning on a relay when holding register 66 is set to 1. When I manually change holding register 66 through Test ModBus, the relay is set. However, when I use the following VBA code in Mach3:

Call SetModOutput (66,1)

The relay is not set- it seems like it's referencing a different register. My AutoPolling Options are set with Input Start Addresses of 1025 and 1536, and Output Start Address is 2048. I'm using this setup based on someone's post who had a similar project, but I have no idea what it means. Could you explain how the Start Addresses are used?

Do you have any idea where I'm going wrong?

Thanks,
Nate
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 25, 2011, 07:07:08 PM
It was mine you copied but mine is for the PLC I use so your address's may not be the same. The 1025 is decimal for 2001 Oct, 1536 dec for 3000 Oct (My analogue ins) and 2048 is dec for 4000 oct.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 25, 2011, 09:35:12 PM
Interesting Hood. sure it was your settings. long day...

What does the "oct" stand for? something to do with 8 bits?

Can you explain how the Start Addresses are used? in plain english?
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 26, 2011, 03:19:11 AM
Peter is the expert on this kind of stuff but my understanding is
My PLC works internally with Octal and Mach address is Decimal equivalent, so for example ModBus Inputs to my PLC ladder (OutPuts from Mach)  are written as B4000.0, B4000.1 etc in my ladder and ModBus outputs from my PLC are B2001,0, B2001.1 etc
If you know what registers your Cubloc uses and whether its octal or whatever then you can convert to decimal and that would be your start ranges in Mach.
Here is  a snippet from the lathes ladder to let you see, first is showing inputs to PLC from Mach, second showing Outputs from PLD to Mach..
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: keithmech on June 26, 2011, 10:00:28 AM
http://henriksplace.se/cnc/cnc_mach3_modbus_1.html
Have you read this?
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 26, 2011, 11:40:46 AM
keithmech-

Yes, I have studied it many times. Sadly, it pertains to TCP and not Serial...
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 26, 2011, 11:47:18 AM
You sure? seems to be serial but via the plugin.
Have you tried setting the start register as 0?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 26, 2011, 02:42:10 PM
Interesting...

He is using the plugin and serial setup. He mentions brains, but I dont see him using one.

I am using Version R3.042.040 was the "Plugin" added in later versions? I dont have it...
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on June 26, 2011, 02:47:57 PM
You do have the plugin, I told you before it comes with Mach ;)
Enable on Ports and Pins Modbus support and  Plugin support, restart Mach then from Functions config choose the serial modbus and the plugin will open.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 26, 2011, 07:58:00 PM
Hi Nate,

OK, To set up the Legacy Modbus for a remote PLC. This is for my toolchanger.
You will need to adjust the register numbers. I also use macro 999 that is run in the Mach3 init string to initialse my toolchanger variables, etc.

 The Mach3 Modbus interface should be configured. This is a config for my toolchanger (i,age below):

' ModIO Checkbox NOT checked
' First line of AutoPolling Input not checked - No inputs can go to Ports and Pins
' Second line of Inputs Checked, Slave = x, Start Regs = 1200, # Regs = 3
' First line of Autopolling Output not checked - no output Ports & Pins
' Second line of Output Slave = x, Start Regs = 1100, # Regs = 2




I set up modbus to read 3 registers  starting at address 1200. I also set up twp output registers starting at address 1100
Mach3 reads and writes the modbus data from buffers. There are 2 input buffers and 2 output buffers, organised as;
0-63       Input buffer 1
64-127   Input buffer 2
 
0-63      Output buffer 1
64-127   Output buffer 2
 
 
I use input buffer 2 and output buffer 2. This is because Mach3 maps some of buffer 1 to it's input and outputs signals. We don't want that.


When you want to read register 1200 you do it by;

value = GetInput (64)

This is because register 1200 was read into the 2nd input buffer starting at index 64



When you want to set register 1100 you do it by;

SetModOutput 64, tool ' output requested tool number

This is because register 1100 is written from the 2nd input buffer starting at index 64



So, you need to use GetInput(r) to read your registers, and SetModOutput r, v to write outputs.

I know that the commands GetInput and SetModOutput seem inconsistant in format but thats the way it is. 

I set up these constants so I can use the register names rather than the buffer index.

Const ChangerCurrPos  = 64      ' Inputs  1200 Current tool
Const ChangerCountReg = 65      ' 1201 Change done indicator
Const ChangerErrCode  = 66      ' 1202 Error code reply if problems

Const ChangerReqPos   = 64      ' Outputs 1100
Const ChangerInitReg  = 65      ' Outputs 1101


I hope this helps.

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 26, 2011, 08:06:55 PM
Peter-

Thank you SO much. I am going to try to piece together what you have written in my mind. Every bit is bringing me a bit closer!

Would you be able to post your m999 start macro? if you did not want to post it, could you email it to me? natefoerg@gmail.com

Looking at it would help me fill in the blanks...
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 26, 2011, 08:40:02 PM
Hi Nate,

All it does is sets the changer to the current tool at startup. This is needed a M6Start is only run when a Toolchange is commanded.

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 26, 2011, 08:49:40 PM
Sure, I get it now. Can you share your M6start?
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 26, 2011, 08:58:52 PM
Hi Nate,

Sorry, not at this time as it's specific to the ModIO, and I have an up coming commercial use for it.

that said I'm happy to help you sort out yours.

Cheers,

Peter
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 27, 2011, 09:40:46 AM
Hood-

Thanks. you were right about the plugin and how Henrik set his up. it is Serial via the Plugin. I just did not see that..

My understanding (very incorrect) was that to use the plugin, I had to comm over tcp.

Peter-

Thanks. I get the bit about the M6macro. your and Hood's help is invaluable. Additionaly Peter, I look forward to spending money on your products whenever possible. I wont forget that you were willing to help...
Title: Re: Mach 3 toolchange for dummies???
Post by: fdos on June 27, 2011, 03:16:14 PM
I'm here just rather busy.

I posted all the code in my HXL thread.  The CHNC turret is completely different though and a much harder animal to control.  

Basically all I'm doing is using a holding register to hold current tool station.   The Cubloc runs a basic loop which looks to see if a new station has been requested and operates the air valves to achieve this.

The CHNC turret is bi-directional and operates with an air motor.  My code is not going to help you really as my HXL turret is an indexing type and single direction.

You basically have to monitor the encoder and fire the stop solenoid in sufficient time to stop the turret on the CHNC.

You might want to find this guy

http://video.google.com/videoplay?docid=6834017345329403743&hl=en#

I just googled "cubloc chnc" and that came up.


Wayne...

Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 27, 2011, 08:08:08 PM
Fdos-

Thanks for chiming in.

"The Cubloc runs a basic loop which looks to see if a new station has been requested and operates the air valves to achieve this." very good explanation!

Fortunately, the CHNC turret actually only runs one direction.

I have contacted the guy (Vince here) who made that video many times. sadly he is too busy to help, and cant provide me with any code or settings due to the PC that runs his lathe being down.

Its a heart breaker, knowing that data is all there, just inaccessible... 
Title: Re: Mach 3 toolchange for dummies???
Post by: Peter Homann on June 27, 2011, 08:22:08 PM
Hi Nate,

What part are you actually stuck on?

Cheers,

Peter.
Title: Re: Mach 3 toolchange for dummies???
Post by: fdos on June 28, 2011, 06:58:59 AM
It's been such a long time since I have been inside a chnc. 

Have you managed to decode the turret ecoder with the cubloc?  I seem to recall it's output is bcd.

Can you operate the air valves to lift turret, spin it and engage the turret stop?

If you can it's all down to getting the timing right.

 
Title: Re: Mach 3 toolchange for dummies???
Post by: natefoerg on June 28, 2011, 09:06:24 AM
The part we kept getting stuck on was the autopolling input and output start registers. Nothing anywhere we could find seemed to tell us where we could find what the start registers should be. We looked in Cubloc book, online, and finally when hood pointed out that Henrik had used both serial and the plugin, we then had a known good number to start with for the start register.

Finally last night (late)we had mach communicating with the cubloc/cubase32/relay board. We could MDI T0101 etc, and trigger a different relay for each seperate T*********X. A great sigh of relief was heard coming from the three of us. We had been struggeling for many hours to get that elusive piece of info that was- a working start register number!

We have lots of work to go, but now that we have at least got T*********X triggering relays, we feel the worst is over, we hope...

Fdos- I am building an encoder simmilar to the original Hardinge encoder, made of hall effect sensors. I am using all eight sensors as inputs to the cubloc, so no need to decode anything.

Next are these tasks-
connecting relays on the cubloc to the solenoids.
getting the encoder installed.
getting cubloc to write the encoder position to Mach.
writing the Cubloc tool change code.
Installing the turret up or down sensor.


A big thanks to everyone for all of your help.

I promise to add everything that will be helpful/needed for the next person trying this. I am determined to not have the next guy struggle this much...

 

 

 
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on September 29, 2011, 04:23:51 AM
Hi All
I have the same problem as CNC70 on page 7 of this thread. (CNC70 did you manage to get your tool changer to work?)
I can get my tool changer to work well but only if I call the tools in one direction. If I call a lower number of tool to the carrent tool the turret tries to run backward against the ratchet lock. The turret can only rotate in one direction because of the lock.

I have tried it with not  choosing the option on General Config for "Ang Short Rot on G0" moves.

Does anyone have any ideas how I can set this up so that the tool changer will only operate in one direction.

Regards

Arthur

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on September 29, 2011, 04:37:27 AM
attach your xml and macro and I will have a look and see if I figure out the problem.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on September 29, 2011, 05:51:08 AM
Thanks Hood,

This Macro is only a trial based on a friends  using 4 tools for testing I will change it to 8 tools later.
Also I have temporarily  removed the entries required to move the table to safe position for toolchange as I have just been manually entering the tool changes during testing.

I have emailed the files as I get an error when I try to attach the files here. (already file of same name being used)

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on September 30, 2011, 02:37:38 AM
I looked at your xml and macro but cant see how that macro would work when used with a rotational axis as it is calling the axis to go to positions between 1 and 15 units depending on tool.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on September 30, 2011, 03:15:49 AM
Hi Hood

An A value of 36 gives a full rotation of the turret which means it is 4.5 per tool. (8 tools)

So for tool 2 the values for A are 5 which takes it past the ratchet and 4 back onto it.

This works for all 4 tools. I have only been testing by manually inputting T0202 M6 etc.

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on September 30, 2011, 03:35:18 AM
You would need to use 360 degrees for full rotation and work out steps per degree.
You would need to enable Rot Rollover on General Config and disable softlimits rot axis and Short Rot on G0 moves as well.
You will NOT be able to use G53 if you wish the axis to rotate to the tool in one direction only, this will mean you need to home the turret.
To make your turret rotate forward you would just call the angle you need for example G0A15 then to reverse 1 degree you would call G0A-14. If you called G0A0 the turret would rotate the long way round which is what you want.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 02, 2011, 12:17:28 PM
Thanks Hood,

I now have it operating in degrees and it is working well and I can now  change to any tool using manual inputs. I just need to set up a home switch now so tool 1 is always tool 1.
The next problem I see is that I cant edit the button script for home all on mach 3 lathe to include the toolchanger.
Do you know how I can get round this?

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 02, 2011, 12:58:57 PM
Open the screen in screen4 (or MachScreen if you prefer) double click on the button and change it to a VB button then save as a different name (so it doesnt get overwritten if you upgrade) and then in Mach load the renamed screen. Remember you need to make sure its saved a a .lset.

Regarding the home switch on the turret, you dont actually need one, just need to make sure when you home the turret is on tool 1.
Actually thinking about it as  you are working in G54 coords homing would not really be needed if you put an A DRO on the screen as you could just zero by typing. Probably still best to home though but.....
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 02, 2011, 05:59:03 PM
Hi Hood,

I cant get machscreen to run and I have tried to add a button using screen4 to the standard turn screen to zero the toolchanger but it screws up the position of other elements of the screen.
I am using XP.

Any ideas whats going on?

Regards
Art
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 03, 2011, 07:23:39 PM
Hi Hood

I have downloaded another (3 page lathe screen from works in progress) screen set with an A axis dro and zero button and it seems to be working okay without a home switch.
There is no diagnostics screen but I could load the standard screen set if needed.

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 02:33:09 AM
Sorry missed the previous post. Where were you wanting the button placed?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 03:26:12 AM
Hi Hood,

I was trying to put it to the left of  the X & Z DRO's and zero buttons on the standard screen. Thie other screen I downloaded with the A DRO and zero button from the forum seems to be working well and it does have a diagnostic page.

The problem I have now is that when I move from tool 1 to tool 2, G00 A46 followed by G00 A-40 to return against the ratchet (DRO shows 40 degrees) Then Move to Tool 2 by G00 A91 it moves the tool 51 degrees which requires a larger negative move to return against the ratchet. I know I could just say G00 A85 to get to tool 2 bbut I think that is going to get messy.
Is there a way that I could set the A DRO to the proper value for the tool after the move in the macro? ie After the G00 A-40 set the A DRO to 45.

Regards

Art
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 03:35:28 AM
Not sure how your macro is set up but you could set the A DRO to what you want after the toolchange by calling
SetOemDRO(803,XX)
where XX is the value you want. Make sure you have a
While IsMoving()
Wend
on the line before you do that so that it wont happen until the turret has reversed and the DRO is set.

Presume the reason you are needing this is because you are stalling the stepper so position is out a bit?

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 03:45:09 AM
Hi Hood,

Yes you have to stall it to keep it hard against the ratchet or there is movement in the turret.

Regards

Art

Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 03:52:58 AM
Hi Hood,

SetOemDRO(803,XX)
I dont know where XX is going to be generated I will need to have some way of the program knowing that when tool 2 is selected that the DRO is set to 45 after the change etc.

Regards
Art
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 04:08:06 AM
All depends on how your macro is written I suppose.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 04:12:50 AM
I was going to try and modify the one I emailed you earlier.

Regards

Art
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 08:36:13 AM
Well just looked at the macro and think this should work
Code "G53 A" & Apos      'For turret on A-axis change Z to A      
Code "G04 P1"         'Could be shorter pause or none?
Code "G53 A" & Alock      'For turret on A-axis change Z to A
Code "G04 P1"         'Could be shorter pause or none?
While IsMoving()
Wend
SetOemDRO(803,Apos)   'This bit added to set DRO back to position wanted.
Sleep 1000                    'Wait for 1 second for DRO to update, could put Code "G4P1" instead if wanted


Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 08:44:23 AM
Hi Hood,

I have a label with tool position showing the degrees of the tool position which has an OEM code 106 Can I use this with SetOemDRO(803,xx) where xx is the number stated as the tool position?(OEM106)

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 08:47:27 AM
Possibly, how do you set that user label?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 08:49:16 AM
Hi Hood

You enter degrees in tool position in the tool table.

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 09:09:03 AM
sorry not following, probably best to attach your macro, you will need to rename it to something like ArtM6Start.m1s for the forum to accept as it will only accept a file name once.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 12:53:10 PM
Hi Hood,

Please find attached Macro and image of screenset I am using.

I think I need to set the DRO at the exact angle after every toolchange, this macro sets the dro to the requested angle to pass the rachet. ie 47 degrees for tool 2 which means that it tool 3 is set to move to 97 degrees it is only actualy moving 45 degrees and does not pass the ratchet.

Can I use the tool table to enter the angle of the turret and read this from the tool direction reading on the screen.

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 02:50:57 PM
Ok that macro is the same as you sent before so only for  a 4 pos turret and yours is 8 I think?
You will have to alter the macro to suit before you will know if it works or not. What I think you are going to have to do is make each call a bit more than the distance it needs to move to clear the ratched before it moves back, so for example 360/8 = 45 degrees then as you say your tool calls would be 47 for tool 2 then reverse maybe 5 degrees then set the DRO to 45. Tool 3 would be 92 reverse to 87 then set DRO 90

So in the previous example I gave your macro would need a line that says
SetOemDRO(803,(Apos-2))

Still not sure what you are meaning regards the tool table, it is for setting tool offsets not turret rotation amounts.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 04, 2011, 05:24:19 PM
Thanks Hood

Its all working well now I have just run a job through and all tool changes went without any problems.

The tool table thing was just me trying to find a way of getting the correct angle for the tool but SetOemDRO(803,(Apos-2)) was all that was required.

Thanks again

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 05:59:48 PM
Ah ok I understand now. Glad its working :)
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 04, 2011, 06:09:11 PM
Meant to ask, what kind of turret is it you have? Did it come with a lathe or did you purchase it from somewhere? Reason I ask is I am currentl;y retrofitting a small lathe and in the future I will likely fit a turret and I am not sure whether making one or buying one would be the best option.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 05, 2011, 04:35:24 AM
Hi Hood,

It was a boxford 240 cnc lathe that came with the tool turret fitted. It used to run on a BBC computer. It was in really good conition very little used.
I picked it up a few years ago for £400.00  from a college near Glasgow. I  used the original steppers and drives and fitted a Campbell combo board.

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 05, 2011, 04:39:52 AM
Ok thanks for the reply, will see what happens once I get the wee lathe up and running.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 10, 2011, 06:18:15 AM
Hi Hood,

I noticed a problem over the weekend while using the lathe  that the tool change is adding the tool offsets from the previous tool to the move back to the original start point.

If I start at X0 Y0 with tool 1 (which has no offset) and change to tool 2 the turret moves to the safe position stated in the Macro and returns to x0 y0.
When I change to tool 4 the turret moves to the safe position and returns to  x-35.8170 y18.349 which is the offset for tool 2
If I return to tool 1 the turret moves to safe position and returns to x-71.634 y 53.560.

This distance increases with every tool change until the axis hits the limits.

Any ideas what I am doing wrong?

Regards

Arthur

Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 10, 2011, 06:39:25 AM
Is that your lathes toolchange macro?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 10, 2011, 06:49:07 AM
Sorry my apologies, was looking at someone elses macro ::)
Will have a look at yours in a bit.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 10, 2011, 07:10:00 AM
Just to get this clear in my head, the tool number DRO is updating correctly with the tool number called, eg t1 called and the DRO shows 1 after the toolchange?

The offset of each tool is ok when called?

It is the toolchange position that is increasing each time?


How are you calling the tools?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 10, 2011, 10:53:34 AM
The tool number DRO  is updating correctly and the offset is ok when called.

The problem is when the tool returns to the original position before the change is called.

Changing from tool 1 to tool 2 is okay as tool 1 has no offset but changing from tool 2 to tool 4 the machine returns to the offset stated in tool table for tool2 not the original start point.

Calling the tools T0101 M06 etc.

Regards

Art
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 10, 2011, 03:43:36 PM
Ok think I see what you are saying now, you have a toolchange position and you want the machine to go there to change the tool, it does and then after that you want it to go to the same coords that the last tool was at?
If thats what you are meaning normall that is done in your GCode, ie you change the tool and the next line of code after the change takes the tool to where it is to start.

If thats not what you are meaning then let me know and I will try and understand again :D
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 13, 2011, 01:34:07 PM
Thanks Hood,

Following our conversation on skype the other night the turret is now workiing well and there are no more strange moves after tool change.

One more question for you there is an NPN proximity switch on the x axis lead screw with a slotted disc. Should I be using this? it is not connected yet.

Regards

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 13, 2011, 01:59:15 PM
No, that may have been used for threading with the original control possibly but with Mach you need a pulse from the spindle.
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 13, 2011, 03:31:31 PM
Actually just read again, you said X axis. Dont have a clue what that would have been for, only thing I can think of is its some kind of crude encoder to close the loop to the old control. If it was an opto that had a flag block it at the extent of travel then it would likely have been a limit switch but a slotted disc puzzles me.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Flying Scot on October 13, 2011, 04:27:20 PM
I have removed it and  I do have the pulse from the spindle.

Thanks again

Arthur
Title: Re: Mach 3 toolchange for dummies???
Post by: Tr_G on November 26, 2012, 11:18:12 PM
Hello

Does anyone have any code to run a 16 tool changer so it can find the requested tool?
Details are:
16 tool ATC
output for CW
output for CCW
read input that is off and on to count tools

Title: Re: Mach 3 toolchange for dummies???
Post by: rasta on October 29, 2013, 04:59:24 AM
Hi Hood;
Can you please suggest a line that can be added to the vb script so the program does not start until the signal is given that the Toolchanger has reached the bottom of the location slot? That way if there is any missing steps in the Toolchanger stepper it will not do anything until corrected
Kind regards
Mariano


After some sleep I see you wouldnt actually have to put the move to toolchange pos in each section, just having Code "G53 G0 X* Z*" after the first block would work fine.

Like this

 If GetSelectedTool() = GetCurrentTool() Then
End
 End If
 
Code "G53 G0 X* Z*"
While IsMoving()
Wend
 
 If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 
 
 If GetSelectedTool = 2 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A45"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
 End If
 

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 29, 2013, 03:12:00 PM
Do you have an input to Mach that shows the turret is not clamped?
Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: rasta on October 29, 2013, 03:21:46 PM
Do you have an input to Mach that shows the turret is not clamped?
Hood
i have set up pin 11 as an input , and fitted a limit switch inside the toolchanger that closes when the toolchanger shaft has bottomed, but, Im lost on the VB bit
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 29, 2013, 03:37:58 PM
Maybe something like this would do.


If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
sleep 1000
If IsActive(Input*) Then
End
Else
MsgBox("Turret not clamped")
DoOemButton(1003)
End If
 End If
Title: Re: Mach 3 toolchange for dummies???
Post by: rasta on October 29, 2013, 03:47:43 PM
Maybe something like this would do.
Tank you Hood;
I will try it tonight when I come back, now I have to drive a Mori-Seiki, with twin chucks and live tooling .great machine.
regards
Mariano


If GetSelectedTool = 1 Then
 ActivateSignal(OutPut2)
 Sleep 500
 Code "G53 G0 A0"
 While IsMoving()
 Wend
 DeActivateSignal(OutPut2)
sleep 1000
If IsActive(Input*) Then
End
Else
MsgBox("Turret not clamped")
DoOemButton(1003)
End If
 End If
Title: Re: Mach 3 toolchange for dummies???
Post by: Hood on October 29, 2013, 05:06:36 PM
Thinking about it you will likely get away with just putting these lines at the end of the macro rather than having to put them in each tool call.

Hood
Title: Re: Mach 3 toolchange for dummies???
Post by: Tr_G on October 29, 2013, 08:47:38 PM
I did get the tool changer working on a 1984 Kitamura but only in clockwise direction. When I tried to go cw and ccw it would miss count the tool because when the motor on the changer stopped sometimes the led signal will be on and sometimes off and this would mess up the tool count.
If any one can add some code to correct the position to check if the led signal is on when it finishes the tool change rotation this would correct the cw cww problem.




'Find shortest route to next tool

ChgTool = (NewTool - SpinTool)

If ChgTool < 0 Then
   ChgTool = (16 + ChgTool)
End If

If ChgTool > 0 And ChgTool <= 16 Then          'in my code here I changed the 8 to 16 so it only goes CW
   Call CW(ChgTool)
   Exit Sub
End If

If ChgTool > 0 And ChgTool > 8 Then
   ChgTool = (-16 + ChgTool) * -1
   Call CCW(ChgTool)
   Exit Sub
End If