Hello Guest it is April 26, 2024, 04:02:58 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Havoc340

Pages: 1
1
I just found all of your replies right now, and wanted to say thank you!

It's late for me right now but I'll be going over all of this in the next day or two and report back!

2
I expected the turret to need to home, and cycle once to index itself to the first tool. This happens once the turret has been indexed and the first position established. Then if there was a way to keep track of the state the whole time mach4 was running on the computer (I expect it already does) then the turret would not need re-homed any more than the X or Z axis do.

I am also trying to understand the way you have worded your IF's.
I think I can simplify my explanation of the turret operation.

In order to advance the turret, you must turn Output 1 AND 2 ON simultaneously.
In order to lock the turret into place, Output 1 must be on, for 10 seconds by itself, with Output 2 OFF.  When output 1 is on by itself, the turret rotates backwards and locks against a ratchet pawl.
After the 10 second timer is met, Turn Output 1 Off. At this point, Outputs 1 and 2 are off and the turret is disabled.

To index the turret:
When it is time to home/index advance the turret, you will want to turn OUT1 and OUT2 on simultaneously.
When Input 2 (Index Input pulse) goes active, Turn off OUT2. wait 10 seconds. Turn off OUT1.
The turret is now indexed in the first position.

After the turret is indexed and home, this is what needs to happen for a complete tool change:
When a tool is called and it is time to advance the turret, you will want to turn OUT1 and OUT2 on simultaneously.
When Input 1 (Tool position pulse) goes active, Turn off OUT2. wait 10 seconds. Turn off OUT1.
The turret is now in the next consecutive tool position.

 Now that I know we have states to work with, I figured we would be giving each tool position it's own state. Having the "dead spot" state between tools would help "ratchet" the program through the states, ticking them up through the input changes.  That is how I am thinking about the program.  

 

Without knowing the intricacies of Lua structuring of things, and what needs to happen for something to happen I will say that however it ends up working is fine with me.


And thank you again for your time Craig! I know I am going to end up learning a ton from the way we are doing this. Seeing the way the code is put together to accomplish this task will give me a ton of insight how to get going with other macros. Maybe I'd even get the confidence to retrofit my other machine with a tool changer. I'd love to add a 4th axis to it, but the only way that happens is if I retrofit.

3
I don't know how to store a state, but I am not totally new to state based programming. I didn't realize that this is what Mach4 uses. As I am reading and re-reading your posts I think it's starting to sink in just a little.

I think I could get by with something like this, just in the right language.

To index all six postitions something like this might work:

If input (the tool pulse) 1 is on, and input 2 (turret index) is on State =0 (Tool 1)
If Input 1 is on, and input 2 is off and state =0, change state to 1 (tool 2)
If Input 1 is off, and input 2 is off and state =1, change state to 2 ( I think a "dead state" may be nessicarry to prevent cycling/looping through all states automatically once the input/outputs are triggered).
If Input 1 is on, and input 2 is off and state =2, change state to 3 (Tool 3)
If Input 1 is off, and input 2 is off and state =3, change state to 4
If Input 1 is on, and input 2 is off and state =4, change state to 5 (Tool 4)
If Input 1 is off, and input 2 is off and state =5, change state to 6
If Input 1 is on, and input 2 is off and state =6, change state to 7 (Tool 5)
If Input 1 is off, and input 2 is off and state =7, change state to 8
If Input 1 is on, and input 2 is off and state =8, change state to 9 (tool 6)
If Input 1 is off, and input 2 is off and state =9 change state to 10
If Input 1 is on, and input 2 is on and state =10, change state to 0 (reset to state 0, and tool 1)

Tool Request is translated into state request. So if the machine is currently in state 0, and tool 1 is requested the machine checks the state (T1 State=0) and does nothing.
If tool 5 is requested the macro translates that into needing the machine to be in state 7. Since the machine is in state 0, it turns on two outputs simultaneously Lets call them output 1 and output 2. Output one is an enable relay that energizes the turret. Output two is the signal for the turret to move.

**How this turret works mechanically**
 When this turret is energized (output 1 on), it automatically moves in reverse and locks into position against a ratchet pawl. When the turret gets the "advance" signal (output 2), it moves forward. The ideal situation turns both the turret on, and then energizes it for a forward move. Once it is in position, turn off output 2. it will automatically reverse and lock into position. After a set time, turn off output 1 so the motor isn't constantly powered.


