Hello Guest it is January 26, 2021, 01:29:04 PM

Author Topic: OEM/User/otherwise knowledge  (Read 3224 times)

0 Members and 1 Guest are viewing this topic.

OEM/User/otherwise knowledge
« on: August 11, 2015, 08:10:50 AM »
Can any one explain the difference of these commands in a wizard AND is there a difference if you place a DRO on the Global Page 0
GetOEMDRO(1051)
GetOEMDRO(800)
GetDRO(0)
Call GetDRO(0)
GetUserDRO(1051)

and then the Set Command of the same.

The reason i'm asking, is i'm having all sorts of bother getting and setting the X DRO values in a wizard.
If i put 5 second waits in they will work occasionally.If i put a Message Prompt they will always get and set.
its driving me around the twist.
Page 0 has the DRO on it
Page 1 seems to work all the time
Page two works when it feels like it.

Wes

Offline BR549

*
  •  6,943 6,943
    • View Profile
Re: OEM/User/otherwise knowledge
« Reply #1 on: August 11, 2015, 08:44:55 AM »
HI Wes as a test try adding this after every call to update teh Dro. What version are you using ??

While Ismoving()
Sleep(100)
Wend

(;-) TP
Re: OEM/User/otherwise knowledge
« Reply #2 on: August 11, 2015, 09:17:41 AM »
Hi TP,
I'm using version 67
Im not sure that would do anything mate as nothing is moving and the wait of 100 is less than g04 p5000 that I'm using.
I'm assuming the wait is milliseconds?
I'll try it tomorrow though.

Your thoughts on why?

Wes

Offline ger21

*
  • *
  •  6,287 6,287
    • View Profile
    • The CNC Woodworker
Re: OEM/User/otherwise knowledge
« Reply #3 on: August 11, 2015, 10:21:56 AM »
What does your actual code look like?

I do this, and it works every time.


XWork = GetOEMDRO(800)  ' Get Current X Work Coordinate
YWork = GetOEMDRO(801)  ' Get Current Y Work Coordinate

Call SetOEMDRO(800,1)
Sleep(250)

And it really shouldn't matter what page the DRO's are on.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline BR549

*
  •  6,943 6,943
    • View Profile
Re: OEM/User/otherwise knowledge
« Reply #4 on: August 11, 2015, 04:15:20 PM »
FIrst, while Ismoving()  is NOT what you think it is, very little to do with actually moving.  It is waiting for ALL internal processes to stop NOT just motion (;-) ANd G4P# is the wrong approach for a macro. It is a GCODE wait call not a CB script call. There IS a difference.


(;-) TP
Re: OEM/User/otherwise knowledge
« Reply #5 on: August 11, 2015, 10:43:29 PM »
Heres a Bit of Code from the main Button.

'Pull in common Information so we know which process we need
ProbeFeed = GetOEMDRO(1053) 'Get the probe feedrate.
TipD = GetOEMDRO(1050) 'Get the Probe Tip O.D.
ProgCNC = GetOEMDRO(1062) 'Which Program to run
XStart = GetOEMDRO(800) ' X DRO
YStart = GetOEMDRO(801) ' Y DRO
ZSafe = GetOEMDRO(1306) ' Z Safe Distance
ZProbe = GetOEMDRO(1307) ' Z Probe Depth
XDist = GetOEMDRO(1304)
YDist = GetOEMDRO(1305)
SetUserLabel(34,"")
Call SetVar(2000,0)
Msg = "YStart = " & YStart
MsgBox Msg, 64 ,"Step"
Msg = "XStart = " & XStart
MsgBox Msg, 64 ,"Step"

Select Case ProgCNC

Case 1

Msg= "Probing Round Centre"
   MsgBox Msg, 64 ,"Probe Information"

If GetOEMDRO(1304)=0 Then 'First If Then
   Msg= "No Set User Bar Size to Probe - Terminating"
   MsgBox Msg, 64 ,"Error - Bar Size Zero"
End   
Else 'First Else
'Next Check and Program
Code "G91 F" & ProbeFeed
' This is the Probe hit LED and Second If Then
If GetOEMLED (825)=0 Then
' add outside moves
 PrepMoveY  = (YDist/3) - (YDist*0.05) + (TipD/2)
Do
  Code "G90 G00 Z" & ZSafe
   Code "G91 G00 Y" & PrepMoveY
   Code "G90 G31 Z-" & ZProbe
   While IsMoving()   
  Sleep(100) 
   Wend
YPosZVal=GetVar(2002)
   Code "G90 G00 Z" & ZSafe
   Code "G90 G00 Y" & YStart
   Msg = "Should Be at Y Start"
MsgBox Msg, 64 ,"Step"
      Code "G91 G00 Y-" & PrepMoveY
   Code "G90 G31 Z-" & ZProbe
   While IsMoving()   
   Sleep(100)
   Wend
   YNegZVal=GetVar(2002)
