Hello Guest it is March 28, 2024, 11:15:01 AM

Author Topic: lathe turret macro  (Read 10428 times)

0 Members and 1 Guest are viewing this topic.

Offline Monty

*
  •  116 116
    • View Profile
lathe turret macro
« on: October 30, 2009, 11:09:40 PM »
I'm trying to move an axis motor from a macro.

The end goal is a macro to run my turret which I will post when it is a little further along.

I need to be able to do a rapid one way until a sensor trips and then reverse until another sensor trips.

What is the easiest way to do this? I know I can use G0 but then how to trip it? This is event driven not a distance thing.

Can I just use the oem scan code for fast jog?

Something like:

rapid +Y  'move Y in + direction

while a = 1
a = GetOemTrigger(1)
wend

stop Y 'stop Y axis

rapid -Y  'move Y in - direction

while b = 0
b = GetOemTrigger(2)
wend

stop Y  'stop y axis

end

Monty

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: lathe turret macro
« Reply #1 on: October 31, 2009, 04:18:29 PM »
Have a look at the command IsActive(INPUTx) to check a pin within an incremental loop of short rapid moves.

Graham
Without engineers the world stops

Offline Monty

*
  •  116 116
    • View Profile
Re: lathe turret macro
« Reply #2 on: October 31, 2009, 08:20:21 PM »
Thanks Graham,

I fooled around with this all day and finally got it to work acceptably. I don't know if how I did this is the easiest or cleanest way, but it works repeatably.

I still have to add all the logic for looking at the encoder. I also have to add error checking plus determining which way to turn and how many stations.

But it's a start!!  ;D

The formating is a little screwed up for some reason, and it keeps jumping around in the text window on the forum. I'm too tired to pretty it up. It should be clear enough to read.

'Inputs are as follows:
 '
'
'OEMTRIG1 = Encoder Bit 1
'OEMTRIG2 = Encoder Bit 2
'OEMTRIG3 = Encoder Bit 3
'OEMTRIG4 = Encoder Bit 4
'OEMTRIG5 = Parity Bit
'OEMTRIG6 = Strobe1
'OEMTRIG7 = Strobe2
'OEMTRIG8 = Index Proximity Switch
'OEMTRIG9 = Lock Proximity Switch
'OEMTRIG10 = Door Switch
'
'
'Outputs are as follows:
'
'
'OUTPUT10 = Lock Solenoid
'
'   
DoOemButton(138)         'Go home       
While IsMoving()         'wait for movement    
Wend            'to end     


For I = 1 To 18         'Slow jog is needed    
DoOemButton(112)         'for extra torque
Next I                  


DoOemButton(310)         'Rotate Turret CW (axis Y-) 
sleep (500)            'Turn for .5 sec 
DoOemButton(1003)         'Stop Motor   


For I = 1 To 18         'Back to Fast jog    
DoOemButton(111)
Next I 


DoOemButton(310)         'Rotate Turret CW (axis Y-)       

For I = 1 To 5         'Count number of stations     

While Strobe1 = 0         'Wait for Strobe1 to go high       
If IsActive(OEMTRIG6) Then       
Strobe1 = 1       
Else       
Strobe1 = 0       
End If    
Wend        

While IsActive(OEMTRIG6)      'Look for Strobe1 to go low    
Wend            'Number of Srobe1 falls =                   
                                                                'Number of stations

Strobe1 = 0    
Next I 

ActivateSignal(OUTPUT10)         'Energize lock solenoid 

LockProx = 0 

While LockProx = 0            'Look for Lock Proximity Switch
   If IsActive(OEMTRIG9) Then      'to go high
    LockProx = 1
   Else
    LockProx = 0
   End If
Wend 
DoOemButton(1003)            'stop motor 
Sleep(100)               'wait for damping 

For I = 1 To 18               'slow jog    
DoOemButton(112)         'for increased torque
 Next I 

DoOemButton(309)            'Reverse Motor
  sleep (200)               'Turn for .2 sec
  DoOemButton(1003)            'Stop Motor
 For I = 1 To 18               'Fast Jog    
DoOemButton(111)
 Next I
  DoOemButton(309)            'Reverse motor
 While IndexProx = 0            'Look for IndexProx to go high
   If IsActive(OEMTRIG8) Then      'IndexProx must complete
   IndexProx = 1         'OFF-ON-OFF
   Else
   IndexProx = 0
   End If
Wend
  While IsActive(OEMTRIG8)         'Look for IndexProx to go low
