Setting up a tool changer

More
18 Jan 2012 19:14 #16898 by fferraz
fferraz created the topic: Setting up a tool changer
Hi guys, nice to make my first post in the community.

My name is Felipe, I work on a jewelry factory and some months ago we built our own CNC Lathe.

We first tried to use the Windows program Mach3 to control it. We managed to get it fully working but we were having some problems where the machine would start loosing its reference after some work time. Also, after using it for a little bit, we just found the program to be kinda bad hehehe.

Well, we then looked for some other program and we found linux CNC as one of the most reliable programs around, so we are giving it a try.

For now, we already managed to get everything working like a charm... EXCEPT for the tool changer. We have a carousel with 8 tools in it and I've already looked at every part of the program, the stepconf and the manual but I'm just LOST on how to make it work... I know that I have to use something related to the HAL and EMCIO but I just couldn't figure out how to do it.

What I need is that whenever I use the T1, T2 ... T8 on my code, that the program sends a binary digit to 3 pins of the parallel port (pins 2, 14 and 16). Also it should read from pin 10 if it's 0 or 1, because that is the pin that'll say that the change is done. So the "table" is something like this:

Tool - Pin 10 - Pin 2 - Pin 14 - Pin 16

T1 - 1 - 1 - 1 - 1
T2 - 1 - 0 - 1 - 1
T3 - 1 - 1 - 0 - 1
T4 - 1 - 0 - 0 - 1
T5 - 1 - 1 - 1 - 0
T6 - 1 - 0 - 1 - 0
T7 - 1 - 1 - 0 - 0
T8 - 1 - 0 - 0 - 0

Is there any easy way to do this? I would REALLY REALLY appreciate some help here, since none of us are really programming geniuses hehe.

We're using EMC2 2.4.6 on Ubuntu 10.04.

