Hello Guest it is March 19, 2024, 02:11:06 AM

Author Topic: Machine setup help - urgent if possible :)  (Read 12276 times)

0 Members and 1 Guest are viewing this topic.

Offline mc

*
  •  382 382
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #20 on: July 24, 2016, 05:12:17 PM »
You obviously quoted me before my sly edit. It's the S/Speedchange macro you need to edit, not the M6 for the spindle speed.

You'd need to check in what order the scripts get run, especially if both M3 and S are on the same line.
As long as they don't both get called simultaneously, you could essentially have identical code in both to test for the correct gear, so even if the M3 gets called before the speed change, the M3 macro will of already done the gear checking, so by the time the spindle speed macro is called, it just checks for the correct gear and then sets the VFD as required.
Then on just a speed change, the spindle speed macro will handle the gear change.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #21 on: July 25, 2016, 02:23:19 AM »
Yeah, i tried messing with the M3 way back but it does not read the speed correctly and does very odd things, cant recall exactly what happened now but its all in my main conversion thread, it didn't work anyway which is what lead me to the spindlespeed macro which worked better but I still have this issue where it says do this or that but does not give you a chance to actually do it :)

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #22 on: July 25, 2016, 04:40:50 AM »
This is my current spindle speed.m1s code, so far it warns me to either change the mechanical speed dial (this must be done with spindle running) OR change back-gear (must be done with spindle off) and speed dial as well.

It needs to somehow tell Mach to not process G-code as well as stop the spindle at certain combinations of speed/pulley. I guess a manual spindle start is ok.

Can this be done, I'm beginning to think i should have just used the cash and fitted a servo spindle :(

Code: [Select]
rpm = GetRPM()
pulley = GetOEMDRO(56)

Select Case rpm
case 0 To 126
  If pulley <> 1 then
    Call SetOEMDRO(56,1)
    if pulley = 2 then
      MachMsg ("Change Speed Dial To 700rpm","Wrong Speed Range",0)
    else
      MachMsg ("Change Back-Gear To Low Range And 700rpm","Wrong Speed Range",0)
    end if
  End If
Case 127 To 366
  If pulley <> 2 Then
    Call SetOEMDRO(56,2)
    if pulley = 1 then
      MachMsg ("Change Speed Dial To 2200rpm","Wrong Speed Range",0)
    else
      MachMsg ("Change Back-Gear To Low Range And 2200rpm","Wrong Speed Range",0)
    end if
  End If
Case 367 To 1031
  If pulley <> 3 Then
    Call SetOEMDRO(56,3)
    if pulley = 4 Then
      MachMsg ("Change Speed Dial To 700rpm","Wrong Speed Range",0)
    else
      MachMsg ("Change Back-Gear To High Range And 700rpm","Wrong Speed Range",0)
    end if
  End If
Case 1032 To 3000
  If pulley <> 4 Then
    Call SetOEMDRO(56,4)
    if pulley = 3 Then
      MachMsg ("Change Speed Dial To 2200rpm","Wrong Speed Range",0)
    else
      MachMsg ("Change Back-Gear To High Range And 2200rpm","Wrong Speed Range",0)
    end if
  End If
Case 3001 To 99999
  Call SetOEMDRO(56,4)
  MachMsg ("Speed Limited By Machine, Check Code, Change Back-Gear To High Range And 2200rpm","Wrong Speed Range",0)
End Select

SetSpinSpeed( rpm )

Offline mc

*
  •  382 382
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #23 on: July 25, 2016, 05:06:12 PM »
The problem with your current code, is there is nothing to stop motion. It simply displays whatever message, then continues on it's way.
Within the If Else statements, you'll need to call a feedhold prior to displaying the message, so that motion is physically stopped. Once you get that working, you could then expand it to stop the spindle if needed, and then restart in whatever direction you need.

What I'd suggest before you try editing/adding to the code, is create a flow chart of the process, so that you know exactly what the process is, before you start coding anything. That way you're simply converting from flow chart to code, and not trying to figure out the process at the same time as trying to code it.

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #24 on: July 26, 2016, 02:13:20 AM »
Ok, thanks

so it sounds like it will be possible to do what i want, what is the correct way to code a feed-hold in a macro?

Would it be just DoOEMButton (1001)

with maybe Code "M05" to stop the spindle ?

Flowchart sounds good, but i do have a pretty good idea of what is needed anyway, just unsure how to achieve it :)

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #25 on: July 26, 2016, 02:32:44 AM »
I usually use msgbox"" for this so that you know what is going on and have to respond and then have the macro do a stop and exit, here is a snippet from the toolchange macro I just did for a friends lathe.

If AxisPosition = TurretAngle Then                    'Check that the A Axis DRO is the same as the Turret Angle derived from Prox's
 Message "Toolchange Complete"                         ' If it is then show message in ticker saying toolchange complete
   Else
   MsgBox"Toolchange Failed!!  Programme stopped!!"    'If it is not then pop up message warning
   DoOemButton(1003)                                   'Press Stop button
   End If



Hood

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #26 on: July 26, 2016, 02:36:44 AM »
That snippet was right at the end of the macro so it would exit anyway but if it was earlier then you would have to have an End before the End If so that it exits the macro right away.
Snippet from earlier in the same macro.

If XHomed = True or ZHomed = True Then                'Check to see if X and Z are NOT homed
  MsgBox " Please home axes before tool call"       'Message to say not homed
  DoOemButton(1003)                                     'Stop Code
   End                                                  'Exit macro
   End If

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #27 on: July 26, 2016, 02:37:38 AM »
Ok, my manual does not list the msgbox function, what is the difference between msgbox and machmsg ?? They both seem to display message boxes.

;)

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #28 on: July 26, 2016, 02:39:34 AM »
Not a clue, never used MachMsg.

Hood

Offline Davek0974

*
  •  2,606 2,606
    • View Profile
Re: Machine setup help - urgent if possible :)
« Reply #29 on: July 26, 2016, 02:41:02 AM »
Hmm, ok, maybe need a newer macro manual. Msgbox is a visual basic style call.

Will have a play when i get the encoders wired properly.