Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: vmax549 on March 18, 2008, 07:51:10 PM

Title: Tool changer routine with hot swap
Post by: vmax549 on March 18, 2008, 07:51:10 PM
Has anyone done a tool changer routine that has a hot swap of the tool in the carasel. For example when the tool change occurs the requested tool is brought up and the swap is made then the old tool goes back to the hole the new tool came out of and the tool number is reset to refect the acutal tool loaded back into that slot.

Looking for an example of the hotswap part to model my carasel code after.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: Graham Waterworth on March 19, 2008, 04:57:38 PM
I think Scott (Poppabear) has one that works that way.

Graham.
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 21, 2008, 09:03:34 AM
Hi Terry - I'm intrigued - why would you want to do this? - not saying there isn't good reason - just can't think of what it is! Also - how can a tool be put into the slot that the current tool came out of - what would put it there?

Cheers

Ian
Title: Re: Tool changer routine with hot swap
Post by: poppabear on March 21, 2008, 10:43:02 AM
Terry,

   Yes  I have one like this, it uses a swap arm, It is mainly run by a PLC that Mach3 controls, the tool changes at the swap is about 2-3 seconds, then Mach goes back to machining while the Carrasel rotates to the next tool needed.

The way I did it was named my pots as variables in an array, that would update with the value of the new tool at swap time.

I cannot release my code since I use it for my commercial machines, but it can be done.

scott
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 21, 2008, 11:18:19 AM
****I guess I did not asnwer your question(;-) THe tool changer has an arm that has a rotary arm attatched at the end, THe arm at the end has a center pivot and an extention on opposite sides that holds the tools. At tool change the changer rotates to the new tool pocket and the arm picks it up. the other side is empty to receive the old tool. At tool change the arm swings over to the spindle and receives the old tool , then the arm rotates and places the new tool into postion. THen the arm moves back to the carasel and put the old tool back into the pocket where the new tool came from.*******

Stirling the reason for hot swapping is to allow the tool chager to work at max efficentcy. Instead of having to rotate back to each tool location every time to return the tool to its original location, you simple put the old tool back where the new tool came from. THe mechanics are simple. And the code for the tool change I can figure out.

BUT I need to figure out the programimg side of MACH "VB" how to have mach do the swap in the tool table to reflect that change so it stays correct and current after a hot swap. Not being a programer I get lost in LOGIC (;-) and require help from time to time creating an original piece. Once I see it I can modify a piece of code to what I need but the creative logic goes right over my head.


*** Bear so you store the tool array at the plc level and do the swapping there?? Can I assume that you download the tool pocket info to the plc before the job starts?? In my situation each job may require a total reloading of the carasel for the job.

what I want to try to do  is to see if MACH Brains can do the total job without a PLC. AS a test.

Just fishing for info NOT secrets(;-)  TP

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 21, 2008, 01:04:44 PM
OK Terry - thanks for the explanation. Seems to me what you need to code is an indirection table. In VB this could be coded as an array. The array index could represent the tool and the number in each array cell represents the carousel slot where that tool is. You start with the same number in the cell as its index. So array[1]=1 etc. which means tool 1 is in slot 1 etc.

As you move along and you want to change the tool in a slot you just change its slot number. So for example you may decide array[1]=5 which means tool 1 is now in slot 5 etc etc.

The rest of your code stays the same its just you have have the extra code to update and index via your "tool-slot indirection table".

Any good?

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 21, 2008, 03:30:27 PM
Hi IAN, you said WHAT????   NO I think I get the idea, let me think about this. I will have to draw out a flow table of the operations and see if I can follow it there.

Also the mach tool table is loaded with all 150 tools available. Itwould need to load the carousel from this table assgning a pocket for each tool required for the job. The carousel will hold 30 tools, not all pockets are needed for each job

SO at load time for the program I need to load up the carousel pockets with the tools  assigning each pocket# a tool #. then the redirectontable takes over and controls which tool is in what pocket and keeps tabs of the swapouts as it goes.  ??

SO what is also needed is code to load the indirection table at the beginning ?

Thanks (;-) TP
Title: Re: Tool changer routine with hot swap
Post by: Ron Ginger on March 21, 2008, 07:39:41 PM
Your big problem is going to be keeping the values between changes. Remember, every time VB runs a button or a macro it starts a NEW VB process. So anything you stored in an array the last time a tool changed is lost, VB starts a new array.

You could define a series of Mach DROs, one for each tool pocket. Then any time your code runs it looks at each DRO to find the one holding the tool number it wants, then it sets that DRO to the number of the tool its about to put in that pocket.

DROs and LEDs are maintained by mach for each screenset. The macros will see the DROs that belong to the current screen when they run. Watch out for weird things happening if you should run one of those macros from a wizard screen! Also an issue when a macropump is running, it shares its DROs and KEDs with the current screen, so running a wizard or screenset that is not coordinated with the macropump is also risky.

I have been beating on Brian to fix this so there would be one Vb context started up every time a screen loads, then every button call would simply be a subroutine call in that context. He agrees its a worthy change, but it looks like a major change. I will keep pressing him.

ron ginger
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 21, 2008, 10:12:59 PM
I guess I am going to have to drag out the VB for dummies book again(;-)

So I gues I can't just assign 30 variables as tool slot# and populate the vars with tool#s then as each tool cycle takes place update the vars accordinly.????


Or perhaps set up a page inside of mach with 30 tool slots and dros then populate the dros and have them persistant dros to hold the info they update the dros at tool change??? Just have to watch out for duplicate DROs. (;-) Right RON?

