Author Topic: Arduino ModBus and Mach3 for tool turret changer  (Read 10240 times)

0 Members and 1 Guest are viewing this topic.

Offline Fuzer

  • Active Member
  • Posts: 6
    • View Profile
Arduino ModBus and Mach3 for tool turret changer
« on: September 02, 2014, 07:53:59 AM »
Hello people! I need some help with my project cause after all the research i have done i still feel lost in the space.  :(

I have an emco5 cnc lathe. I am controlling 2 stepper motors through mach3 and a BOB for X-Z axis. My tool turret changer is being controlled through a dc motor and my arduino. Now i want to make the exact thing: to control my tool turret changer with my arduino through mach. I have found out a way through modBus. I have succeed in making mach3 and my arduino to talk to each other through some tutorials i found here on the forum. But how i will tell to my arduino to do this(change tool) when you see this M6 T0101in g-code? I am thinking that i have to do it somehow through the modBus and brains or through a macro.

P.S.1 I am not sure if the info i have provided are enough i am totally new at both arduino and mach3.

P.S.2 Excuse me for my english but it's not my native/mother language.

Thanks in advance people!  :)

Constantine
« Last Edit: September 02, 2014, 07:56:21 AM by Fuzer »

Offline cncalex

  • Active Member
  • Posts: 244
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #1 on: September 02, 2014, 01:38:39 PM »
Hi Constantine,
in General Config check " auto tool changer "
In your profile macros folder you will find the toolchange macro called M6Start.m1s you need to edit it.
location normally is "  C\Mach3\ macros\Mach3Turn\ M6Start.m1s"   for lathe.

Alex

Offline Fuzer

  • Active Member
  • Posts: 6
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #2 on: September 02, 2014, 02:37:54 PM »
Hello Alex and thanks for your reply! I have checked this about the macros but how i will make it? I mean how the macro will talk with the ModBus and the arduino? Or the ModBus connection is not necessary to be done since it's with macro? Or if it's necessary the ModBus connection how i will ask from the ModBus to enable that macro M6start so my arduino will be asked to make that proccess? I hope that i am understandable with my yoda-style-english that i am talking! :)

Offline Fuzer

  • Active Member
  • Posts: 6
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #3 on: September 03, 2014, 06:30:27 AM »
Here is my macro code that i have found here around on the forum for the tool changer

Code: [Select]
Sub Main()

NumSlots=6
OldTurretPos=(GetOEMDRO(803))
OldToolSlot=Abs(GetOEMDRO(803))
NextTool = GetSelectedTool()
NextToolSlot = (NextTool-1)*60


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

If NextTool>6 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 

But how i will make this macro to give a signal to my arduino to rotate the motor so the tool to be changed?
My goal is whenever there is spotted in g-code this ---> M6 T*********x
i want the spindle to stop rotating,
then  my turret tool changer to move in a safe spot and
then to trigger my arduino to rotate the motor at the specific tool
and after all these have been done i want my TC to move back
at the work station where it was and the spindle to start rotating again.

My thought was to connect the arduino through modBus.
Then somehow , i guess through a brain, to check all the time the G-code
and if M6 T*********x is spotted then M6start.m1s has to be triggered.
I am thinking that all the above i want to be done will be in that macro
and that macro i have found already it's not doing all these things i want.

Offline Fuzer

  • Active Member
  • Posts: 6
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #4 on: September 03, 2014, 07:37:52 AM »
It may be a really stupid question but do i need any modIO board to connect my arduino there?  ??? ???
Through the research i have done already no one was mentioning any kind of these boards.  ::) ::)

Offline Chaoticone

  • Administrator
  • *
  • Posts: 5,432
  • Precision Chaos
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #5 on: September 03, 2014, 08:34:02 AM »
Hello Fuzer, The first thing to relies is that it is about 99.999% certain that no ones M6 macro or Arduino sketch is going to work for you. You will have to create your own. Second, you will have to learn how the Arduino and Mach will communicate with one another. Watch all the video tutors on scripting, modbus and tool changers to help with that. http://www.machsupport.com/videos/ Download the macro programmers ref. manual. You are going to need it.

Start simple. First try to get Mach to turn on an output on the Arduino. Then have the arduino turn an led in Mach on or off depending on the status of the output on the Arduino. Once you can do this and fully understand how to get, set and reset bits in the Arduino from Mach and in Mach from the Arduino going forward will be a lot easier. I think I would then write a sketch for the Arduino to do a tool change start to finish on its own. Once you get to this point it will be time to tie it all together.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline Fuzer

  • Active Member
  • Posts: 6
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #6 on: September 03, 2014, 09:38:29 AM »
Hello Brett and thanks for your info! It seems that has a lot to be done!
Sooooo back to research once again! But thanks for giving me the path that i have to walk through!
Really helpfull and appreciated! I will be back again on here and i hope it will be for the results of my project!
Thanks once again Brett!

Constantine

Offline serpvect

  • Holding
  • Posts: 1
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #7 on: August 22, 2015, 07:17:00 PM »
The problem in fact is as follows: how to pass a command to modbus from a .m1s script and how to check a response from modbus within this .m1s script.
Anyone got a solution?

Rol.

Offline BR549

  • Mach4 Alpha
  • Posts: 6,855
    • View Profile
Re: Arduino ModBus and Mach3 for tool turret changer
« Reply #8 on: September 18, 2015, 06:28:46 PM »
MOdbus is built into the scripting language in Mach3    you can talk directly to the modbus device and Mach3 will listen for a responce from a device.

You can do it over serial or TCP if I remember correctly.   IT owould be BEST if you created all teh TC motion scripting in teh device and then Mach3 can signal to move then the device can signal back when it is done with teh move/toolchange .

(;-) TP