Help needed on the best way to control a 8 position lathe turret

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
jumps4
Posts: 143
Joined: Wed Oct 10, 2018 8:37 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 38d2697ca033-0611180974 mpu12
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: New Port Richey, Fl. USA
Contact:

Help needed on the best way to control a 8 position lathe turret

Post by jumps4 »

Hello
I have been converting a 11x26 lathe to Acorn.
I have just updated windows 10 and cnc12 to v4.18
viewtopic.php?f=57&t=3068
report_38D2697CA033-0611180974_2019-09-05_15-34-47.zip
(280.71 KiB) Downloaded 156 times
I have working so far:
spindle encoder
Haun Yang vfd with 3hp motor
Acorn board and 8 relay board
automatic tool measurement
flood coolant
touch screen
shuttle express
425oz closed loop steppers x and z (not reporting faults to acorn yet, i have to program drives)
Intel core i5-2400 @3.1Ghz 4gb ram
duel monitors keyboards and mouse

At present there are no home/limit switches or emergency stop connected so i have 6 open inputs
I have built my own 8 position tool turret and I'm now ready to make my limit switch and turret location inputs connections
I'm asking for help with the most accurate home switches parallel or series/
should I use 4 inputs for gray logic for the turret plus a home switch?
I understand the concepts but I'm new to coding in cnc environment for the turret and gray logic.
So if someone could help me build the perfect setup for acorn lathe with a turret I'll purchase whats needed so there are no work a rounds I would like to make this the ideal setup for an acorn board.
The tool turret is driven by a 425oz stepper, 30:1 worm drive unidirectional and needs to reverse a very small amount ( 1 or 2 degrees to lock )
when the turret locks by reversing the location does not change, it just locks a sprag clutch with spring pressure.
(see build thread for more pics viewtopic.php?f=57&t=3068 )
any help and ideas would be greatly appreciated
wiring , switches ect.
Thank You
Steve
Attachments
DSCF2588.JPG
DSCF2587.JPG
DSCF2586.JPG
DSCF2585.JPG
DSCF2584.JPG
DSCF2583.JPG
DSCF2582.JPG
DSCF2581.JPG
DSCF2589.JPG
Last edited by jumps4 on Sat Sep 07, 2019 8:35 pm, edited 1 time in total.
No Brains, No Headaches...
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 possition lathe turret

Post by briuz »

For my CNC lathe I am building with a 16 position lathe turret, I used a hall effect sensor to find the home position. A magnet on the back of the turret triggers the sensor.

The wiring diagram I used is 1/2 way down this page: https://maker.pro/arduino/tutorial/how- ... th-arduino
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 possition lathe turret

Post by briuz »

Homing macro code for my lathe turret:

N100 ;Check for open home switch
IF !#[50000 + #9822] THEN M225 #100 "HomeAll switch tripped!!!\nPlease clear before Homing.\n\nPress Cycle Cancel to end Homing"
IF !#[50000 + #9822] THEN GOTO 100

;Disable all limits
M94 /101 /102 ;/103 /104

;Perform Homing commands
M92/Z L1
M26/Z
M92/X L1
M26/X
;M92/B L1
M26/B ; temp
;M91/A L1

; Home Turret
M40 ; Set custom tuning variables for lathe