Told ya I was a VB dummy(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: poppabear on March 21, 2008, 10:27:07 PM
Yes, I use an Array in the M6 this loads values into registers in the PLC which keeps the values all the time, the M6 loads them the last values from the PLC and any changed values are sent back out to the plc, the plc does all the work.

scott
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 22, 2008, 07:01:57 AM
Hmmm yes - in my enthusiasm to discuss the logic of the indirection table I completely forgot the VB context issue - darn it!
OK - so the principle remains but the issue of persisting the table accross VB contexts is the next hurdle. As has been said you could use DROs or external means as per poppabears. One other method would be to use gcode variables instead of or in association with a VB array. Probably easier just to use the vars without any array.

So I gues I can't just assign 30 variables as tool slot# and populate the vars with tool#s then as each tool cycle takes place update the vars accordinly.????

Yes, that's the idea... but the other way round. The 30 vars would be the 30 tools and the value in the var would be the slot. Remember you're going to come into your routine with a tool number not a slot number. You'd use the tool number to focus on one of the 30 vars and then get the value in the var to tell you which slot to go for to get that tool. Then as you go you just change the values in the vars. So to start for example #1001=1 means tool 1 (1001-1000) is in slot 1. At some time later maybe #1001=5 so tool 1 (1001-1000) is in slot 5, if you get my drift?  :)
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 23, 2008, 07:21:48 AM
Hi Terry - had a bit of a play with this this morning - please see attached zip.
Save your existing M6start.m1s somewhere or rename it and replace it with the attached version. Also drop M1000.m1s into your macro folder. Then load the .tap file into Mach.

M1000.m1s sets up a virtual carousel with 8 tools.
M6Start.m1s demonstrates a possible hotswap mechanism.
hotswap.tap tests it.

Cheers

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 23, 2008, 01:11:59 PM
Ian I will try your ruotine later today.   Two things I have thought of Mach must store the T# that is in the gcode in a variable to have it ready to go. We need to access that VAR to have the toolchanger move to that slot in advance of the toolchange. THat way when mach sees the T# and stores the var the carousel can rotate into position and when the M6 is called it will already be at location. Fanuc style.

Also we need to have an input table/page? to fill in as to what tools from the tool table are to populate what slots in the initial loading of the carousel. ALso a veiw slot load window is need to be able to pull up the current slot/tool3 to be able to verify the tool loading is correct to the slots.

IE:

code
code
code
T6
code
code
code
M6
T7
code
code
code
code
M6
T8
etc,etc

THanks for the help(;-) If we can get this model working it will provide a template for others with mills and toolchangers to model by. It will help out a great deal in making MACH a viable option for the small machine shop to UPDATE their OLD iron to a moderm controller economically.

NOW I know some people say it is best left up to PLC to do the work, BUT the way I see it MACH is really NOT doing anything special at tool change time(;-)Axis's are normally idle why not put it to work taking care of the tool changer as well(;-) We have a TON of processor why not use it?????

(;-) TP

Title: Re: Tool changer routine with hot swap
Post by: stirling on March 23, 2008, 03:03:20 PM
what's with the WE Kimasabi? - it's your baby  ;D

Two things I have thought of Mach must store the T# that is in the gcode in a variable to have it ready to go. We need to access that VAR to have the toolchanger move to that slot in advance of the toolchange. THat way when mach sees the T# and stores the var the carousel can rotate into position and when the M6 is called it will already be at location. Fanuc style.

Well yes and no. If you want this then you'd have to pre-process the g-code (messy) or somehow dig into Mach's lookahead mechanism (I wish you luck). Its a reasonable thought sure, but on the other hand, when Mach hits a T# the axis have to move to the toolchange position anyway. Couldn't the carousel just spin at the same time whilst the axis are getting there?
(I just took a quick look to see if the fact that Mach can pre-process macros as it builds the toolpath could be used - but it seems M6 is a special case and is not pre-run at this time - unlike user macros for example)

NOW I know some people say it is best left up to PLC to do the work, BUT the way I see it MACH is really NOT doing anything special at tool change time(;-)Axis's are normally idle why not put it to work taking care of the tool changer as well(;-) We have a TON of processor why not use it?????

Seems reasonable to me.

BTW in your example code you've got an M6 followed on the next line by a T#. Is that just a typo? I always thought the syntax was T# before the M6 (and usually on the same line) yes/no?

Cheers

Ian

A quick edit:

NOW I know some people say it is best left up to PLC to do the work, BUT the way I see it MACH is really NOT doing anything special at tool change time(;-)Axis's are normally idle why not put it to work taking care of the tool changer as well(;-) We have a TON of processor why not use it?????

Actually I'm not so sure... I'm thinking maybe you have to have independant control of the arm and carousel... thinks...
Title: Re: Tool changer routine with hot swap
Post by: poppabear on March 23, 2008, 03:38:09 PM
Yes,  The reason I went with a PLC is so after mach changes to the New tool, Mach continues on cutting, mean while the PLC will rotate the Carracell to the next New tool  position for the next tool swap. The PLC operates independantly of Machs M6 routine.  If you try to tie Mach into doing all the Tool change the you lose ALL the advantage of having a Read-A-Head Swap Arm tool changer since it will change the tool, then rotate to next tool then drop out, mean while your wasting cut time going through the double cycle that you didnt want to lose time on in the first place.

Since Mach doesnt have "Read A Head" for Next Tool, you have to do a work around. In your CAM you have to post: Next Tool then, Current tool and store the next tool for the caracell rotation. Further at the end of the run, you might have to tie in some intellegence in your Macropump to watch for the Last Tool change and do a repeat so your code will drop out and not get your caracell out of sync with your PLC.

Scott
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 23, 2008, 05:55:42 PM
HI IAN, I am not the lone ranger when it comes to programing(;-). But I can stick to I if needed.(;-)

THe reason the gcode example is that way ?, that is the faunuc style . You can put in the T6 at anytime ahead of the m6 and it is stored in a VAR i believe. That way the tool changer can start early and have the tool sitting in the correct slot at tool time then when the M6 is called the tool is ready for a swap. As soon as the tool swap takes place then the next t# allows the tool changer to bring the next tool required into position.

I will dive into that part and see HOW Mach handles the T# call. We do have a VAR monitor now, just have to figure out the super secret code to test.


Hi Bear, Mach has to store that tool#info somewhere, just need to figure out where. OR it can only process it along with the m6 call????  I'll Test to see IF it can conform to the fanuc standard.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: poppabear on March 23, 2008, 06:42:53 PM
NOTE:

I can save you some time, been there done that.........
You currently have two varibles: GetCurrentTool() and GetSelectedTool()
When you come to a M6, mach stores the current tool in current tool, and the new tool in selected tool.
Unfortunatly, (at current this current mach time), when you initially Parse the Gcode to build you Tool path there is now way to store a list and order of use of needed tools.
(Yes, I have asked Brian for a way, when I started mine).
For me, I put my current tool and next tool both before the M6, that way I can stay ahead of the game.

scott
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 23, 2008, 06:45:23 PM
Hi Ian, tests reveal that MACH CAN follow the fanuc T#/M6  convention, so it MUST store that T# info away in a buffer or VAR somewhere. NOW where?????

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 23, 2008, 07:11:36 PM
Bear I am confused. WHat does that mean?

GetCurrentTool()    Is this the current tool mach is running?

GetSelectedTool()  Is this the "next" tool in line to be used at the next M6  ??

 If so this is the Var I need to initiate the carousel rotation to the next position??

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 23, 2008, 08:31:45 PM
Hi IAN, Test confirmed that Mach does store the next tool# in line to be used and it is retreived with Getselectedtool().

AND it does work with your example code(;-)  SWEET!!!!!!    COuld you modify your example to indicate what tool is due up next.  Like you indicate which tool is IN THE SPIDLE????

So "WE" CAN use the fanuc convention for tool changes. (;-)

(;-) TP

Title: Re: Tool changer routine with hot swap
Post by: stirling on March 24, 2008, 06:52:18 AM
Sorry Terry but I think your headed down a cul-de-sac here. Bear has confirmed in his post #14 where my thoughts were going with my last edit.

Mach simply CAN'T control the toolchanger whilst the axis are moving. It has to stop the axis, operate the toolchanger, then resume axis movement.

So...

IF you use Mach to control the toolchanger then...
1) It CAN'T be done whilst the axis are moving 2) lookahead is irrelevant. 3) swapping tool/slot is useful.