Wend
 DoOemButton(1003)            'Stop motor   
  sleep(200)
 DeActivateSignal(OUTPUT10)         'De-Energize Lock Solenoid
                            'Now in position

Offline Monty

*
  •  116 116
    • View Profile
Re: lathe turret macro
« Reply #3 on: November 02, 2009, 05:29:45 PM »
In an effort to help anybody else in the world who may be crazy enough to install a Dorian PowerDex turret under Mach3 control, I am posting my Macro.

The Turret that I have was a FleaBay purchase that had a bad motor in it. So I replaced it with a stepper I had on hand. If you are using the stock motor, You will have to add some code to control the motor brake and the AC servo. This can be a simple Run, Direction relay setup, controlled through outputs. You can delete all the motor control logic I had to use to get the stepper to work. The rest of the control logic should work. The stock AC servo will be faster, and should be easier to control.

I apologize for the sloppy logic. I'm sure somebody more in tune with VB could condense things a bit.

The M6start macro does the changing, and the M6end checks to make sure the change was done properly. You will be helped in understanding this macro if you have the .pdf programing guide from Dorian. Be aware that there is a typo on page 4 in the second column. They have transposed Index and Lock proximity in the operation description. The motor should be stopped when the Lock prox goes high, not the index. The index prox is used to detect when to stop after the motor reverses.

I have tested this on my machine and it appears to work well, however, I assume no responsibility whatsoever for this code. You are solely responsible if you use it to do anything. Assume I am a complete idiot......to do otherwise would be foolhardy. ;)

YOU HAVE BEEN WARNED!!!

Offline Monty

*
  •  116 116
    • View Profile
Re: lathe turret macro
« Reply #4 on: January 31, 2010, 12:55:01 PM »
Just a note to anybody who downloads this. I have had a chance to run it a lot more and find bugs. The biggest problem is I did not put any code in there to check for missed events. For instance if you have your debounce set much over 100 you my have problems seeing the strobe falls. This can cause the turret to keep rotating around past the desired tool station. It may detect the strobe fall on another station and incorrectly position the turret. Fortunately this is found when the macro checks to see if the selected tool matches the final position and it does throw an error. To make it more robust there should be some code to deal with this and rotate to the desired position. Also I need to fix the logic around the tool change when you are selecting for the same tool, but with a different offset. I would also like to add a homing routine if the turret is out of position. Right now I just do it manually by some LEDs on the diagnostics page.

Those are the major things that need to be fixed. I'm currently trying to get a lot of other bugs worked out and this is low on my list of things to do. I'll probably wait until after mach 4 is released so I can update it for that. I should also tidy up the logic and make the position checking a sub routine. I took the lazy cut and paste approach.

Monty
Re: lathe turret macro
« Reply #5 on: April 06, 2010, 12:08:57 PM »
Hi ,
I'm finish installing mach3 and new geckos drives in my dina3000 lathe, and is working great, but i have a problem with the six tool turret, i like to know if some one can help me with this matter. I don't know any vb o macro programing. Any help will be greatly appreciated thanks.
Re: lathe turret macro
« Reply #6 on: April 06, 2010, 12:48:45 PM »
Hi

Quote
I'm finish installing mach3 and new geckos drives in my dina3000 lathe

If you mean a Dyna 3000 lathe, the link below will give you the names of 4 people who seem to have the same lathe, they should be able to help you.

http://www.machsupport.com/forum/index.php/topic,5480.0.html

Otherwise you will have to give some info as to exactly what the turret comprises of, how it indexes and locks etc. etc.

regards

ArcEye
Re: lathe turret macro
« Reply #7 on: April 06, 2010, 02:18:02 PM »
thanks for you reply, I installed an stepper motor running as rotary A thru pins 7 - 8, 360 degrees 6 tools, there is an optical home at tool 1, and a solenoid to open and lock the tools turret, am using output #8 for the solenoid. Please let me know if you need more information. Thanks
Re: lathe turret macro
« Reply #8 on: April 07, 2010, 04:02:36 AM »


Do Kaderick, Dave Mauch or DennisCNC not already have a tool change macro or is your lathe not a Dyna 3000?

If it a Dyna 3000 have you seen this link?  The guy who converted it has already got toolchange with Mach and appears to be involved in a CNC company

http://www.romaxxcnc.com/dyna3000.html

If the 'not re-inventing the wheel' tack does not work, come back to the forum and someone will be able to help.

regards

ArcEye