Once the outputs are turned on, the turret starts to move. As it moves it will be triggering the index and pulse "encoder signal", subsequently changing the states.

Once the turret is in the requested state 7 (Tool 5) position, it shuts off output 2 (the turret move signal) and then 10 seconds later it shuts off the output 1, de-energizing the turret motor.

Then if the state = the state requested by the m6, it exits the macro. Maybe it should store the current state. I am not sure. Or when we home the machine upon power up, the turret indexes to tool 1. I am not sure if or how states are stored however if we can save the current state it would prevent the need to cycle the turret through to state 0 and count up from there.

I know this is a long way from an actual program however I feel it is a solid outline of the macro. I just need the correct jargin.


4
Craig, you were right. I was completely confused. I had tried to dig a little more through the initial information in the lua manual and got frustrated.

From there, my mach4 pc was a huge turd, and with other things going on in life I just put it on the back burner. Now I'm ready to take another crack at it.

I hadn't noticed your replies until now. I'm reading what you have posted and re-reading it. Hopefully it starts making some sense.

As for the "encoder" on the tool turret, it is just pulse indexing. As each tool is indexed, a pulse is sent. As tool 1 is indexed, a separate signal pulse is sent as well. So it's like an encoder but it's not technically. It operates in this order through the turret rotation:

Tool: Input 1, Input2

 Tool 1: 1-1
Moving: 0-0
 Tool 2: 0-1
Moving: 0-0
 Tool 3: 0-1
Moving: 0-0
 Tool 4: 0-1
Moving: 0-0
 Tool 5: 0-1
Moving: 0-0
 Tool 6: 0-1

5
Super quick haha.

So to break it down...

How do I define inputs and outputs in Lua?
I need to turn an output on "output 1" and then wait for encoder pulses.
How do I count? I would like to be able to index tool 1 and save it's position, then increment from there on each tool pulse.
Once the correct tool is reached, I need to turn off that output.

It would be nice to store the current tool location so the next tool change from T2 to T3 does not need to cycle all the way through to T1, and then count to 3... but honestly if it works I'll deal with it.

Then I need to be able to exit the macro telling MACH that the correct tool is loaded.

That is pretty much the jist of it.

6
Thanks for the replies!

Tom, that is an idea for sure!

Craig,  I can totally appreciate your process of helping me learn vs doing it for me. I am willing to learn however I'm a slow learner with the code.

If it were Arduino, I could hobble something together just fine. I know what needs to happen in the tool change process, I just do not know the Lua words. There are easily defined tutorials. With Lua everything I have come across is to create programs, and user interfaces, and way more technical stuff. None of the terminology makes any sense, and the tutorials go straight into randomization, UI, etc... and none of it really is pertaining to my issue. I have looked for other tool changer examples and haven't found any I can work from.

7
VB and the development of wizards / Re: Emco Turn tool changer macro
« on: September 20, 2018, 04:20:33 PM »
Aju, just a heads up! Your power input is backwards on that diagram. I found out when the capacitor on the board blew up haha.

8
Ok, so my brain is not working like it used to. I haven't even heard of Lua before today. I have a macro from Mach3 that does exactly what I need it to, however since I'm runing a pokeys57u on my lathe, and want all of the features... I'm going to need to resort to Mach4.

Can someone please help me out?

Here is a Macro I found for Mach3 to control the PCturn Turret, using the factory internal encoder setup. I have everything wired up and mechanically ready to test.


The thread is short, but http://www.machsupport.com/forum/index.php/topic,16685.0.html is my source.

****************************************************************************************************************************************************

'M6Start.M1s
'Input1 is an optical sensor used to count tool positions
'Input2 is from a microswitch used to determine tool 0 position
'OUTPUT6 drives the tool changer forward, de activating it allows the tool changer to rotate back against the ratchet pawl at low power and is the default
'Un comment the Open statement, various write# statements and the close# function to write a logfile for diagnostic purposes

'Close #1
'Open "M6start_log.txt" For Output As #1 'open a file to write logs to
NewTool = GetSelectedTool()
'NewTool = 2
'Write #1, "NewTool ", NewTool
OldTool = GetCurrentTool()
'Write #1, "OldTool ", OldTool
MaxToolNum = 6 'Max number of tools for the changer
CurrPos = OldTool