IF you use external hardware to control the toolchanger then...
1) It CAN be done whilst the axis are moving 2) lookahead is useful. 3) swapping tool/slot is irrelevant.

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 24, 2008, 09:03:12 AM
OK so what yous guys are saying is that MACh can not do anything while the axis are moving??? THe macropumps don't run and the brains don't work??? I think I am confused again. The actual tool changing takes place while the machine is stopped anyway. Only the rotattion of the carousel is taking place during the machine movement. It trip a relay and waits until it get a switch combo and opens relay.

To me that is like sayng once the machine starts to move there can be no further interaction with mach until it is done????

But I do appreciate your input and ideas.. (;-)

Thanks (;-) TP

Title: Re: Tool changer routine with hot swap
Post by: stirling on March 24, 2008, 09:15:45 AM
OK so what yous guys are saying is that MACh can not do anything while the axis are moving.THe macropumps don't run and the brains don't work??????
No I'm not saying that
I think I am confused again. The actual tool changing takes place while the machine is stopped anyway.
This is true - but that's not my point.
Only the rotattion of the carousel is taking place during the machine movement.
But this is my point - what is rotating the carousel?
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 24, 2008, 10:15:00 AM
Hi Ian, When Mach has to rotate the carousel. It trips a relay to start a motor. On the carousel is an absolute type encoder that returns a switch combination to identify each slot on the wheel. So when the slot ID matches the "next tool" slot number then mach signals the relay to open and stop the motor. There is a smart relay that controls the motor and detent operations that lock the wheel in perfect position.

SO that makes MACH's part trivial, signal a relay and monitor the encoder signal until the correct position then signal the relay again.

I honestly don't see the problem but I have been wrong before?????? (;-)

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 24, 2008, 12:49:37 PM
Hi Terry - ok I'll bow to you on this because I've not much experience in the electromechanical (I thought that all went out with 1970s telephone exchanges  ;D) - But if it's any help here's a couple of issues that spring to mind.

When Mach hits a T# (in advance of an M6 - fanuc style) it has to output a signal to trip the relay and hence motor. Can Mach do this?

Each time the carousel outputs its encoded position it has to interrupt Mach to let it know there's data waiting and then it has to present this data to Mach for comparison. Can Mach do this?

BTW What about the arm?

Cheers

Ian

EDIT: With regard to the encoder outputing its position to Mach I've just read up on triggers. Instead of using an absolute type encoder, one way would be that the carousel just sends a pulse each time its at a slot, Mach could keep track of which slot. This negates the need for Mach to read a number. Just a thought. :)
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 24, 2008, 02:19:28 PM

When Mach hits a T# (in advance of an M6 - fanuc style) it has to output a signal to trip the relay and hence motor. Can Mach do this?

******** Yes

Each time the carousel outputs its encoded position it has to interrupt Mach to let it know there's data waiting and then it has to present this data to Mach for comparison. Can Mach do this?

******** yes

BTW What about the arm?


****** It can be controlled from relays as well, depends on design complexity.

Cheers

Ian

EDIT: With regard to the encoder outputing its position to Mach I've just read up on triggers. Instead of using an absolute type encoder, one way would be that the carousel just sends a pulse each time its at a slot, Mach could keep track of which slot. This negates the need for Mach to read a number. Just a thought. :)
Quote

I have thought of that, but if MACH ever hiccups(;-) Like in a probing cycle (;-) you could loose reference and a tool changer crash is not pretty. THe Unique ID system allows mach to know where it is at all times Hardcoded so to speak. You can monitor 30 positions with 5 digital signals as on/off combinations.   Seeing how mach polls the macropump/brains every cycle I don't see this as a bottleneck??????

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 24, 2008, 03:36:48 PM
Hi Terry - sounds like you've got it all sorted - sounds good to me - sorry it took me a while to catch on.

go for it.

Cheers

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 24, 2008, 03:53:46 PM
Hi IAN, the elec/mech side is fairly easy for me. THe programing side puts me like a duck in the desert, stranded on dry land(;-)

