Hello Guest it is March 28, 2024, 01:11:13 PM

Author Topic: G4, M30, M1, etc. is somtimes ignored when running programming script  (Read 5890 times)

0 Members and 1 Guest are viewing this topic.

Ok, I am a newbe and this is my first posting but, I don't know why this is happening. I am familiar with programming and learning G code and Mach3. I have only had the CNC machine (Shark Pro) for about six months. I have upgrade my controller to a CNC4pc - C11 V9.3
I am using XP, 3gig CPU with 4gig Ram. Using Mach3 Ver. R3.042.040.

This is the problem; I am programming one of my buttons for Auto Centering and Zeroing.
The program is working properly with all the G4 codes in it. Now at the beginning I am writing a continuity test section and any G4, M30 or M1 (M1 button is optioned on) they are ignored, yet they work inside the program. I have loaded it with different screens, both 1024.set and others and it makes no difference. Beat me with a rock, but I just don’t see why they are ignored.

Here is a part of the program; the new section makes you test for continuity before centering, it ignores the G4 & M commands. This section is above the dashed lines. When running the program all I will see is the " ** NO Continuity **"  in the Status Bar, a slight pause of about 1.5 sec then it runs the below program. The computer runs to fast for the " **** TEST CONTINUITY ****" to be seen in the Status Bar with out a pause. The new section is being saved, when I re-open the "edit button script" is does show it saved.

Rem   Test To make sure spindle is grounded And continuity exist
Code "( **** TEST CONTINUITY ****)"   'print in Status Bar
        Code "G4 P1.5"                      'Pause to read Status Bar
             
If GetOemLed (825) <> 0 Then           'check for continuity test
        Code "( CONTACT TESTED OK)"   'print in Status Bar
        Code "G4 P1.5"                 'pause to read Status Bar
        Code "( Place CENTER TOOL then RESTART)"      'print in Status Bar
        Code "M1"                         'stop program until RESTART is Pressed   
Else                               'if no continuity then
    Code "( ** NO Continuity **)"    'print in Status Bar
        Code "M30"                         'stop program and rewind from start   
End If                       'End If statement
Code "M1"                                          'Wait to align the ring then restart

-------------------------------------------------------------------------------------------------------------------------------

(This section works OK and sees the G4 code)
Rem   Centering Spindle In center of tube
If GetOemLed (825) <> 0 Then       'Check to see if the probe is already grounded or faulty
   Code "(Probe plate is grounded, check connection and try again)"
Else
   FeedCurrent = GetOemDRO(818)    'Get the current Feed Rate settings to reset later
   XCurrent = GetDro(0)
   YCurrent = GetDro(1)

Rem   Move Z down into ring      'move probe into ring
   Code "F8"                 'change feed rate to moderate speed 8 IPM
   ZNew = ZCurrent - .75      'set Z distance for down .75 inch
   Code "G31 Z" &ZNew      'move Z down .5 inch
   While IsMoving()              'wait for probe to finish moving
   Wend                    'end wait command
   
Rem   If Probe touches Ring On the way down Then go back up
        If GetOemLed (825) <> 0 Then   'if probe touches Auto Zero ring then
      ZNew = GetDro(2) + .25   'probe move to current Z + .25 inches if touches plate on the way down
      Code "G0 Z" &ZNew      'move Z down at 2 IPM
      While IsMoving()      'wait for probe to finish moving
      Wend            'end wait command
      Code "G4 P5.0"              'Pause for 5 seconds to re-align ring before it tries again  (this Works OK)
      Code "F8"         'change feed rate to moderate speed 8 IPM
      ZNew = GetDro(2) - .5   'probe move to current Z - .5 inches
      Code "G31 Z" &ZNew      'move Z down .5 inch
      While IsMoving()      'wait for probe to finish moving
      Wend            'end wait command
     End If            'end if statement

Any Ideas or am I just blind and missing something stupid...
Lyle
The difference between a young person and an older person is the realization that the more you learn; you learn, the less you know.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G4, M30, M1, etc. is somtimes ignored when running programming script
« Reply #1 on: September 30, 2010, 10:50:14 PM »
When you are intermixing VB and Gcode it does not always do as you expect it would do.

In the first part you are calling M1 and M30 BUT there is NOT a gcode program running so what is it going to hold or reset(;-) They only work for an active Gcode program running.

To make the G4 P# work you would need to insert a WHile Ismoving() command in front of it OR mach may jump over it while it is still doing the Message write.

The While Ismoving() is not just for when mach is moving it is when Mach is active in a process.

In the second half the G4 works because there is a While Ismoving preceeding it to prevent Mach from skipping over it UNTIL the process is complete.

Just a thought, (;-) TP

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: G4, M30, M1, etc. is somtimes ignored when running programming script
« Reply #2 on: September 30, 2010, 11:27:27 PM »
I would redo the first part and do it ALL in VB without trying to hop out to the Gcode side. Look up the use of " Message and MachMsg and Question "to be used as a hold until you get a response from the operator.

Just make sure you are NOT putting the operator in a dangerous situation while you are in software hold. Odd things can make a machine restart from a soft hold.

Safety first then function

Just a thought, (;-) TP
« Last Edit: September 30, 2010, 11:30:32 PM by BR549 »
Re: G4, M30, M1, etc. is somtimes ignored when running programming script
« Reply #3 on: September 30, 2010, 11:54:25 PM »
Thank you TP,
After you started talking about VB versus gCode, that rock hit me. Yes, it makes sense to me now. Sometimes the simple things are easily missed. I am use to programing in one term and not sliding back and forth between terminologies.

Thanks again,
Lyle
The difference between a young person and an older person is the realization that the more you learn; you learn, the less you know.