Sorry if my english is not perfect (I'm from Brazil) and also if something is not very well explained... is kinda hard to explain this stuff with a foreign language. ;)

Thanks in advance for your attention.
More
18 Jan 2012 19:41 #16899 by cncbasher
cncbasher replied the topic: Re:Setting up a tool changer
is this a ready buit toolchanger ?

motor driven or stepper motor
and have you position encoder

their are 2 toolchanger comp files in the wiki for a Boxford and Orac toolchanger
that may help with a bit more information about the toolchanger

i'm sure a solution is close
More
18 Jan 2012 19:57 - 18 Jan 2012 19:58 #16901 by BigJohnT
BigJohnT replied the topic: Re:Setting up a tool changer
Felipe,

Welcome to the LinuxCNC forum.

Take a look at my CHNC lathe config files which contain an eight station tool turret. It uses some HAL and some Classicladder. The HAL sections are documented as to their function.

gnipsel.com/shop/hardinge/hardinge.xhtml

John
Last Edit: 18 Jan 2012 19:58 by BigJohnT.
More
18 Jan 2012 20:16 #16902 by andypugh
andypugh replied the topic: Re:Setting up a tool changer
fferraz wrote:

T1 - 1 - 1 - 1 - 1
T2 - 1 - 0 - 1 - 1
T3 - 1 - 1 - 0 - 1
T4 - 1 - 0 - 0 - 1
T5 - 1 - 1 - 1 - 0
T6 - 1 - 0 - 1 - 0
T7 - 1 - 1 - 0 - 0
T8 - 1 - 0 - 0 - 0

Is there any easy way to do this?


I think there is.
Note that if you invert pins 2,14,16 then they are simply counting in binary from 0 to 7, so this is a job for select8
www.linuxcnc.org/docview/html/man/man9/select8.9.html
(Which admittedly doesn't have the clearest of descriptions)
Because it needs 0 to 7 and the tools are 1 to 8, you will also need to add -1.
It looks like pin 10 can be connected directly to tool-changed
So, you need to put the following in custom.hal, assuming that the parallel port pins 10,2,14 and 16 are unallocated.
#load the components
 loadrt sum2 count=1
loadrt select8 count=1
#add to a thread
addf sum2.0 servo-thread
addf select8.0 servo-thread
# make the sum into a decrement by 1
setp sum2.0.in1 -1
#link the pins (unlink the toolchange in case it is linked)
unlinkp iocontrol.0.tool-changed
unlinkp iocontrol.0.tool-number 
net change-done iocontrol.0.tool-changed <= parport.0.pin-10-in
net tool-num iocontrol.0.tool-number => sum2.0.in0
net tool-num-dec sum2.0.out => select8.0.sel
net bit0 select8.0.out0 => parport.0.pin-02-out
setp parport.0.pin-02-out-invert true
net bit1 select8.0.out1 => parport.0.pin-14-out
setp parport.0.pin-14-out-invert true
net bit2 select8.0.out2 => parport.0.pin-16-out
setp parport.0.pin-16-out-invert true

It might need a bit of tweaking to not return instantly, depending on the timing.
More
19 Jan 2012 09:55 #16930 by fferraz
fferraz replied the topic: Re:Setting up a tool changer
Hey guys, thanks a lot for the quick replies! ;)

Ok, to answer cncbasher's questions:
- No, it's not ready built, we built the tool changer too.
- It's motor driven.
- We do have a position encoder.

BigJohnT, I took a look at your config files and we'll go deeper into them later. I think it may help us with a lot of info indeed.

andypugh, your solution indeed looks very promising! I tried to use it but it's giving me an error:

Debug file information:
custom.hal:16: Signal 'tool-num' of type 's32' cannot add pin 'sum2.0.in0' of type 'float'


Any idea why that is?

Thanks again guys, nice to be part of such a helpful community.
More
19 Jan 2012 11:20 #16931 by andypugh
andypugh replied the topic: Re:Setting up a tool changer
fferraz wrote:

andypugh, your solution indeed looks very promising! I tried to use it but it's giving me an error:

Debug file information:
custom.hal:16: Signal 'tool-num' of type 's32' cannot add pin 'sum2.0.in0' of type 'float'

Any idea why that is?.

Ah, yes.
HAL has 4 different data types, boolean/bit, floating point and signed and unsigned integers.
The toolchanger needs to work throughout with signed integers, but unfortunately sum2 only works with floating-point.
The best answer to this is to add an offset pin to the select8 component, and I might do that, however that won't take effect until the next software release.
The pragmatic solution at the moment is to convert to float and back again.
#load the components
loadrt sum2 count=1
loadrt select8 count=1
loadrt conv_s32_float count=1
loadrt conv_float_s32 count=1
#add to a thread
addf conv_s32_float.0 servo-thread
addf sum2.0 servo-thread
addf conv_float_s32.0 servo-thread
addf select8.0 servo-thread
# make the sum into a decrement by 1
setp sum2.0.in1 -1
#link the pins (unlink the toolchange in case it is linked)
unlinkp iocontrol.0.tool-changed
unlinkp iocontrol.0.tool-number 
net change-done iocontrol.0.tool-changed <= parport.0.pin-10-in
net tool-num iocontrol.0.tool-number => conv_s32_float.0.in
net tool-num-float conv_s32_float.out => sum2.0.in0
net tool-num-dec-float sum2.0.out => conv_float_s32.0.in
net tool-num-dec-signed conv_float_s32_0.out => select8.0.sel
net bit0 select8.0.out0 => parport.0.pin-02-out
setp parport.0.pin-02-out-invert true
net bit1 select8.0.out1 => parport.0.pin-14-out
setp parport.0.pin-14-out-invert true
net bit2 select8.0.out2 => parport.0.pin-16-out
setp parport.0.pin-16-out-invert true
More
19 Jan 2012 11:57 #16933 by fferraz
fferraz replied the topic: Re:Setting up a tool changer
Hey andy, thanks again for the correction. Now the error is that the program can't find the conversion function.

Debug file information:
HAL: ERROR: function 'conv_s32_float.0' not found
custom.hal:10: addf failed


Weird, uh?
More
19 Jan 2012 12:03 #16934 by andypugh
andypugh replied the topic: Re:Setting up a tool changer
fferraz wrote:

HAL: ERROR: function 'conv_s32_float.0' not found

Sorry, I am doing all this without access to an actual EMC2 machine.
If you look at www.linuxcnc.org/docview/html/man/man9/conv_s32_float.9.html
You will see that the component is conv_232_float but the function is conv-s32-float..
So, you need to swap the _ for - in the addf and net lines, but not the loadrt. This applies to both conversions.
More
19 Jan 2012 16:19 #16943 by fferraz
fferraz replied the topic: Re:Setting up a tool changer
Great, andy, thanks a lot, now it loaded alright.

Just so that I understand what you did in that code...
Here ( net tool-num iocontrol.0.tool-number => conv-s32-float.0.in )you're getting the tool number from the command (e.g.: T6 M6) and inputting it into the converter.

Then you are taking the output from the converter and putting into the sum2 function, which will decrease the number by 1.

Then you're sending the output of that sum (which in the example will be 5) and converting it back to s32. Finally you'll send that s32 output to the select8 function, which will then output "101", but you send those bits inverted to the parallel port so it'll receive "010", which should call the tool 6.

Is this right?

I'm asking all of this because I'm pretty sure your code is perfect but I have some problem on my connections, because it's not working. I tried typing T1, T2, T3.... in the MDI window and nothing happened. Also, the spindle is running continuously whenever I load the program.

I'll try to have a talk with the guy who built and connected the turret for us to check if that's really the way it's supposed to work... maybe I misinterpreted something on mach3.
More
19 Jan 2012 16:31 #16944 by andypugh
andypugh replied the topic: Re:Setting up a tool changer
fferraz wrote:

you're getting the tool number
...
to the parallel port so it'll receive "010", which should call the tool 6.

Yes, that's the idea.

You need an M6 with any T-number. I don't know if you are doing that?
You generally want a G43 too, to apply the correct tool-length offset.

The problem might be that the tool-changed flag on parport-10 isn't going low on time, so the toolchange is completing immediately.

Halscope is probably going to be useful for watching all these fast-changing signals.

It might be necessary to mask iocontrol.0.tool-changed with a oneshot component triggered from iocontrol.0.tool-change.
However, looking at www.linuxcnc.org/docview/html/config_emc2hal.html#r1_3 it seems likely that the HAL code was wrong, and you need to swap iocontrol.0.tool-number to be iocontrol.0.tool-prep-number
Time to create page: 0.193 seconds
Powered by Kunena Forum