THanks For your help, (;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 24, 2008, 11:54:11 PM
Phase 1 create the screen to load the carousel and initialize the data to the slot postions
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 25, 2008, 06:37:20 AM
Hi Terry - I'll help where I can if you need it.


When Mach hits a T# (in advance of an M6 - fanuc style) it has to output a signal to trip the relay and hence motor. Can Mach do this?

******** Yes

how?
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 25, 2008, 09:34:19 AM
Hi IAN, WHen Mac see a t# it stores it in a var or buffer. At the M6 call it processes that var. After the M6 has finished mach then loads up the NEXT t# into the var/buffer. SO that var is available to use from a brain/pump to active a MACH ouput pin that can control a relay. the brain/pump then can watch for the proper ID signal combination from the abs encoder to let mach know when to deactive or resignal for a stop.

You will notice that the example page has the SLOT# as the primary id and the TOOL# as the variable. THis will be the easiest for the operator to track. He first has to load the carousel and inoput what tool went into what slot. Also at any time he must be able to verify the tool# and slot. SO I thought a PAGE with dros would work well here. Mach can keep the dros as persistant dros and we never loose the info from job to job or shut down to startup.(I think)(;-)

The GoToSlot# allows the operator to rotate to a slot to unload/load a tool from the carousel.

Would I need a table to load up from the dros so VB could work its magic and track the hotswapping and keep the dros updated as well??

I have a startup macro(initialise) and a M6start macro to work with. THe M6end macro is NOT used in an auto tool chager mode.

Can your example of hot swap work in this instance?? I know you had the tool# as prim ID and the slot as the variable(;-)

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 25, 2008, 11:30:14 AM
Hi IAN, WHen Mac see a t# it stores it in a var or buffer. At the M6 call it processes that var.
Yep - agreed - no problem so far.

After the M6 has finished mach then loads up the NEXT t# into the var/buffer.
Well - not quite I think - from what I've seen, Mach doesn't store the T# in the var until it subsequently processes the line the T# is on. Let's be exact here - its the only (good) way to spec software. And here's the first issue. You want to be able to read the next T# as soon as you've loaded the previous tool into the spindle - that's why you need a lookahead mechanism OR you need to pre-process the gcode to move the next T# to immediately after the M6 so that your macro pump routine can get started on it asap.

SO that var is available to use from a brain/pump to active a MACH ouput pin that can control a relay.
OK - this is what I was looking for in my last post - I thought Art may have sneeked a soft interrupt in there somewhere but polling is ok - I can go for that.

the brain/pump then can watch for the proper ID signal combination from the abs encoder to let mach know when to deactive or resignal for a stop.
OK

You will notice that the example page has the SLOT# as the primary id and the TOOL# as the variable. THis will be the easiest for the operator to track. He first has to load the carousel and inoput what tool went into what slot. Also at any time he must be able to verify the tool# and slot. SO I thought a PAGE with dros would work well here.
Mach can keep the dros as persistant dros and we never loose the info from job to job or shut down to startup.(I think)(;-)
The GoToSlot# allows the operator to rotate to a slot to unload/load a tool from the carousel.
OK - personally I wouldn't worry about all this at the moment - I'd get a basic simple harness working and worry about this later - but hey - its your call. FWIW I personally think the practice of using DROs as variables is messy but whatever - I know a lot of people do it.

Would I need a table to load up from the dros so VB could work its magic and track the hotswapping and keep the dros updated as well??
Well not really - if you can access your DROs from your code to populate a table (which of course you can) then you can do whatever directly on them. Different types of data structures are used because of the particular advantages they bring over each other in manipulating their data. VB has pretty p*ss poor data structures anyway so I wouldn't worry about it.
Now - hotswapping - if you can rotate your carousel whilst the axis are moving - the whole point here - why do you need hotswapping?

Can your example of hot swap work in this instance?? I know you had the tool# as prim ID and the slot as the variable(;-)
Well it was just that - an example - but it could be changed to do whatever you want - but see above - hotswapping - why do you need it?

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 25, 2008, 11:58:56 AM
Hi Ian basically you don't want the swap arm standing around with a tool loaded waiting on the carasouel to cycle around back to the proper slot while the machine is back at work. During the tool swaps the carosel MAY have to move into position and the tool arm MAY need to swing into position as well and retract when done to get clear of the spindle movements. SOme machines this is NOT a problem by design ,SOME machines it is a problem as you cannot change the hard designed motion of the changer. SO I thought it best to plan on the worst case senario.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 25, 2008, 12:28:02 PM
Hi Terry - OK - not a problem.

Still concerned about my question re lookahead though because that's fundamental to what you're doing.

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 25, 2008, 12:42:43 PM
HI Ian easy enough to test and give you exactly results. I can set up the var as a gcode VAR, Mach has a var monitor now so I can see exactly when it its updated as I step throught the lines of code. I'll let you know shortly(;-)

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 25, 2008, 01:03:01 PM
OK, mach sets the VAR when it processes the T# line. That is why on a faunuc the next tool# normally follows directly after the M6 line.

T1
code
code
code
M6
T2
code
code

Hopefully that allows the brain to monitor the Var and respond when it sees the value change. ?

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 25, 2008, 03:22:09 PM
OK Terry - keep posting  :)
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 25, 2008, 06:50:38 PM
OK I have the screen to take dro entries of the tool# and the tool descriptions will follow the tol# entry .

Also I have it showing the "tool in spindle" correctly and the "next tool up" dro working. 

Title: Re: Tool changer routine with hot swap
Post by: stirling on March 26, 2008, 05:47:59 AM
Hi Terry - If you want to use my hotswap routine logic then you'll need to flip your tool/carousel numbers. Doing it your way you'll have to search for the slot by stepping through each slot in turn looking for the required tool. Doing it my way you go straight to the tool and lookup the slot - simple.
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 26, 2008, 09:22:28 AM
Hi IAN, yes I know your way makes it simple. BUT i keep looking at it from the operator standpoint. The OLD way was to see the slot number as fixed and the tool numbers change. NOW if I can make it look the OLD way and do it the new way ???????


(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 26, 2008, 10:28:57 AM
NOW if I can make it look the OLD way and do it the new way ???????

No problem - you revert to a previously mentioned scheme. You use your screen to load a table or whatever and your code operates on the table rather than on your DROs. In fact this is probably what you should do anyway - its good software engineering practice to keep a separation between the code and the interface.

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 26, 2008, 10:56:44 AM
HI IAN, Same subject but a different project(;-)

 We have a denford mill with a tool changer that is converted to MACH control. Now we have to interface the ATC (toolchanger) to mach. THe atc runs from a serial connection. We have captured all the control codes needed to run the ATC and can make the TC cycle by sending the codes through Hyperterm to the atc.

Question? How do we get VB to send the controls codes over the com port when needed?

Question Can I send a copy of the tool table to a printer port? Say LPT1

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 26, 2008, 11:59:53 AM
Question? How do we get VB to send the controls codes over the com port when needed?
see "sendserial" at http://www.machsupport.com/MachCustomizeWiki/index.php?title=Mach_specific_Subroutines/Functions_grouped_by_purpose or 4.4.10 in the customization guide.

Question Can I send a copy of the tool table to a printer port? Say LPT1
Not sure I understand what you mean.
Title: Re: Tool changer routine with hot swap
Post by: Graham Waterworth on March 26, 2008, 04:12:17 PM
Hi Terry,

something like this will do it :-

dim command as string
dim byte as string
command="B000013E------"
for a=1 to len(command)
  byte=mid(command,a,1)
  putportbyte(Ox378,asc(byte)) ' Ox378 is the address of your serial port
  for b=1 to 1000
  ' this is a delay loop, adjust to get your 9 ms delay
  next
next
end

Graham.
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 26, 2008, 04:48:45 PM
Hi Graham - just so we don't get confused here - I take it you mean parallel port where you've written serial port. :)
Also - out of interest - what's the 9ms delay for?