G98 ; Set feedrate to inches/minute
M65 ; Turn on solenoid to raise paw
G01 A[#5044 - #157] F360 ; Rotate turret #157 degrees to disengage paw. #5044 is current position of A axis.
M105 /A P-5 F720 ; Rotate turret at 720 degrees per minute until sensor detects magnet.
G00 A[#5044 + #158] ; Rotate turret to zero offset.
M26/A ; Set A axis (turret) to zero degrees.
G01 A[#5044 - #157] F360 ; Rotate turret #157 degrees to engage paw. #5044 is current position of A axis.
M85 ; Turn off solenoid to lower paw.
G01 A0 F360 ; Lock paw in position.


;Enable all limits
M95 /101 /102 ;/103 /104
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 possition lathe turret

Post by briuz »

M40 Macro code:




;------------------------------------------------------------------------------
; Filename: mfunc40.mac
; Set Tuning Variables
; Description:
; Notes:
; Requires:
; Please see TB300 for tips on writing custom macros.
;------------------------------------------------------------------------------

IF #50010 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching

N100 ;Insert your code between N100 and N1000

#157 = 15 ; Offset to raise/lower turret paw
#158 = 7.3 ; Turret Offset To Home Zero Position
;#158 = 4.6 ; Turret Offset To Home Zero Position

N1000 ;End of Macro
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 possition lathe turret

Post by briuz »

;Tool Change Macro
;

IF #50010 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 9999 ;Skip macro if graphing or searching

;IF #9006 != 0 THEN GOTO 200
;M225 #100 "Please Change to Tool Number %.0f\nThen Press Cycle Start to continue" #4120



; Variable Reference Table
;
;
; #100 -- Temporary Math
; #101 -- Temporary Math
; #105 -- Debugging Tool Number
;
; #157 -- Turret Offset To Raise/Lower Paw
;
;
;
; #4120 -- Tool Number
; #5044 -- Turret Axis Position In Degrees
;
; #29000 -- Value Passed To Sub Program
; #29001 -- Return Value From Sub Program

M40 ; ; Set custom tuning variables for lathe.
;#157 = 25 ; DEBUGGING SET OFFSET TO RAISE/LOWER PAW


N200

G98 ; Set feedrate to inches/minute


O9100 ; IsNumberEven()

;M225 #100 "IsNumberEven"

; Note: Even numbered tools are standard 3/8" tooling and odd numbered tools are round such as drills, taps, reamers, and round tool steel.
; #29000 -- Number To Check
; #29001 = 0 If Even and 1 If Odd

#100 = [#29000 % 2] ; Get remainder of number (#29000) and place in #100

#29001 = 0
IF [#100 > 0.0] #29001 = 1

M99

;M225 #100 "test"



O9200 ; CalculateEvenToolPosition()

;M225 #100 "CalculateEvenToolPosition"

; Even tool positions are for square lathe tool bits and carbide tool holders.
; Gets the tool number from #29000
; Returns new turret position (in degrees) in #29001

#100 = [#29000 - 1] ; Tool calculations are zero-based. i.e. Tool 1 is 0, Tool 2 is 1, etc.
;#101 = [#100 * 22.5] ; Each odd tool is 45 degrees apart.
;#29001 = [#101 - 18] ; Subtract from the odd tool to find the even tool. (Is it 27 degrees or 18 degrees?)

#101 = 27; ; Difference, in degrees, from odd tool position. (27 or 18)

; Hard-code turret positions to prevent floating point errors building up in math.
IF [#100 == 1] #29001 = [0 + #101]
IF [#100 == 3] #29001 = [45 + #101]
IF [#100 == 5] #29001 = [90 + #101]
IF [#100 == 7] #29001 = [135 + #101]
IF [#100 == 9] #29001 = [180 + #101]
IF [#100 == 11] #29001 = [225 + #101]
IF [#100 == 13] #29001 = [270 + #101]
IF [#100 == 15] #29001 = [315 + #101]



M99



O9300 ; CalculateOddToolPosition()

;M225 #100 "CalculateOddToolPosition"

; Odd tool positions are for round tooling such as drills, taps, reamers, and round tool steel.
; Note: Tool #1 is round and will be at zero degrees.
; Gets the tool number from #29000
; Returns new turret position (in degrees) in #29001

#100 = [#29000 - 1] ; Tool calculations are zero-based. i.e. Tool 1 is 0, Tool 2 is 1, etc.
;#29001 = [#100 * 22.5] ; Each odd tool is 45 degrees apart.


; Hard-code turret positions to prevent floating point errors building up in math.
IF [#100 == 0] #29001 = 0
IF [#100 == 2] #29001 = 45
IF [#100 == 4] #29001 = 90
IF [#100 == 6] #29001 = 135
IF [#100 == 8] #29001 = 180
IF [#100 == 10] #29001 = 225
IF [#100 == 12] #29001 = 270
IF [#100 == 14] #29001 = 315

M99



O9400 ; RaisePaw()

;M225 #100 "RaisePaw"

#100 = [#5044 - #157] ; Calculate the new turret position to raise the paw.

;M225 #100 "Number %f" #100

M65 ; Activate the solenoid.
;G01 A[#100] F360 ; Slowly rotate the turret to the raised paw position.
G00 A[#100] ; Rotate the turret to the raised paw position.

M99



O9500 ; LowerPaw()

;M225 #100 "LowerPaw"

#100 = #5044 ; Store the current turret position.
#101 = [#5044 - #157] ; Calculate the raised paw position.
G00 A#101 ; Rotate the turret to the raised paw position.
M85 ; Release the solenoid.
G01 A[#100] F360 ; Rotate the turret back to the tool position.
M99


; main()

; To change the tool, raise the paw, see if the new tool is odd or even, calculate the new position, move to the new position, then lower the paw.

M98 P9400 ; RaisePaw()

#29000 = #4120 ; Set #29000 to the tool number

M98 P9100 ; IsNumberEven()

IF [#29001 == 0] M98 P9200 ; If the tool number is even, CalculateEvenToolPosition()
IF [#29001 == 1] M98 P9300 ; If the tool number is odd, CalculateOddToolPosition()

G00 A#29001 ; Rotate turret to new tool position

M98 P9500 ; LowerPaw()





N9999
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 possition lathe turret

Post by briuz »

On my turret, the turret is locked by a paw that is pulled up by a solenoid. So, before a move, the solenoid is activated and the turret is rotated to allow the solenoid to be completely disengaged. Then, the turret is rotated to the new position, the turret is rotated a little farther so the solenoid will engage the turret, the solenoid is released, then the turret is backed up to the tool position.

The turret itself is rotated by a stepper motor that has a 1:1 ratio with the turret.

The tool locations are spaced out by an unusual number of degrees so as to allow for so many tools in such a small space. Because of the spacing, all the turret tool locations are hard-coded in the macro code. I considered calculating them out mathematically but decided against it as floating point math will slowly loose it's precision due to rounding errors.

Let me know if you have any questions.
cnckeith
Posts: 7313
Joined: Wed Mar 03, 2010 4:23 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: Yes
CNC11: Yes
CPU10 or CPU7: Yes
Contact:

Re: Help needed on the best way to control a 8 possition lathe turret

Post by cnckeith »

cool!

A starting place is the beta Lathe turret PLC programs.. here is the link to the thread..
viewtopic.php?f=63&t=1340

and the link to all the beta ATC programs with instructions.
https://www.centroidcnc.com/centroid_di ... ograms.zip

atc programs.PNG
Need support? READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043
All Acorn Documentation is located here: viewtopic.php?f=60&t=3397
Answers to common questions: viewforum.php?f=63
and here viewforum.php?f=61
Gear we use but don't sell. https://www.centroidcnc.com/centroid_di ... _gear.html
jumps4
Posts: 143
Joined: Wed Oct 10, 2018 8:37 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 38d2697ca033-0611180974 mpu12
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: New Port Richey, Fl. USA
Contact:

Re: Help needed on the best way to control a 8 position lathe turret

Post by jumps4 »

thank you for your replies
I have ordered some parts:
10 - Opto-Interrupter Speed Detection Modules lm393 chips
lm393 motor pickup.rtf
(1.47 MiB) Downloaded 178 times
2- NOYITO PC817 4-Channel Optocoupler Isolation Board Voltage Converter Adapter Module 3.6-30V Driver Photoelectric Isolated Module 10 - HY805 Optical Sensor Switch
pickup.rtf
(1.8 MiB) Downloaded 164 times
I'm planning to replace the Optical Sensors on the lm393 boards with the hy805 sensors. they have a high accuracy and will be remote mounted then wired into the lm393 boards. (after note: soldering to the boards destroyed them. I had to use a tweezers as a heat sink and solder to the original pins)
Then the output of the 4 lm393 boards will go to the NOYITO PC817 4-Channel Optocoupler to protect the acorn board and switch 4 inputs for gray logic. ordering pre-made boards saves me from trying to make my own board and they are cheap.
I can also use them in the same way for x and z home switches. I read they are accurate to .002 mm.
That is the plan for electronics I'll post my wiring diagrams if the magic smoke stays in.
thank you for your ideas again
I'm sure I'll have a lot of questions to go
Steve
Attachments
1.jpg
motor-speed-sensor-module-circuit.png
3.jpg
3.jpg (9.23 KiB) Viewed 5298 times
2.jpg
pickup.rtf
(1.8 MiB) Downloaded 157 times
Last edited by jumps4 on Sat Sep 14, 2019 2:36 pm, edited 1 time in total.
No Brains, No Headaches...
jumps4
Posts: 143
Joined: Wed Oct 10, 2018 8:37 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 38d2697ca033-0611180974 mpu12
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: New Port Richey, Fl. USA
Contact:

Re: Help needed on the best way to control a 8 position lathe turret

Post by jumps4 »

does this look right?
here is my plan for sensor disk with 3 notches and 4 sensors to use gray logic.
the turret is in front of the axis and this is facing the back of my turret where sensors will be mounted.
the squares are sensors the numbers are acorn inputs (any available input numbers can be used if edited in the code)
this should leave me with 3 inputs left
x and z home in series
e-stop
and a input for x z closed loop error fault stop



tool 1 logic is 1001
tool 1.JPG
tool 1.JPG (15.26 KiB) Viewed 5289 times
tool 2 logic is 1000
tool 2.JPG
tool 3 logic is 1100
tool 3.JPG
tool 4 logic is 0100
tool 4.JPG
tool 5 logic is 0110
tool 5.JPG
tool 5.JPG (15.83 KiB) Viewed 5289 times
tool 6 logic is 0010
tool 6.JPG
tool 7 logic is 0011
tool 7.JPG
tool 8 logic is 0001
tool 8.JPG
No Brains, No Headaches...
briuz
Posts: 127
Joined: Wed Jul 10, 2019 9:24 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Help needed on the best way to control a 8 position lathe turret

Post by briuz »

Programmed right, you can make that work. But you really only need one signal to find the home position. The other positions can be located by just rotating 45 degrees for each position.
Post Reply