Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: CJEls on May 08, 2008, 03:33:35 AM

Title: Running macro and testing them
Post by: CJEls on May 08, 2008, 03:33:35 AM
Hi All

I am running a m6 macro but it is not working or I can not see it working. I am not a vb man And know noting about programing in vb. Can you see the Macro running while mach is busy.

Thanks

CJ Els
Title: Re: Running macro and testing them
Post by: jimpinder on May 08, 2008, 05:16:11 AM
The machine will TOTALLY skip M6 until you configure it  - see Config/General Config - top left hand corner.
Ignore Tool change should be ticked. If you tick "Stop spindle - Wait for cycle start" the machine will do that.
 
The "Auto Tool Change" reads the M6 script
The M6 macro is empty - becasue for an M6 everybody wants to do something different.

I have a quick change tool holder - so my machine moves to a safe location where I can change the tool, I change it, and the machine moves back - so you will have to write your own script for it. Have alook at the tutorials under "Scripting"

Title: Re: Running macro and testing them
Post by: CJEls on May 08, 2008, 02:48:29 PM
hi jmpinder

The auto tool change is ticked. The macro is one that is working from Graham. I can not tick the ignore tool ghange the it will not do a tool change. If I call a tool it does change the tool number in the tool dro.The machine whenrunning it will produce abatch of part all withim 2 microns of the othe , it will save me some time if the tool changer is automatic and the I can carry on with work on my mill.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 08, 2008, 03:14:00 PM
Is this a Lathe? if so how are you calling the tool?
 How do you have your toolchanger connected, ie is it through parallel port pins, ModBUS or some other way.
 Dont know what the macro is like so I cant say what you are likely to see happening.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 09, 2008, 03:46:48 AM
Hi Hood

The machine is  aEmco Compact P6 Lathe. The macro was written By Graham and I believe he has the same machine running with this Macro.Please Have a look at the Macro.The program steps into line one and it will go to if nexttool<ornexttool>'valid and then it will jump to the end  subline. I do not Know if I use the same Screen set as graham and i only have one tool dro this might be a problem because it can not compare the new tool to the old tool. Any help
Thanks
CJ
Title: Re: Running macro and testing them
Post by: Hood on May 09, 2008, 04:36:12 AM
The Tool DRO is Old Tool and the new Tool is whatever tool yoiu ask for in the code or MDI, you dont need a DRO for that.
 Do you have the turret set up to the triggers that are in the VB?
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 09, 2008, 04:47:59 PM
Hi hood

My feedback comes in on pin 11,12,13,15.How do you setup the triggers so vb will know.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 09, 2008, 04:56:21 PM
My VB is not great but from what I see the toolchange macro is looking for OEM triggers so you need to set them up in Ports and Pins, Inputs.
        if IsActive(OEMTRIG1) then sensors=sensors+1
        if IsActive(OEMTRIG2) then sensors=sensors+2
        if IsActive(OEMTRIG3) then sensors=sensors+4
        if IsActive(OEMTRIG4) then sensors=sensors+8


Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 09, 2008, 05:02:15 PM
hi

The oem triggers are setup in the ports and pin pages.The only ting is must it be active high or low.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 09, 2008, 05:07:12 PM
I would imagine it will depend on whether the sensors are normally open or closed.
Hood
Title: Re: Running macro and testing them
Post by: Hood on May 09, 2008, 05:09:31 PM
Just another thought, you do have the macro in the correct folder dont you? example if you have a custom turn profile there will be a folder in the main macro folder with the name of that profile, thats where you want the M6Start.m1s
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 09, 2008, 05:18:27 PM
Hood

Thank you for the help.what worry`s me is that i do not get any output on output 4. I am using 2 paralel card`s and u know they are both woring because i had my limit swithes connected to them to test the cards. when I do a tool change nothing happens to the output but the tool change dro does go to the new tool.I am using port 2 pin 2 and i know it is working because i tested it with the coolant pump on off. Any other suggestions.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 09, 2008, 05:32:42 PM
If you open Mach and then go to the Operator menu and choose VB editor. In the editor type in
ActivateSignal(OutPut4)
and then press the green arrow, your output should now be active, to turn it off again change the above to
DeActivateSignal(OutPut4) and press the green arrow it should turn off again.