Ian
Title: Re: Tool changer routine with hot swap
Post by: Graham Waterworth on March 26, 2008, 04:51:29 PM
Sorry Ian, its a reply to VMAX about his Denford ATC, I need to create a new thread, should not have hijacked this one.

Graham.
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 26, 2008, 05:23:33 PM
Hi Graham, I had looked at the port command but being I am a double dummy I chose to NOT try that approach yet.
Thansk FOr the help, I am trying to get Richard up and running(;-)

Hi IAN, THe delay is to comply with the ATC requirement of a 9ms delay between charactors in the command string going to the ATC??? Yea I know weird but that is what it takes to work(;-)

I had tried using the SendSerial  VB command but I have yet to get it to work??? VB likes it but nothing ever shows up at the port(;-)

I THink I have also figured out that you cannot send anything to a printer from the MACH version of VB. I found my old copy of VB for Dummies but most of the stuff doesn't seem to work in" MACH "VB(;-(

Back to the drawing board, (;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 26, 2008, 05:45:35 PM
Graham in the second line VB errors on the word BYTE.
(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: Chaoticone on March 26, 2008, 06:19:25 PM
This is a great topic. Stirling, Vmax, Poppabear, and Graham. It will have to work. I have admired all of your work for a long time.

Brett
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 26, 2008, 07:20:03 PM
Hi Stirling I almost missed your question. AS part of this project I would like to send a copy of the tool table AND a copy of the current slots assignment to a printer from a mach button. BUT it seems that the MACH VB does not support printing to an lpt port,at least not that I can get to work. It errors with,  not a supported object or command.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: Graham Waterworth on March 27, 2008, 05:22:02 AM
was not thinking when I typed it in, Byte is a reserved word in VB, try it like this :-

Dim command As String
Dim oneByte As String
command="B000013E------"
For a=1 To Len(command)
  oneByte=Mid(command,a,1)
  putportbyte(Ox378,Asc(oneByte)) ' Ox378 is the address of your serial port
  For b=1 To 1000
  ' this is a delay loop, adjust to get your 9 ms delay
  Next
Next
End

Graham.
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 27, 2008, 06:05:41 AM
Sorry Ian, its a reply to VMAX about his Denford ATC, I need to create a new thread, should not have hijacked this one.

Graham.

Hi Graham - no problem - I did wonder if I'd missed some posts somewhere  ;D

HI IAN, Same subject but a different project(;-)

 We have a denford mill with a tool changer that is converted to MACH control. Now we have to interface the ATC (toolchanger) to mach. THe atc runs from a serial connection. We have captured all the control codes needed to run the ATC and can make the TC cycle by sending the codes through Hyperterm to the atc.

Question? How do we get VB to send the controls codes over the com port when needed?

Hi Terry - according to this your ATC is on your serial port (COM). To write to that I think you must use "sendserial" not "putportbyte" and set up the baud rate and handshake etc. on the Config page.

I think we all may be getting a little confused because the port address that Graham has given you (Hi again Graham) is the address of the default PARALLEL port. (PS - for 0x378 (C hex style) use &H378 (BASIC hex style))

Question Can I send a copy of the tool table to a printer port? Say LPT1
Your second requirement is indeed for the parallel port (well assuming your printer is on the parallel port). BUT, you can't just write raw data to the parallel port and have it come out on a printer. You either have to figure out all the particular manufacturers formatting/hanshaking codes OR of course more usually, you need to print via their driver which does all that for you. However - I'm not sure whether Mach can tolerate a printer driver to exist along side it's pulse engine - maybe on two separate LPTs it can - I don't know.

Cheers

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 09:14:56 AM
Hi Ian,            THe machine has 3 lpts, 2 for MACH and one for windows(;-)  SO far they have behaved ok but???

Well I gleamed a little more info last night on serial ports and mach. Seems the sendserial only works IF you have NOT set up the event serial control, and it is send only.

If the event control is active it it bidirectional and you use getfifo, sendfifo
The SendSerial command is used only for sending one way traffic.
> It cannot
>> recieve.
>> The GetFifo is used only in 2 way serial communication. This two-
> way mode is
>> selected by
>> config/ports&Pins and selecting "Event driven Serial mode" .
> Then , to send
>> you use
>>
>> SendFiFo( "This is what I want to send')
>> and recieve using GetFiFo()
>>
>> Do not use SendSerial if you want to get a return, only the
> event driven
>> serial is separate threaded
>> and available for realtime back and forth..
>>
>> Thanks,
>> Art

*****  NO wonder I could not get the monitor to run and use sendserial (;-)

Documentation is a wonderfull thing IF you have any(;-)

Hi Graham, I thought that is what you intended but was not sure, thought I would ask first.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 09:35:49 AM
HI Graham, I tried the new code and I now get a complie error on the port address. Yes I know what is in there is  an lpt address(;-)  I used the com1 setting of  03f8.   It errors on the F8 part. I did notice the the 03 portion changes color to magenta????

The timing loop works well, I like that one(;-) it is going into my bag of tricks.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 10:02:28 AM
Heck I cannot get any of the comport commands to show up on the serial monitor.

Sendserial does not work
SendFIFO does not work

Tried it on two computers one was the mill?????? the other my work station.

SO I don't know if the serial monitor can see it when in VB to test????? THe serial monitor DOES work to send test commands to the port that part works.

Beats ME. (;-)

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 27, 2008, 10:08:59 AM
Hi Terry
Hi Ian, THe machine has 3 lpts, 2 for MACH and one for windows(;-) SO far they have behaved ok but???
Cool

Well I gleamed a little more info last night on serial ports and mach. Seems the sendserial only works IF you have NOT set up the event serial control, and it is send only.

If the event control is active it it bidirectional and you use getfifo, sendfifo
The SendSerial command is used only for sending one way traffic.
> It cannot
>> recieve.
>> The GetFifo is used only in 2 way serial communication. This two-
> way mode is
>> selected by
>> config/ports&Pins and selecting "Event driven Serial mode" .
> Then , to send
>> you use
>>
>> SendFiFo( "This is what I want to send')
>> and recieve using GetFiFo()
>>
>> Do not use SendSerial if you want to get a return, only the
> event driven
>> serial is separate threaded
>> and available for realtime back and forth..
>>
>> Thanks,
>> Art

***** NO wonder I could not get the monitor to run and use sendserial (;-)
Cool again

Documentation is a wonderfull thing IF you have any(;-)
LOL - after 20+ years in software engineering I've learned there are two things that are as rare as rocking horse sh*t - code commenting and documentation updating... and no (Brian) I'm not volunteering.

Hi Stirling I almost missed your question. AS part of this project I would like to send a copy of the tool table AND a copy of the current slots assignment to a printer from a mach button. BUT it seems that the MACH VB does not support printing to an lpt port,at least not that I can get to work. It errors with,  not a supported object or command.
How are you trying to do this - i.e. what command/routine is failing?

Ian
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 27, 2008, 10:12:50 AM
Hi Terry - with regard to your last question to Graham - you need to read my earlier reply about the format of hex strings in BASIC. The syntax is &H0378 or whatever address you're using. The &H is instead of Grahams 0x at the front of the string.

A word of caution which I hope isn't too late. You have to be VERY careful which port or address you write to - you can seriously screw up your system - even trash the hard disk if you're not careful.

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 10:17:35 AM
I tried all variants of

Printer.Print " test STRING"  , etc

I can gather the info and send it to a file in notepad!!!!   but not to a printer

I gues that part is NOT supported in MACH VB

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 27, 2008, 11:21:34 AM
Yes, It seems that although the printer object itself is recognised, none of its methods or properties are available (I tried a few) - zippo. Hence your message of "object doesn't support this property or method". I think this is one for Brian perhaps. I'm sure he'll be delighted. ;D
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 11:56:04 AM
YEP that is the funny part of mach I can always get within 1/64" of finishing a mile run in mach but just can;t seem to cross the finishline,  because of mach limitations.

OH well, (;-)  TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 27, 2008, 12:07:40 PM
LOL - you can't go around saying things like that. Last time I said that about someone's software they looked at me like I'd said their daughter had a face like a horse  ;D
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 27, 2008, 03:56:28 PM
Hi Ian,

 ITS not too late like I said THAT would be my last approach. I believe I can figure out a workaround to the charector delay that does not involve using it. (;-)

Would you happen to know of a way to do a DOS command from inside of machVB if so then I can send the file to the printer with the DOS Print command????   

Yep I guess I had better straighten up or Brian might not talk to me anymore(;-(

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 28, 2008, 07:02:57 AM
Hi Terry
Would you happen to know of a way to do a DOS command from inside of machVB if so then I can send the file to the printer with the DOS Print command????

Dim cmd As String
cmd = "print c:\test.txt"
Shell ("cmd.exe /c" & sCommand)

(With thanks to Shuja Ali)

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 09:18:07 AM
Hi IAN,     that worked like a charm(;-)

Here is the code to get the tool table data and print it. ( this is not an original code but borrowed peices and parts patched together to do a job)

All it needs to be added to it to be pefect Is to add the time and date to the top of the file AND arrange the data to be printed so all the collums line up making it easier to read. BUT as it is, it serves the purpose(;-)


***********************

'newer version will poll up To 225 tools And skip Any tool With a description of "empty"

' overwrite file = C:\mach3\ToolInfo.txt

textFilePath = "C:\mach3\ToolInfo.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(textFilePath)


Do Until num=225

num=num+1

N = GetToolDesc(num)
D = GetToolParam(num,1)
L = GetToolParam(num,2)
WD= Gettoolparam(num,3)
WL= Gettoolparam(num,4)

If N <>"Empty" Then

objTextFile.WriteLine("*Tool"& num &"  * "& N &" *Diameter: "& D &" *Length: "& L &" *Wear Diam"&WD &" *WearLength"&WL & Chr(13) & Chr(10))

Else

End If

Loop

objTextFile.Close

Dim sCOMMAND As String
 sCOMMAND="print c:\mach3\toolinfo.txt"
 Shell("c:\winnt2\system32\cmd.exe /c" & sCOMMAND)
 
End   

Thanks Guys for all the help. Hopefully it will serve others as well, We will add this to the MACH TOOL BOX.

(;-) TP

Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 09:27:13 AM
HOWDY HOUNDDAWGS  that new( PRINT TOOL TABLE) button works like a CHARM. Here is what it prints out like:


*Tool1  * .250,EM,2f,RN *Diameter: 0.375 *Length: 1 *Wear Diam0 *WearLength1.1111

*Tool2  * .250,EM,4f,BN *Diameter: 0.05 *Length: 0 *Wear Diam0 *WearLength0

*Tool3  * .250EM,2f,FN *Diameter: 0.5 *Length: 0 *Wear Diam0 *WearLength0

*Tool4  * .500,EM,3f,FN,CB *Diameter: 0.25 *Length: 1 *Wear Diam0 *WearLength0

*Tool5  * Tap,tc,1/4x20 *Diameter: 0.12 *Length: 0 *Wear Diam0 *WearLength0

*Tool6  * BB, set .4883" DIAM *Diameter: 0.375 *Length: 0 *Wear Diam0 *WearLength0

*Tool7  * FM,6",alum *Diameter: 1 *Length: 0 *Wear Diam0 *WearLength0

*Tool8  * Probe,6"a,2mm,BE *Diameter: 1 *Length: 0 *Wear Diam0 *WearLength0

*Tool9  * .500 *Diameter: 1 *Length: 0 *Wear Diam0 *WearLength0

*Tool10  * This is a test *Diameter: 1 *Length: 0 *Wear Diam0 *WearLength0

*Tool99  * Probe *Diameter: 1 *Length: 3 *Wear Diam0 *WearLength0



(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 09:40:36 AM
IAN,  I gleened another piece of info about the sendportbyte call . It does seem to require the port address in HEX?

THat could be really dangerous for me to go roaming aroung inside of somewhere I don't have a clue about(;-)

Also I read that ART was going to address the charactor delay problem with a new version of event driven serial  but I don't see where that ever got finished.(;-)  Alot of the older equipment that was serial driven seemed to like the built in delay between charactor send over serial for some reason ???????
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 28, 2008, 10:29:41 AM
Hi Terry - now you're starting to take the p*ss  ;D

(PS - for 0x378 (C hex style) use &H378 (BASIC hex style)

Hi Terry - with regard to your last question to Graham - you need to read my earlier reply about the format of hex strings in BASIC. The syntax is &H0378 or whatever address you're using. The &H is instead of Grahams 0x at the front of the string.

A word of caution which I hope isn't too late. You have to be VERY careful which port or address you write to - you can seriously screw up your system - even trash the hard disk if you're not careful.
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 11:45:51 AM
OK I have the Tool slot assignment report finished, It tells what tool is in what slot and prints it out for you. It is assigned to a button (Print TOOLSLOT Assignment) It tells the slot #, T# and tool desc. Also inclused the tool currently in the spindle.

textFilePath = "C:\mach3\ToolAsmt.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(textFilePath)

slt1= getuserdro(1150)
slt2= getuserdro(1151)
slt3= getuserdro(1152)
slt4= getuserdro(1153)
slt5= getuserdro(1154)
slt6= getuserdro(1155)
slt7= getuserdro(1156)
slt8= getuserdro(1157)
TIS= getuserdro(1159)

TS1= gettooldesc(slt1)
TS2= gettooldesc(slt2)
TS3= gettooldesc(slt3)
TS4= gettooldesc(slt4)
TS5= gettooldesc(slt5)
TS6= gettooldesc(slt6)
TS7= gettooldesc(slt7)
TS8= gettooldesc(slt8)
TISA= gettooldesc(TIS)

objTextFile.WriteLine("*TSlot1---- " & slt1 &" -- " & TS1)
objTextFile.WriteLine("*TSlot2---- " & slt2 &" -- " & TS2)
objTextFile.WriteLine("*TSlot3---- " & slt3 &" -- " & TS3)
objTextFile.WriteLine("*TSlot4---- " & slt4 &" -- " & TS4)
objTextFile.WriteLine("*TSlot5---- " & slt5 &" -- " & TS5)
objTextFile.WriteLine("*TSlot6---- " & slt6 &" -- " & TS6)
objTextFile.WriteLine("*TSlot7---- " & slt7 &" -- " & TS7)
objTextFile.WriteLine("*TSlot8---- " & slt8 &" -- " & TS8)
objTextFile.WriteLine("**")
objTextFile.WriteLine("**")
objTextFile.WriteLine("*Tool In Spindle---- " & TIS &" -- " &TISa)

objTextFile.Close
Dim sCOMMAND As String
 sCOMMAND="print c:\mach3\toolasmt.txt"
 Shell("c:\winnt2\system32\cmd.exe /c" & sCOMMAND)
End   


****************** Copy of the printout

*TSlot1---- 8 -- Probe,6"a,2mm,BE
*TSlot2---- 7 -- FM,6",alum
*TSlot3---- 6 -- BB, set .4883" DIAM
*TSlot4---- 5 -- Tap,tc,1/4x20
*TSlot5---- 4 -- .500,EM,3f,FN,CB
*TSlot6---- 3 -- .250EM,2f,FN
*TSlot7---- 2 -- .250,EM,4f,BN
*TSlot8---- 0 -- Empty
**
**
*Tool In Spindle---- 1 -- .250,EM,2f,RN


(;-) TP



Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 12:35:09 PM
OK I figured out the Time and Date thingy but I have a question about the file structure that gets printed out.

THis is what the file prints like:

*Tool#1  * .250,EM,2f,RN *Dia: 0.375 *Lgth: 1 *WrDiam0

*Tool#2  * .250,EM,4f,BN *Dia: 0.05 *Lgth: 0 *WrDiam0

*Tool#3  * .250EM,2f,FN *Dia: 0.5 *Lgth: 0 *WrDiam0

*Tool#4  * .500,EM,3f,FN,CB *Dia: 0.25 *Lgth: 1 *WrDiam0

*Tool#5  * Tap,tc,1/4x20 *Dia: 0.12 *Lgth: 0 *WrDiam0

*Tool#6  * BB, set .4883" DIAM *Dia: 0.375 *Lgth: 0 *WrDiam0

*Tool#7  * FM,6",alum *Dia: 1 *Lgth: 0 *WrDiam0

*Tool#8  * Probe,6"a,2mm,BE *Dia: 1 *Lgth: 0 *WrDiam0

*Tool#9  * .500 *Dia: 1 *Lgth: 0 *WrDiam0

*Tool#10  * This is a test *Dia: 1 *Lgth: 0 *WrDiam0

*Tool#99  * Probe *Dia: 1 *Lgth: 3 *WrDiam0

**
  Date: 3/28/2008 Time: 11:25:28 AM




********* THis is what I would like it to look like: Whith the columns lined up.

*Tool#1    * .250,EM,2f,RN           *Dia: 0.375    *Lgth: 1    *WrDiam0

*Tool#2    * .250,EM,4f,BN           *Dia: 0.05      *Lgth: 0     *WrDiam0

*Tool#3    * .250EM,2f,FN            *Dia: 0.5        *Lgth: 0     *WrDiam0

*Tool#4    * .500,EM,3f,FN,CB       *Dia: 0.25      *Lgth: 1     *WrDiam0

*Tool#5    * Tap,tc,1/4x20           *Dia: 0.12      *Lgth: 0     *WrDiam0

*Tool#6    * BB, set .4883" DIAM   *Dia: 0.375    *Lgth: 0     *WrDiam0

*Tool#7    * FM,6",alum                *Dia: 1          *Lgth: 0     *WrDiam0
 
*Tool#8    * Probe,6"a,2mm,BE     *Dia: 1          *Lgth: 0     *WrDiam0

*Tool#9    * .500                        *Dia: 1          *Lgth: 0     *WrDiam0

*Tool#10  * This is a test             *Dia: 1          *Lgth: 0     *WrDiam0

*Tool#99  * Probe                       *Dia: 1         *Lgth: 3     *WrDiam0

**
  Date: 3/28/2008 Time: 11:25:28 AM


Seeing how I can't format at the print level I would need to format the actual file that is written to look like this as the printer just dumps the file when printing.

Any ideas ????? 

(;-) TP

Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 01:40:44 PM
Mean while back at the farm,(;-) I have stalled long enough building the easy stuff(;-) Back to the LOGIC side.

Seeing that Mach saves the DRO values I think the approach to the hotswap should stay with the dro approach.

I want to have the process selfcontained inside of mach if possible. So I will pound on a process using the DROs as the VARs. 


Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 02:47:15 PM
HI IAN,     I am quickly starting to SEE the simplicity of YOUR solution (:-) (;-) If I can just figure out how to make it UPdate the dros on the page but yet work like your solution.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 28, 2008, 03:30:06 PM
Hi Terry

No problem. I order by tool, you order by slot. Just loop through my tools and read each slot. Then use the slot to index the appropriate DRO.

e.g.

assuming your first gcode var is #1000 and your slot 1 DRO number is 1000 AND that you use consecative vars and DROs (which would be weird if you didn't)

numTools=8
gcodeVarBase=999 (or whatever i.e. 1 less than the first you use)
droBase=999 (or whatever i.e. 1 less than the first you use)

for tool = 1 to numTools
  slot = GetVar(gcodeVarBase + tool)
  SetUserDRO(droBase + slot, tool)
next

Ian
Title: Re: Tool changer routine with hot swap
Post by: poppabear on March 28, 2008, 04:42:03 PM
Very Nice work!!

Here is a pic of the ATC setup page on my "Night Vision" flash Screens, it is set up for the Swap Arm type ATC.

Scott
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 05:19:20 PM
Scott that is a really nice looking page.

IAN, I think I am lost BUT, mach is crashing the vb and program run and mdi so I can't tell if it is me or mach that is crazy.

I guess I will have to wait untill Brian sorts this out OR back up to an OLD version. 

I am not sure if I have the last piece of the code in the right place yet. I beat on it for a while then change it and beat on it some more.(;-)

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 06:20:03 PM
OK I have the tool changer INITIALIZATION Button working , I can load up the tool slots and push the button and set all the neccasary VARS correctly.

THe hotswap is still eluding me brain.  One thing I noticed is that when I remove a tool from the slot it needs to reset to zero until the next cycle occurs where it gets set back to the returned tool number. That will show the slot vacant when a tool is in the spindle. THat way IF I have to stop incycle the tool slots will be correct and SHOW the empty slot.

(;-) TP
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 28, 2008, 09:11:53 PM
YEP just as I thought, Hopelessly lost in LOGIC again(;-) I have tried various ways that I could think of to tie it together but NOT.



THe original intention was to fill in the dros on the page to match up the slots and tool#. Then press the initialize Button to set the system VARs .

In A program the first T# would set the Next Tool Up dro. Then the m6start will transfer the NTU over to the Tool In Spindle dro. As the next T3 is read it will again fill in the NTU dro. As the NTU dro changes then the BRAINS will trigger a holding relay to RELEASE and start a motor to turn the carousel. The Brains will then monitor the encoder on the carousel untill it sees the proper ID code then STOP the motor and lock the carousel in position.

THen the m6start macro would do the actual swap based on the t#s being held by the
macro

So far i have everything working BUT the actual hotswapping of the DROs.

Listed are the parts of the m6start macro I have to work with: THe brains part I have not listed.

********************************************************************************


********************************************************************************


Tool = GetSelectedTool()                 '* Original code in M6start from mach
Setcurrenttool(tool)
Setuserdro(1300,tool)

'***************************************************************

Option Explicit                                 '* Code to run hotswap

Const numTools=8

Dim currentTool As Integer
Dim selectedTool As Integer
Dim selectedSlot As Integer
Dim crlf As String
Dim msg As String
Dim i As Integer

                                                          ' what is the selected tool?
selectedTool = GetSelectedTool()

                                                          ' in which slot in the carousel is the  required tool?

selectedSlot = GetVar(1000 + SelectedTool)

                                                            ' remind ourselves what the current tool  is
currentTool = GetVar(1000)

                                                            ' stick the current tool in the selected tool's slot

SetVar(1000 + currentTool, selectedSlot)

                                                             ' remember for next time which tool we're   now using
SetVar(1000, selectedTool)

                                                             ' tell Mach which tool is selected
SetCurrentTool( selectedTool )

                                                              ' dump the carousel state for our reading    Pleasure
crlf = Chr(13) & Chr(10)

If currentTool = 0 Then
  msg = "Getting tool " & selectedTool & " from slot " & selectedSlot
Else
  msg = "Swapping tool " & currentTool & " for tool " & selectedTool & " in slot " & selectedSlot
End If

msg = msg & crlf & crlf

'for each tool
For i=1 To numTools
  If i = selectedTool Then
    msg = msg & "Tool " & i & " is in the spindle" & crlf
  Else
    msg = msg & "Tool " & i & " is in slot " & GetVar(1000 + i) & crlf
  End If
Next

'******************************************************************************
                                         '* Last piece of code to update DROs
                                           
                                                '* assuming your first gcode var is #1000  and your slot 1 DRO number is 1000 AND 
                                                 '* that you use consecative vars and DROs (which would be weird if you didn't)

numTools=8
gcodeVarBase=1000                    '* (or whatever i.e. 1 less than the  first you use)
droBase=1149                            '* (or whatever i.e. 1 less than the   first you use)

for tool = 1 to numTools
  slot = GetVar(gcodeVarBase + tool)
  SetUserDRO(droBase + slot, tool)
next



*********************** For now I am at a stalemate that is limited by my faulty programer GENE If you can help out please do and please notate for better understanding if you can.

Thanks (;--) TP
Title: Re: Tool changer routine with hot swap
Post by: stirling on March 31, 2008, 08:11:39 AM
Hi Terry - Have you got the actual tool changer mechanics built yet? if not, would it be poss for you to do that?

I will get back to you asap but at the moment I'm pretty tied up time wise.

Cheers

Ian
Title: Re: Tool changer routine with hot swap
Post by: vmax549 on March 31, 2008, 10:25:36 AM
Hi IAN, THere is NO hurry(;-). I am in the process of finishing up the carousel. I am starting to see the logic picture the more I work with the pieces so it may CLICK on its own(;-). That has always been my flaw, I seem to be missing the logic GENE.  Once I have a logic pattern to work with I can do just fine with modifications and add ons.

Again NO HURRY,  Thanks for all the help

(;-) TP