Hello Guest it is April 25, 2024, 04:28:46 AM

Author Topic: ismoving() error message  (Read 7910 times)

0 Members and 1 Guest are viewing this topic.

Offline rufan

*
  •  38 38
    • View Profile
ismoving() error message
« on: July 20, 2013, 02:06:21 PM »
During the toolchange the Z-axis needs to move to Z130 position but I got a ismoving() error message. See Sub MoveZ
This only happens when the routine: '-----If spindle RPM =0 and not Aligned ----- '  and   '----- If spindle RPM > 10 and not Aligned ----'  are executed
If routine '----- If spindle RPM =0 and Aligned ----' is used every thing works perfect.

Already tried this but does not help
While ismoving            While ismoving()
Wend                        Wend     

While ismoving            While ismoving
sleep 10                     Sleep 10
Wend                        Wend

I have no idea what is causing the problem, any suggestion.

This is a part of the code:
Sub AlignSpindle

'-------------------- If spindle RPM =0 and Aligned -------------------------
If GetOemDro(39) <10 Then             
  If isactive(INDEX) And isactive(OEMTRIG1) Then    
    ActivateSignal(OUTPUT9)         'Activate Locking Pin
    Exit Sub
  End If
End If

'-------------------- If spindle RPM =0 and not Aligned ---------------------
If GetOemDro(39) <10 Then                        
  Code"M4S10"
  ActivateSignal(OUTPUT9)         'Activate Locking Pin
  While Not isactive(INDEX) And Not isactive(OEMTRIG1)
    sleep 10
   Wend
   code"M5"
End If

'-------------------- If spindle RPM > 10 and not Aligned -------------------
'--------------------------- Dynamic spindle braking ------------------------
If GetOemDro(39) > 10 Then         'Get True spindle
  code"M4S1000"               'Start spindle CCW to brake
    While getOEMdro(39) > 100         'Check if spindle speed above 100rpm
    sleep 1
      If getOEMdro(39) > 100 Then
       activateSignal(OUTPUT6)         'Activate Spindle ENABLE
       sleep 50
       deactivateSignal(OUTPUT6)              'deActivate Spindle ENABLE
      End If
    Wend
   ActivateSignal(OUTPUT9)                 'Activate Locking Pin
   code"M4S10"
   While Not isactive(INDEX) And Not isactive(OEMTRIG1)
    sleep 10
   Wend
   code"M5"
End If

'---------------------- Double Check Spindle Index Alignment -----------------------
If Not isactive(INDEX) And Not isactive(OEMTRIG1) Then MsgBox("Tool Alignment Fail") 

End Sub
'----------------------------------------------------------------------------


'----------------------------------------------------------------------------
Sub MoveZ
code "G1 G53 Z130 F3000"      'Move Z-Axis to tool change position
While ismoving()
Wend
End Sub

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: ismoving() error message
« Reply #1 on: July 21, 2013, 05:12:22 AM »
I would hazard a guess that the "call" for M4 may be the problem. It's a no no to call a macro from a macro.

Ian

Offline rufan

*
  •  38 38
    • View Profile
Re: ismoving() error message
« Reply #2 on: July 24, 2013, 07:59:07 AM »
I was also thinking about that but just didn't try that.
Now I change the code, for code"M4" I put:
  '----M4--------            'Start spindle CCW to brake
  DoSpinCCW()                'Enable CCW Relay
  ActivateSignal(OUTPUT6)         'Spindle enable

This didn't solve the problem with getting the error message line 134 error (while ismoving)

I keep playing around with vb, and found out vb is jumping so fast from 1 sub to another and I think this is causing the issue.
I put sleep 200 before (End Sub), and until now the problem seems to be solved.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: ismoving() error message
« Reply #3 on: July 24, 2013, 08:15:27 AM »
without seeing all of your code I can't comment.

Offline rufan

*
  •  38 38
    • View Profile
Re: ismoving() error message
« Reply #4 on: July 24, 2013, 09:32:47 AM »
Attachment the M6Start version with the ismoving error on Ln-124

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: ismoving() error message
« Reply #5 on: July 24, 2013, 11:12:19 AM »
first thing that jumps out is you're explicitly declaring sleep. (Have you been reading the wiki by any chance?) there's no need to do this - sleep is already "internally" declared for you. Before I look any further you could take that first line out and see if it helps. Let me know.

Offline rufan

*
  •  38 38
    • View Profile
Re: ismoving() error message
« Reply #6 on: July 25, 2013, 09:12:53 AM »
I have read the wiki and there I found this line (Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long))
http://www.machsupport.com/Mach3Wiki/index.php?title=Mach_specific_Subroutines/Functions_grouped_by_purpose

I will remove this line tonight and perform a test, I will post the results.

Many thanks to look at my code.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: ismoving() error message
« Reply #7 on: July 25, 2013, 09:21:02 AM »
Yes I know - that was why I asked - ignore it - it's presumably an old instruction and is now out of date.

Offline rufan

*
  •  38 38
    • View Profile
Re: ismoving() error message
« Reply #8 on: July 26, 2013, 05:14:46 AM »
Removed the Declare sleep line, but still fails.

From what I can visual see is: Spindle is turning to move to index position, but at the same time Z-Axis is going to move.
When this happens I get the ismoving error.
So vb is jumping out of a sub to the next before finishing the task.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: ismoving() error message
« Reply #9 on: July 26, 2013, 08:23:37 AM »
You have some logic in there that would make me uneasy if it were mine. I'm always slightly dubious of the practice of putting in random sleeps when there are issues that should be sorted first.

Example: I'm not sure what your reasons are but you appear to be starting and stopping the spindle twice each time. DoSpinCCW AND activateSignal(OUTPUT6) and then deActivateSignal(OUTPUT6) AND DoSpinStop(). Why are you doing that?

And: Did you intend to potentially engage the lock pin when the spindle is doing anywhere between 0 and 100 rpm?
« Last Edit: July 26, 2013, 09:07:38 AM by stirling »