Code "G90 G00 Z" & ZSafe
Code "G90 G00 Y" & YStart   

' Do the Math
TrigB = PrepMoveY

If Abs(YPosZVal) > Abs(YNegZVal) Then 'Third If Then
CBar = Abs(YPosZVal) - Abs(YNegZVal)
FMove = CBar/2
Doy = 1
Else 'Third Else
CBar = Abs(YNegZVal) - Abs(YPosZVal)
FMove = CBar/2
Doy = 2
End If 'Third End If

'Do the Move or Exit
If CBar <= 0.002 Then 'Fourth If Then
Msg= "Z Probe difference <= 0.002 - To Small Exiting"
   MsgBox Msg, 64 ,"Probe Information"    
Exit Do

Else 'Fourth Else

If Doy = 1 Then 'Fifth If Then
ZFin = Abs(YNegZVal) + FMove
Code "G91 G01 Y" & PrepMoveY
Code "G90 G31 Z-" & ZFin
While Ismoving()
Sleep(100)
Wend
Code "G91 G31 Y-" & PrepMoveY
While IsMoving()   
Sleep(100)
Wend
YProbeVal = GetVar(2001)
Code "G90 G00 Z" & ZSafe
Code "G00 Y" & YProbeVal
Code "G91 Y-" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
Call SetOEMDRO(802, YStart)
Sleep(250)
Code "G90 F" & ProbeFeed

Else ' Fifth Else
ZFin = Abs(YPosZVal) + FMove
Code "G91 G01 Y-" & PrepMoveY
Code "G90 G31 Z-" & ZFin
While Ismoving()
Sleep(100)
Wend
Code "G91 G31 Y" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
YProbeVal = GetVar(2001)
Code "G90 G00 Z" & ZSafe
Code "G00 Y-" & Abs(YProbeVal)
Code "G91 Y" & PrepMoveY
While Ismoving()
Sleep(100)
Wend
Call SetOEMDRO(801, YStart)
Sleep(250)
Code "G90 F" & ProbeFeed

End If 'Fifth End If
End If ' Fourth End If

Loop

Else ' Second Else
 MsgBox("probe is touching")
End If 'Second End If
End If 'First End If

 If GetOEMLED(1006) = True Then '  Set to Zero
 Msg = "Axis set to Zero for Centre of Hole"   
      MsgBox Msg,64,"Successful Probe to Zero"   
Call SetOEMDRO(801,0)
Call SetOEMDRO(800,0)
Sleep(250)
   Else
   SetUserLabel(34,""   )   
End If

Case 2
Msg= "Probing Round Parallel"
   MsgBox Msg, 64 ,"Probe Information"

Case 3
Msg= "Probing Round Parallel while Centring"
   MsgBox Msg, 64 ,"Probe Information"

Case 4
Msg= "Probing for The End Of a Round Bar"
   MsgBox Msg, 64 ,"Probe Information"
'Start the Checks
'Checking for X Data
If GetOEMDRO(1304)=0 Then
   Msg= "No Set User Bar Size to Probe - Terminating"
   MsgBox Msg, 64 ,"Error - Bar Size Zero"
End   
Else
'Next Check and Program
Code "G91 F" & ProbeFeed
If GetOEMLED (825)=0 Then 'This is the Probe hit LED
' add outside moves
 PrepMoveX = XDist + (TipD*2)
   Code "G90 G00 Z" & ZSafe
   Code "G91 G00 X"    & PrepMoveX   
   Code "G90 G31 Z -" & ZProbe
   While IsMoving()   
   Sleep(100)   
   Wend
   Code "G04 P250"
If GetOEMLED (825) = True    Then
   Code "G90 G00 Z" & ZSafe
    Msg= "Probe hit prior to Z depth " & ZProbe & ". "
    Msg= Msg & " X Block dimensions are from Probe to the end of the Bar"       
      MsgBox Msg, 16 ,"Program Has Ended" 
   End
   Else
   Code "G91 G31 X-" & XDist
   While IsMoving()
   Sleep(100)   
   Wend
   Code"G04 P250"
   XProbePos = GetVar(2000)
   Msg= "Probed Value = "  & XProbePos   
   MsgBox Msg, 64 ,"XProbe Value   "
   XCentre = XProbePos - (TipD / 2)
      Msg= "Centre Vale = " & XCentre
   MsgBox Msg, 64 ,"XCentre Value"
   Code " G91 G01 X0.1"
   Code "G90 G00 Z" & ZSafe
   'Reset to Zero or Pass the Value
   If GetOEMLED(1006) = True Then
   Code "G90 G00 X" & XCentre
  While IsMoving()
  Sleep(100)
  Wend
   Call SetOEMDRO(801,0)   
   Call SetOEMDRO(800,0)
  Sleep(250)
   Else
   Code"G90 G00 X" & XStart
   While IsMoving()
  Sleep(100)
   Wend
   SetUserLabel(34,"Edge of the Round Bar is " & XCentre)   
