Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: jve on August 09, 2009, 02:39:04 AM

Title: 16 atc via modbus
Post by: jve on August 09, 2009, 02:39:04 AM
hi guys
i just made a setup in a ab plc (micro logics 1100) i conect it with mach3 and i have comunications my problem is that i need to write and reed from mach3 and i dont know wich way is the simpler brains or vb my plc is waiting for 4 bits 80,81,82,83 so when the plc recive the binary code of those bits it means the tool position did any one did this type before so i can see the vb or brains for the m6 and have idea how to make it
regards
jeffrey
Title: Re: 16 atc via modbus
Post by: jve on August 09, 2009, 01:20:04 PM
any one has some vb or brains that wright and reed to modbus what code i have to do ?
Title: Re: 16 atc via modbus
Post by: vmax549 on August 09, 2009, 01:25:28 PM
I believe the best approach would be from VB . The exact code will depend on HOW you want it to work. AS I see it you would need to create a table that represents your PLC code so when mach calls for a tool change and presents the Tool# the table wil allow VB to send the correct PLC code across the modbus port.

Just a thought(;-) TP

Title: Re: 16 atc via modbus
Post by: jve on August 09, 2009, 01:46:00 PM
ok thanks for your reply
i need mach3  first go to a fixed position on the z axis and wright code for tool no as the binary table
reg  83  82  81  80    tool
        0    0    0    0        1
        0    0    0    1        2
        0    0    1    0        3
        0    0    1    1        4
        0    1    0    0        5
        0    1    0    1        6
        0    1    1    0        7
        0    1    1    1        8
        1    0    0    0        9
        1    0    0    1        10
        1    0    1    0        11
        1    1    0    1        12
        1    1    0    0        13
        1    1    0    1        14
        1    1    1    1        15
        1    1    1    1        16
and after the plc wright to mach a bit that the tool change is ready
Title: Re: 16 atc via modbus
Post by: vmax549 on August 09, 2009, 01:57:08 PM
See IF this post helps you out(;-) If not maybe Scot can help you out.


http://www.machsupport.com/forum/index.php/topic,12192.0.html
Title: Re: 16 atc via modbus
Post by: poppabear on August 09, 2009, 02:48:19 PM
Look in the memory map of your PLC.  I suspect that your control bits are part of a 16 bit word.