Not sure if you saw my last post regarding the loacation of the M6Start.m1s, also is it named as that or do you still have M6StartGraham.m1s? If you do then that could well be the problem.

Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 08:41:02 AM
Hi Hood

I tried to activatesignal(output4) in the vb editor but could not get it to work.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 08:43:08 AM
You definitely have output 4 enabled in ports and pins?
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 08:47:01 AM
Yes

Port  1 pin6
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 08:49:39 AM
Can you please attach your xml and I will see if I can find a problem.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 09:05:19 AM
Okay here we go but i have to change te name bcause the message i get is that the same file has been up loaded.

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 09:33:09 AM
OK your problem may well be that you have both your Z axis and Output 4 set to the same pin (port 1 pin 6)
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 09:40:50 AM
Hood your a genius
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 09:43:08 AM
Not at all, just been there, done that, seen the movie :D
So is your macro working now or are there still problems?
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 09:45:23 AM
I now tried to run the tool change and it is still not running
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 09:55:38 AM
Just another thought, how are you calling the toolchange? are you using the MDI line, if so what do you type?
Hood
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 10:36:27 AM
OK, rename your M6Start.m1s macro to OldM6Start.m1s and then put the following macro in your macro folder for your profile and rename to M6Start.m1s and see if it works.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 11:04:28 AM
Hood now output  4 comes on but it does not stop rotating the turret
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 11:07:57 AM
OK, will have a look later on but at least OutPut 4 is now confirmed to work. Obviously your inputs are not getting seen by the macro so will have a better look to see what its expecting. In the meantime what are your inputs meant to be? are they low or high when not on tool and can you activate them manually to check that they are being seen within Mach (OEM Trigger LEDs on Diags page)

Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 11:12:21 AM
hood I see that you have taken one line and switched it Off I presume that the probleme is there."If oldturretpos<>nexttool then"
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 11:14:13 AM
Hood where do I see the oemtrigger leds
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 11:19:42 AM
Hood if I switch the oem trigger inputs off and i switch the input 1 to4 on I can see my inputs from the turret, it will only change as it gets to the next tool.They are set at active low but i have played with it setting it active high.

Cj
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 02:00:24 PM
Cj
 as I said I am not the best at VB so maybe I am reading things wrong but this is how I think your turret must work;
 Toolchange is asked for so output 4 is turned on, this rotates the turret until it sees the switches for Tool you have asked for, once they are seen OutPut 4 is switched off and toolchange is complete.
 Is this how it works? Are there any unclamping/clamping mechanisms or brakes? Is the turret meant to move a certain distance after the inputs are seen?
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 02:26:12 PM
Hood  the turret reverses to lock.You can hear the turret going past the locking pointand then it must reverse. The OEM triggers is working I tested it in a brisn brogram.
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 02:35:27 PM
Hood the previous reply should have been brain.I tested it with a brain program and with that it is working (the OEM TRIg).
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 02:43:19 PM
Ok if it reverses I dont see that in the macro, will look again though.
What kind of motor is on the turret? What does OutPut4 actually switch on and off?

Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 02:50:16 PM
Hood output4 drives a relay to turn the turret.When this relay falls away another relay comes in at a lower voltage and reverses the turret. This is hard wired.
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 02:52:46 PM
I have disconnected the revers relay just to see if the relay was the problem.
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 02:52:57 PM
OK that explains why its not in the macro, so I am presuming there must be some sort of stop pin or ratchet that is also released when output 4 is active and dropped when its not?
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 02:56:08 PM
It is a ratched type turret.When it reverses it locks the turret.
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 02:59:16 PM
OK, thats good, I have an understanding of how it works now.
I am trying out a few things in the macro, will post back if I find anything, wish Graham would jump in with the answer ;)

Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 03:01:23 PM
Hood I even tried to Use iunput 1 to4 in the place o OEMtrigger1 to4 with the same result no output.
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 03:28:13 PM
You would have to set the macro to look for the Inputs rather than OEM Triggers if you are going to do that.
 I am going to try something else but just cant get why its not working, I can get the output operating but the triggers are not stopping it, wish I was more knowledgeable in VB :(
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 04:28:18 PM
Hood can it be because my inpus is not in seqence.
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 04:31:49 PM
When Graham emailed me the macro my inputs were wired differentto what the macro was He uses pin 10,11,12,13 I use 13,15,11,12.
Title: Re: Running macro and testing them
Post by: CJEls on May 10, 2008, 04:35:27 PM
If I use the inputs like his macro my feedback is defferent to his in other words my hardwirring is different to his.That is why I use those inputs.
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 04:41:26 PM
Pin numbers wont make a difference as long as the macro is looking at the same OEM Triggers.
 I am messing with some VB and so far it looks promising but I will do the rest before I post it for you to try, might take me a while but you never know, I am getting better :D

Hood
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 06:10:46 PM
Cj
 try this, usual precautions apply as I am an idiot so things may go wrong ;)