End If
End If 
Else
  MsgBox("probe is touching")
End If   
End If

Case 8
Msg= "Probing the Centre of a Rectangle Bar"
   MsgBox Msg, 64 ,"Probe Information"

Case 16
Msg= "Probing Rectangle Bar Parallel"
   MsgBox Msg, 64 ,"Probe Information"

Case 24
Msg= "Probing Rectangle Bar Parallel and Centre"
   MsgBox Msg, 64 ,"Probe Information"

Case 32
Msg= "Probing for the End of a Rectangular Bar"
   MsgBox Msg, 64 ,"Probe Information"

Case 64
Msg= "X Axis Probe of Vise Jaw for Square"
   MsgBox Msg, 64 ,"Probe Information"

Case 128
Msg= "Y Axis Probe of Vise for Square"
   MsgBox Msg, 64 ,"Probe Information"

Case Else
Msg= "Nothing selected to Probe"
   MsgBox Msg, 64 ,"Probe Information"

End Select

End

Offline ger21

*
  • *
  •  6,287 6,287
    • View Profile
    • The CNC Woodworker
Re: OEM/User/otherwise knowledge
« Reply #6 on: August 12, 2015, 08:21:01 AM »
Any time you have a line of g-code, you need a while is moving. And youdon't need the sleep(100) in there.

ANd anytime you write to a DRO or a label, I like to add a Sleep(250) to make sure the screen has time to update before continuing.


This:

Code " G91 G01 X0.1"
   Code "G90 G00 Z" & ZSafe
   'Reset to Zero or Pass the Value
   If GetOEMLED(1006) = True Then
   Code "G90 G00 X" & XCentre
  While IsMoving()
  Sleep(100)
  Wend

SHould be:

Code " G91 G01 X0.1"
While IsMoving()
Wend

Code "G90 G00 Z" & ZSafe
While IsMoving()
Wend

'Reset to Zero or Pass the Value
If GetOEMLED(1006) = True Then
Code "G90 G00 X" & XCentre
While IsMoving()
Wend
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: OEM/User/otherwise knowledge
« Reply #7 on: August 12, 2015, 08:50:47 AM »
Havent had a chance to get back to this to test the sleep(100) so taking them out is no problem.
I was under the impression from other Subjects I've looked at that the Sleep(100) reduces the Load on the CPU.

Seems odd and very messy adding While Wend statements after every move, is this a Mach3 Coding issue?
Didn't seem to worry the Page 1 functions, however I'll test it tomorrow with all the While Wend statements in place.


Thanks again Guys

Wes
« Last Edit: August 12, 2015, 08:53:41 AM by ozwes007 »

Offline BR549

*
  •  6,943 6,943
    • View Profile
Re: OEM/User/otherwise knowledge
« Reply #8 on: August 12, 2015, 08:51:47 AM »
Here is the scoop on While Ismoving() as I remember it. In the beginning the WIM() did not have a built in sleep AND it hogged teh CPU during the wait. THen Brian added in an auto sleep to the mix BUT this caused other problems and it was later  removed. So that is why I still add in the sleep() to the WIM() and it works well here.

Also I find that IF you have a group of Gcode moves you can group them together with a WIM() at the end of the group.

Slower PCs work better than faster PCs when handling Macros it is a timing issue with macros.  That is WHY one script will run perfect on ONE PC but not another without some tuning.

Sleep() allows the PC to wait with out hogging the CPU.

After anything that has to update or get a values add in a sleep(100) minimum to give it time to do it or create a semiphor to control the flow.

Never call another macro from inside a macro There IS a CALL for that in later versions that make it work.

The G4P# call is for use in the Gcode side. It stops the Que fill at that line call and then restarts the que fill  from that point. YES it does create a wait BUT WIM() and sleep() are the better choice in the macro side as they do NOT effect the Que fill.

The Gcode side and the Macro side are 2 seperate control functions that are merged together when you use Gcode in a Macro script. REMEMBER that (;-) Not all things will work as you assume they would/should (;-).



Just a few thoughts, Your Mileage may vary.  (;-) TP
Re: OEM/User/otherwise knowledge
« Reply #9 on: August 12, 2015, 06:34:01 PM »
would it be worth while changing the read ahead lines to a lower value on a fast machine TP?
or is this way of track.
It appears from what your saying, the faster the machine the higher the wait state value we need in the Macros.
And as a progression from that, as we update our computers to newer versions this is going to become a major issue with Wizards and such.

Wes