Page 1 of 2

Rotary tool changer

Posted: Thu Jun 06, 2019 9:37 pm
by Mateusz
Dear All,

I'm struggling to implement a rotary tool changer to modified HURCO BMC50. I'm doing tool change first time with basic knowledge of C lang.
Not sure how I can make of use existing LIbrary :?

There are few signal to shuffle around:
- Vertical valve + lower / upper position sesnors
- Horizontal valve + Extended / Retracted Sesnors
- Index sensor
- Carousel home sensor indicating 20th - last tool.
- and tool clamp / unclamp signals set.

I'll be grateful for support,


Re: Rotary tool changer

Posted: Fri Jun 07, 2019 3:40 pm
by TomKerekes
Hi Mateusz,

The first step would be to come up with a detailed flow chart or pseudo code sequence for exactly what has to happen.

Also create a bit list for all the inputs and outputs and what their polarities are.

Is there a rotation axis?

You might test and prove out the sequence manually by toggling bits and observing inputs on the KMotion | Digital IO Screen.

See a code example here.

Re: Rotary tool changer

Posted: Mon Jun 10, 2019 3:29 pm
by Mateusz
Hello Tom,

Thank you for replay,
I've created flow chart see attached files + Functional drawing of the rotary unit itself. I think all information are clear. Below required logic on this setup.

#define Cyl_UP 49 // Coil of Vertical cylinder to move UPwards
#define Cyl_DN 50 // Coil of Vertical Cylinder to move Downwards
#define Cyl_EXT 52 // Coil of Horizontal Cylinder to move magazin towards spindle
#define Cyl_RET 51 // Coil of Horizontal Cylinder to move magazine backwards
#define Sens_UP 1036 // Cylinder sensor UP position - logic 1
#define Sens_DN 1037 // Cylinder sensor DN position - logic 1
#define Sens_EXT 1039 // Cylinder sensor EXTENDED position - logic 1
#define Sens_RET 1038 // Cylinder sensor RETRACTED position - logic 1

#define Rotate_ON 53 // Hi state cause to rotate magazine CW
#define Rotate_CCW 54 // Hi state cause to rotate magazine CCW
#define 0_position 1034 // Magazine zero position indicates 20th last position of tool holder
#define INDEX 1035 // Sensor to INDEX rotary unit. One pulse = One Tool Position, LO state indicates Stop / Lock position

#define CLAMP_Cyl 48 // Cylinder to clamp / unclamp Tool. HI - unclamp
#define CLAMP_Pos 1040 // Tool clamped - HI
#define UNCLAMP_Pos 142 // Tool unclamped - HI
#define C_Button 1041 // Manual tool load / unload Push Button

#define Spin_0 149 // HI state orients SPINDLE to 0 Position
#define Orient_Rdy 1032 // HI state indicates SPINDLE 0 position reached

#define Tool_Change_pos xxx.xx // Tool change position for Z axis Cnt's or mm's

Machine is now running with MPG, Servo Spindle + some extra buttons and POt's for FRO and SSO. Toolchange is to tricky for me at the moment.

Thanks Mateusz

Re: Rotary tool changer

Posted: Mon Jun 10, 2019 9:55 pm
by TomKerekes
Hi Mateusz,

That's a great start. But you left out a lot of details.

Create a more detailed flowchart on how to rotate the turret one index position CW and CCW.

Then create a flowchart to home the turret to position 20 using the above.

Then create a flowchart to move the turret from the current position to the desired position.

Include checking for timeout errors assuming you have.a start time in seconds and a current time in seconds.

Re: Rotary tool changer

Posted: Tue Jun 11, 2019 9:34 pm
by Mateusz
Hi Tom,

As requested, Please see attached flow charts. I tried to make chart to allow turret move to destination point in the shortest distance / time, not sure of this one it will gonna work correctly.


Re: Rotary tool changer

Posted: Wed Jun 12, 2019 12:21 am
by TomKerekes
Hi Mateusz,

No sorry. Those flow charts don't make sense.

You can't have a box with an operation like SetBit have two exits. Only one exit is allowed.

All "if" statements must have two exits. One for true and one for false.

You can't do things like:
Counter = n
When n hasn't ever been defined.

Please research flowcharts. Basically a human should be able to follow your flowchart without ever guessing what to do.

Re: Rotary tool changer

Posted: Wed Jun 12, 2019 4:39 am
by TomKerekes
This looks looks like a good reference that might help.

Re: Rotary tool changer

Posted: Wed Jun 12, 2019 11:21 am
by Mateusz
Hello Tom,

Yes it wasn't good :( but good think is to become better in charts :D - new version attached. I still wonder about the files setup.
Do I'm thinking right ?:
- I think file ServiceToolChangeTable.c would be the most appropriated to co carry out modifications for my needs.
- after mods this file has to run all the time in the KFLOP under any spare thread ? or can be called once when tool change is required directly from M6 command ?
- file SetLastTo1.c Could you please explain me when and how to use it ?
- is there any extra file required to setup to make this tool change happen ?

Shame I can not test it this week. My machine is very far away and there will be no much time to waste on trial and error methodology next time.
I have to collect as much information I need.


Re: Rotary tool changer

Posted: Thu Jun 13, 2019 9:17 am
by TomKerekes
Hi Mateusz,

Much better, but still many errors and missing parts.

Flowcharts should not have any 'while' commands. Instead use 'if' commands that form loops. In some of your loops you will need 2 'if' conditions. For example one to check if the index is present and one to check if the current time - starting time is > 2 seconds

I don't know how your index pulse works. How wide it is or how quickly your turret stops or how much switch bouncing there is. There will likely be a problem where when you go to rotate one index the old index will still be present or bouncing and you will not move the correct amount. You may need logic to wait until the old index goes away for some time before checking for the new index.

I don't follow your logic on which way to turn to the next tool. It seems wrong. Did you try simple examples? I would compute the difference between the new and last first. Then decide if shorter to go the other way. Also if you simply add 20 to the LAST_TOOL then it could be an invalid number like 35 for the next time.

Please wait until you understand exactly what needs to be performed before trying to code it for KFLOP. Everything needs to be broken down into simple steps any human or machine could do that only involves: setting/clearing bits, reading bits, comparing values, reading/saving current time, and arithmetic. But I would use Linear4ToolHolders Rev 1.c as a basis.

I would configure M6 to load and execute the program in an unused Thread, wait until completed, and then sync since axes might have been moved. It should not need to run continuously.


Re: Rotary tool changer

Posted: Thu Jun 13, 2019 10:29 pm
by Mateusz

I'll get back to this topic in few days, I'm running out my time. Once I'll collect all information and fix the charts, I will present them to you.