While (NewTool > MaxToolNum)
    NewTool = Question ("Enter New Tool Number up to " & MaxToolNum)
Wend

    'there is nothing to do so we just exit
If (NewTool = OldTool) And (NewTool > 0) Then
   'Write #1, "New tool number is the same as old tool number. Nothing to do "
       Exit Sub
End If

'If OldTool is 0 that means we dont know where the tool changer is currently positioned and need to reference to the microswitch for tool 1 position.
    'need to establish tool 0 position from microswitch
If (OldTool = 0) Then
   'Write #1, "Old tool number is zero, looking for reference position"
   ActivateSignal(OUTPUT5)' Set toolchanger for full speed move
        'Write #1, "Activated Output 5 to enable toolchanger motor"
        ActivateSignal(OUTPUT6)' rotate tool changer forward
        'Write #1, "Activated Output 6 to set forward direction"
    While Not IsActive(INPUT2)
    Wend
    ' Input 2 must Now be active so the microswitch has been triggered at position 1
    CurrPos = 1
    'Write #1, "Reference position found "
    ' Decide whether to just stop for the normal toolchange process
    If ( CurrPos <> NewTool) Then
       DeActivateSignal(OUTPUT6)
       DeActivateSignal(OUTPUT5)
    Else
    ' Or if we actuallly wanted tool 1 then stop and lock
           DeActivateSignal(OUTPUT5) 'stop rotating forward, rotate backward now
      'Write #1, "DeActivateSignal Output 5 toolchanger reverse "
           SetCurrentTool(NewTool) 'sets up the current tool variable as the start point for a future tool change
           'Write #1, "Setting CurrentTool to NewTool value ", NewTool
           Sleep(2500) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
           'Write #1, "Waited 2.5 seconds for toolchanger to lock "
           DeActivateSignal(OUTPUT6) 'Disable toolchanger motor
           'Write #1, "DeActivateSignal Output 6 toolchanger stop "
    End If
End If

If (CurrPos <> NewTool) Then 'write the start condition to a variable
   If IsActive(INPUT1) Then
      PreviousSensorState = "Active"
   Else
      PreviousSensorState = "Inactive"
   End If
   'Write #1, "PreviousSensorState =", PreviousSensorState
   ActivateSignal(OUTPUT5)' Set toolchanger for full speed move
          'Write #1, "ActivateSignal Output 6 toolchanger go"
        ActivateSignal(OUTPUT6) 'start rotating forward
        'Write #1, "ActivateSignal Output 5 toolchanger forward "
       While CurrPos <>  NewTool
          'Some logic to ensure that we only count on the leading edge of a slot in the toolchanger optical disk
           If IsActive(INPUT1) Then
              SensorState = "Active"
           Else
              SensorState = "Inactive"
           End If
           'Write #1, "SensorState =", SensorState
           If SensorState <> PreviousSensorState Then
              If SensorState = "Inactive" Then
                 CurrPos = CurrPos +1
                 If CurrPos = 7 Then
                    CurrPos = 1
                    'Write #1, "CurrPos reached 7, reset to 1 "
                 End If
              End If
              'Write #1, "CurrPos =", CurrPos
              PreviousSensorState = SensorState
           End If
           If CurrPos = NewTool Then
                 DeActivateSignal(OUTPUT5) 'stop rotating forward, rotate backward now
                 'Write #1, "DeActivateSignal Output 5 toolchanger reverse "
                 SetCurrentTool(NewTool) 'sets up the current tool variable as the start point for a future tool change
                 'Write #1, "Setting CurrentTool to NewTool value ", NewTool
                 Sleep(1500) 'Allow a time interval for the toolchanger to settle back against the ratchet pawl
                 'Write #1, "Waited 1.5 seconds for toolchanger to lock "
                 DeActivateSignal(OUTPUT6) 'Disable toolchanger motor
                 'Write #1, "DeActivateSignal Output 6 toolchanger stop "
           End If
           sleep(200) ' just slows the iterations down a bit
           'Write #1, "Waited 0.2 second "
       Wend
       'Write #1, "should be job done "
       'Close #1
End If   


If you don't know what is going on above, but know Lua somehow... I have a 6 position turret. There are 2 "encoders" in it. One pulses each tool, and the other pulses on tool 1. A single output turned on advances the tool. When the output is turned off, it will automatically lock into place.

Any help would be greatly appreciated! Thanks!
-Bob

Pages: 1