Hi,
To show how a toolchanger can be controlled through a Modbus device, below is some information about how I've implemented a changer module in the ModIO for an Emco changer.
Cheers,
Peter.
/*******************************************************************************
Emco.c
********************************************************************************
/********************************************************************************
The ModIO will read the 2 optical switches and drive the Motor direction Relay.
The EMCO changer has 2 inputs, a turret home switch and a Turret position
switch. The home switch indicates that the turret is lined up with tool position
one locked. This switch will activate whenever the turret passes position 1.
The other switch the turret position switch input is the input from 6 turret
position switches in parallel. If any one of the 6 switches are activate then
this input will be active. Therefore, this input doesn't indicate what tool
position we are at, just that the "Next" tool position has been reached. There it
is necessary to keep track of where the changer is relative to the home
position (Tool 1)
The changer will work as follows;
On startup or after an error occurs we assume we are lost. When the first
toolchange request comes in, the changer will rotate until it sees the home
switch input go active. When it sees this it knows where it is, tool 1, and can
then move to the requested position.
There is also a timeout. If the home switch is not found within the configurable
timeout, an error is assumed to have occured, and the changer stops.
When a tool change is requested and the current position is known, the changer
rotates the turret counting the number of times the position input goes active
until the desired tool position is reached.
There are also 6 outputs used as position indicators, plus a status indicator
output. The position indicators will illuminate when the turret is at the
indicators position. That is, indicator 2 will illuminate when tool position 2
is reached.
The status indicator will illuminate whenever the tool changer is activated.
It will extinguish when the change operation has completed. If an error has
occured and the change is aborted, the indicator will flash until the next
valid operation has completed.
Once the desired position is reached, the motor forward relay is de-energised
and the motor reverses, locking the turret into the desired position.
Note, the position switches on the turret are positioned to be activated once
the turret has passed the tool location. The reversing of the motor rotates the
turret back to lock into the tool position.
There is also a manual change input switch. When activated, the turret will jog
to the next tool position.
Modbus Interface
================
The Emco changer interfaces by a number of Modbus registers as defined below. A
number of the registers are configuration registers and are used to initially
configure the changer. There are also a set of registers that are then used to
control the changer during normal operation.
Config registers
----------------
register 150 Turret Config
This config register is used to enable the EMCO toolchanger module. To turn ON
the module, bit 1 needs to be cleared. Therefore 0x00FD should be written to
register 150 to enable the changer.
register 151 Change Delay timeout HI BYTE
register 152 Change Delay timeout LO BYTE
These 2 registers make a 16 bit timeout which if it expires will abort the change
and error. If you set the time out registers 151 and 152 to 0x10 and 00x0, you
will get a time out of approximately 30 seconds. each bit in the hi register 151
is worth about 2 seconds. With the default value of 0xFF and 0xFF the timeout
is over 500 seconds
register 153 Reverse Delay timeout HI BYTE
register 154 Reverse Delay timeout LO BYTE
These 2 registers define the time delay between between turning off the forward
relay and indicating that the toolchange has completed. This delay is to allow
the changer enough time to lock the turret. With the default value of 0xFF and
0xFF the timeout is turned off.
Output Registeres
-----------------
register 1100 Requested Tool
This register contains the tool position for the next tool change. If this
register contains 0 when the tool change is requezsted, a dummy tool change
occurs. This is a good way to synchronise the Tool Change Counter 1101 output
register and the Tool changed count 1201 input register.
register 1101 Tool Change Counter
This register is used to initiate a tool chage operation. Whenever this register
value is changed a tool change occurs. Therefore to change a tool position, the
position to chage to is first written into register 1100, then the contents of
register 1101 are changed. It is best to increment it as this helps debugging.
Input Registers
-----------------
register 1200 Current Tool
This register contains the current tool position If this register contains 0
it indicates that the tool changer is "lost"
register 1201 Tool Changed Count
This register is used to determine when a tool chage operation is complete. This
is indicated by this register having the save value as register Tool Change
Counter 1101.
To perform a toolchange, the value of 1101 is changed to initiate the change.
When the change is complete, register 1201 will contain the same value that was
written to 1101.
register 1202 Tool Change Error Code
This register is used to determine the state of the last change request. If the
change was completed with an error, this register will contain 0x0000, otherwise
it will contain an error code.
register 1203 Tool Change Mode
This register contains the changers internal state as the change is occurring. It
is only used for debugging purposes.
Changer Operation
=================
To use the changer, the module must first be enabled by writing 0x02 to register
150.
Initially register 1100 should be written with 0x0000. Then, write0x0001 to
register 1101 to perform a dummy change.
Then to perform a tool change, write the new tool position to register 1100, then
increment register 1101 to start the change operation. Register 1201 is then checked
until it changes to the same value in register 1101
*******************************************************************************/