1
General Mach Discussion / Help required for relay output code
« on: March 15, 2023, 07:45:18 AM »
I require some help adding code to an existing project.
I have built a motion fence for my table saw using Mach3, which works well. But I needed to add an air cylinder to 'clamp' the end of the fence (furthest from the linear rail mounting), as the fence flexed a small amount. This feature is now installed and is manually controlled with a button on the screen-set and successfully clamps the fence rigid. This button uses the Mist Toggle (114) to 'clamp' the fence but I now need to add some code the existing code that moves the fence to the desired position.
Here's what I require.....
After moving the fence to a required position, M7 needs to be turned ON (clamped). When another position is required, after entering the target with the numeric buttons, firstly, M9 needs to turn OFF (unclamped). A delay of around 1 to 2 seconds is required (I can adjust this to get the right timing), to allow the air cylinder to retract, then the movement (target) can start. When the target position is reached, M7 needs to activate again to clamp the fence. I might need another delay after the target is reached, to ensure that the clamp doesn't engage before the movement has reached its position. I assume 'WhileIsMoving' will work?
An important note is that the clamp must be turned off before the movement takes place, otherwise the fence will move while 'clamped' and will skew (damage) the mechanics. The clamp remains on until another position is entered.
The existing code that moves the fence is shown below, which takes the required 'target' from a numeric keypad....
Sub Main()
SetOEMDRO(1400,0)
NumericKeyboard(1400)
Code "G0 X" &GetOEMDro(1400)
End Sub
I was hoping to amend the code myself but I'm a bit unsure of where exactly to place the code and I don't want to damage any of the mechanics if the clamp doesn't turn off while the fence moves! Below is the sort of thing I'm looking for....
Sub Main()
SetOEMDRO(1400,0)
NumericKeyboard(1400)
DISENGAGE CLAMP (M9)
WAIT 1 SECOND (TO ALLOW CYLINDER TO RETRACT)
Code "G0 X" &GetOEMDro(1400)
ENGAGE CLAMP (M7)
WAIT 2 SECONDS (TO ALLOW CYLINDER TO CLAMP)
End Sub
I hope you can assist me with this.
I have built a motion fence for my table saw using Mach3, which works well. But I needed to add an air cylinder to 'clamp' the end of the fence (furthest from the linear rail mounting), as the fence flexed a small amount. This feature is now installed and is manually controlled with a button on the screen-set and successfully clamps the fence rigid. This button uses the Mist Toggle (114) to 'clamp' the fence but I now need to add some code the existing code that moves the fence to the desired position.
Here's what I require.....
After moving the fence to a required position, M7 needs to be turned ON (clamped). When another position is required, after entering the target with the numeric buttons, firstly, M9 needs to turn OFF (unclamped). A delay of around 1 to 2 seconds is required (I can adjust this to get the right timing), to allow the air cylinder to retract, then the movement (target) can start. When the target position is reached, M7 needs to activate again to clamp the fence. I might need another delay after the target is reached, to ensure that the clamp doesn't engage before the movement has reached its position. I assume 'WhileIsMoving' will work?
An important note is that the clamp must be turned off before the movement takes place, otherwise the fence will move while 'clamped' and will skew (damage) the mechanics. The clamp remains on until another position is entered.
The existing code that moves the fence is shown below, which takes the required 'target' from a numeric keypad....
Sub Main()
SetOEMDRO(1400,0)
NumericKeyboard(1400)
Code "G0 X" &GetOEMDro(1400)
End Sub
I was hoping to amend the code myself but I'm a bit unsure of where exactly to place the code and I don't want to damage any of the mechanics if the clamp doesn't turn off while the fence moves! Below is the sort of thing I'm looking for....
Sub Main()
SetOEMDRO(1400,0)
NumericKeyboard(1400)
DISENGAGE CLAMP (M9)
WAIT 1 SECOND (TO ALLOW CYLINDER TO RETRACT)
Code "G0 X" &GetOEMDro(1400)
ENGAGE CLAMP (M7)
WAIT 2 SECONDS (TO ALLOW CYLINDER TO CLAMP)
End Sub
I hope you can assist me with this.