My suggestion would be to make sure that word starts with "control bit 80" (if not find the word range that starts wtih a control bit and use that entire word (all 16 contorl bits).

At any rate, reserve the control word range to your ATC in the PLC.  Then since your only really dealing with the 1st 4 bits of a 16 bit work, you can then just send the decimal equivelant of that tool across the modbus into the Control Bit WORD.  You can then use the control bits as your doing (which equates to "Bit of Word" any way), or, just use the decimal value of the entire word for you compare statements in the PLC.

scott
Title: Re: 16 atc via modbus
Post by: jve on August 09, 2009, 03:54:19 PM
do you have any example how to send a bit word from a vb or brain
Title: Re: 16 atc via modbus
Post by: poppabear on August 10, 2009, 07:49:33 AM
again, in my explaination above, you will need to see if your 16 C bits are in a complete word, or make them so (at least the "Small indian" last 4 bits).

You will have to do a combination of a Brian and VB, for instance if you want to send tool #2 to your PLC.

in VB you will send the next tool you want to change to, to the PLC.

i.e.

NewTool = GetSelectedTool()
OldTool = GetCurrentTool()

if OldTool <> NewTool then
SetUserDRO(2000, NewTool)
end if

SystemWaitFor (INPUT4) 'when the PLC is done, it can turn on input4 so the M6 will drop out.

SetOEMDRO(824, NewTool)

'////////////////////////////////////
The above will load the NewTool (next tool wanted), into User DRO 2000.
Then in a Brian, Lets say that your Cfg0 is your output cfg on a serial modbus. That will load the value of DRO 2000
into the First (starting address) of your PLC range for that config.

Brain: (using plugin enabled serial modbus)

DRO 2000 ->NoOp -> Serial P MB, out, cfg0, address 0

So, in your PLC, if you do a data view on the word that contains the 16 control bits (your just using the lower 4).

So in decimal that word would now contain a 2.

in binary it would have a 0000000000000010 at the end.

thus C0 = 0, C1 = 1, C2 = 0, C3 = 0

The example that VMax refered to above, was/is for a much more complex "Hot Swap" code, you dont get any gain in speed with that code unless you have a swap arm.

So, do a Search for ATC in the VB thread, you will find several examples for doing ATC's.

scott



Title: Re: 16 atc via modbus
Post by: jve on September 19, 2009, 12:57:30 PM
today i tried the above vb and brain but when i look in the plc it only change the first bid
example if i put t2m6 and go in the plc software i only find on the coils 0000000000000001 and if i put an other tool change no it is always desame do i have to set the plc in the holding regestre instead of the coils
Title: Re: 16 atc via modbus
Post by: poppabear on September 27, 2009, 10:42:25 AM
then you are writing to "coils" in the PLC, you need to write to a "Holding register", or user memory.  Then do a "Bit-of-word" operation on that register to grab the Tool requested, from there you can do compare statements that then activate your sensor for your Binary input patteren your looking for.

scott
Title: Re: 16 atc via modbus
Post by: jve on October 10, 2009, 12:02:29 PM
then you are writing to "coils" in the PLC, you need to write to a "Holding register", or user memory.  Then do a "Bit-of-word" operation on that register to grab the Tool requested, from there you can do compare statements that then activate your sensor for your Binary input patteren your looking for.

scott
ok scott finally i did my tool changer and it seems it is working well i only have one problem by now when the tool finish it has to activate input 4 of mach 3 i am receiving a bit on the discrete but the input 4 is not activated i have enable input 4 on port 0 pin 1 but not sure if i done it right
do you have some kind of example how i can do the last operation m6 drop out
many thanks in advance
jekran
Title: Re: 16 atc via modbus
Post by: poppabear on October 10, 2009, 07:47:42 PM
you need to use Brains to bring in/ out, your modbus from Serial Plugin modbus.

scott
Title: Re: 16 atc via modbus
Post by: jve on October 22, 2009, 02:08:07 AM
ok scott i made the brain and when i have a toolchange the input 4 led is off and when the toolchange is ready the input 4 led it is on but i dont know y the m6 it does not drop out  what do i have wrong ?
thanks in advance
jekran
Title: Re: 16 atc via modbus
Post by: jve on October 22, 2009, 09:59:51 AM
 this is my vb may be i have some thing wrong on this

Sub Main()
z= GetUserDro(1202)
code"G53 G0z"&z
While IsMoving()
wend
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 16 'Max number of tools for the changer

While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Or NewTool = 0 Then
Exit Sub
End If

If OldTool <> NewTool Then
SetUserDRO(2000, NewTool)
End If

SystemWaitFor (INPUT4) 'when the PLC is done, it can turn on input4 so the M6 will drop out.

SetOEMDRO(824,NewTool)

While IsMoving
Wend

End Sub
Main   

Title: Re: 16 atc via modbus
Post by: jve on October 22, 2009, 12:05:38 PM
i found the mistake on the vb but how i did it when i load a g code with some tool change the system does not wait for the toolchange finish the g code will run and does not wait for the tool change first can some one tell me what i have wrong iv been working on this for two weeks now and i am really tyerd now
this is the last vb

Sub Main()
z= GetUserDro(1202)
code"G53 G0z"&z
While IsMoving()
wend
NewTool = GetSelectedTool()
OldTool = GetCurrentTool()
MaxToolNum = 16 'Max number of tools for the changer

While NewTool > MaxToolNum
NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

If NewTool = OldTool Or NewTool = 0 Then
Exit Sub
End If

If OldTool <> NewTool Then
SetUserDRO(2000, NewTool)
End If

'SystemWaitFor (21) 'when the PLC is done, it can turn on input4 so the M6 will drop out.

SetOEMDRO(824,NewTool)

While IsMoving
Wend

End Sub
Main  
Title: Re: 16 atc via modbus
Post by: poppabear on October 22, 2009, 09:44:37 PM
Use

   While Not(IsActive(INPUT4))
wend

scott
Title: Re: 16 atc via modbus
Post by: jve on October 23, 2009, 02:10:33 AM
i try that but the program still does not stop when i have a toolchange m6
do i need to put some where code "m0"
so the program stop and wait for toolchange to be ready
regards
jekran
Title: Re: 16 atc via modbus
Post by: Peter Homann on October 23, 2009, 02:19:15 AM
Hi,

If you haven't already, go into the config menu Config->General Config and change the Toolchnge mode  to'Auto Tool Changer'

Cheers,

Peter.

Title: Re: 16 atc via modbus
Post by: jve on October 23, 2009, 02:21:38 AM
yes it is allready in auto toolchange
Title: Re: 16 atc via modbus
Post by: jve on December 21, 2009, 02:08:49 AM
i made the tool changer but i still have an other problem which is when i reboot mach 3 the tool changer go to position 1 , i dont know why this is happins but the current tool still read the old tool number then when i make an other tool change it works fine  i made also a dro which i can see the oem dro 2000 and as i reboot first it is 0 after i press reset it go to 1 and toolchange go to position 1
can some one help