Hood
Title: Re: Running macro and testing them
Post by: Hood on May 10, 2008, 06:14:05 PM
Oh meant to say I have the macro set for Inputs rather than Triggers as I could see the LEDs on the standard lathe screen. You will need to set it up as inputs, either that or let me know and I will change the macro to look at the OEM Triggers if you wish.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 11, 2008, 02:21:21 AM
Hood this macro is working fine . Thank you for it. I will now be playing with my machine.Enjoy your day

CJ
Title: Re: Running macro and testing them
Post by: Hood on May 11, 2008, 04:30:25 AM
Glad to hear that CJ.
 I had a look at the macro late last night and noticed I had it set to give an error message if the tool called for was greater than 12, you might want to change that to 8. The reason I had 12 there is I wrote one for Panaceabeachbum a while back and I copied the first few lines from his to save me typing them out, forgot however to change it from 12 to 8 :(
 Grahams macro is much more elegant in the way it does things and looking at it I just cant see why it doesnt work, hopefully Graham will see this and chime in.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 11, 2008, 07:17:42 AM
Hood where can I get some info on vb programing. I think i saw someting in the mach  site.
Title: Re: Running macro and testing them
Post by: Hood on May 11, 2008, 07:28:56 AM
I dont really know, there are a few things posted in the wikis and I think I once saw something on the downloads page but I have never been able to make anything of them, just trial and error for me, thats why it takes me so long to do things :D
Hood
Title: Re: Running macro and testing them
Post by: Hood on May 11, 2008, 07:33:15 AM
The thing about VB is you could ask 100 guys to write a macro  to do a certain thing and you would get 100 different macros, some would be more elegant and some would be long winded but all would work, kind of like the difference between mine and Grahams, Grahams is the elegant one just in case you never noticed :D.
 The way I have picked things up is by looking at the VB used in the wizards etc, you can open a wizard and choose edit VB Button from the user menu and clcik on one of the flashing buttons to get the VB within it. Takes a while to see whats going on but eventually you will start to see things.
Hood
Title: Re: Running macro and testing them
Post by: Hood on May 11, 2008, 07:39:45 AM
Oh I also have a book called VB in a Nutshell, at first it was no use whatsoever as I think it expects you to know VB and is really just a reference manual. When I was doing the toolchange routine for my lathe I was trying to get the PLC to keep indexing the turret until  the correct inputs were seen in Mach, thats when I found the Do Loop statement that I used in mine, Panaceabeachbums and yours.
Hood
Title: Re: Running macro and testing them
Post by: CJEls on May 12, 2008, 01:48:44 AM
Hood I think you must know the do and do not`s. Like you said you have to have a book to look at what code  you can use.
Title: Re: Running macro and testing them
Post by: CJEls on May 12, 2008, 02:06:54 AM
Hood I think A guy Like me does not have a clue to what Mach Can and Can not do.Like the OEMTriggers I do not have the Know how to Understand the Functions it does in Mach.The only way I think Is to play With Mach.Now that the Turret is working I have to Set up a hand wheel System for the Machine But because I have used most of the inputs for Lpt 1 and 2 I will have to use  serial Modbus. The reason I want to use that is on the Video`s they show you how to setup A pot for spindle overide and that Can also be used for feedrate overide.I`ll be using the forum a lot as I have two Milling Machines that I want to convert to mach3. Both of the Machines is Old and the controls shot And all of this just so I can Machine Spares for my Other Hobby .I am more a mechanical man Because my Day time Job is to repair Nc machines.To All the Guy`s reading this forum I you Have a problem Some one that Knows what they doing will Help you If they can and with out payment Thanks to Hood And Graham.

CJ