Hello Guest it is March 29, 2024, 04:17:27 AM

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 - LGentry

Pages: « 1 2
11
VB and the development of wizards / Re: Mach3 script editor bug?
« on: February 09, 2013, 04:19:12 PM »
Sorry - I know you just want a one shot answer but hopefully you'll see why I think I would be wrong to give you one. Maybe someone will come along and explain it better.
I am actually very grateful that you are teaching me, it is much more useful than just posting the code. This way next time I have to write something similar I will understand how it works :D

Yes there is a difference 10/3 in decimal is a infinite number and 3.3333333333333 is not infinite.
BaseX is used in a sub to control the X axis on a lathe to take the final roughing cuts and two finish cuts of a profile.
print round(0.5,0) Displays 0. I would have guessed it would have displayed 1. print round(0.6,0) displays 1.
print round(1.5,0) Displays 2 and so does print round(2.5,0).
Print Round(-1.5,0) and Print Round(-2.5,0) both display -2

I am not sure exactly how far off the rounding function makes my variable as it goes threw my loop. I now understand values produced by rounding are not accurate. Rounding a variable in a loop can cause the difference to grow based on the size of the loop. Possibly rounding difference * num of loops and is not good for accuracy.
In the future I will just use rounding for displaying information to the operator.

Currently my code looks like this. I tested it with n what do you think?
Code: [Select]
 Code "G0 X.4" 'Back away X
  Code "G0 Z.01" 'Back away Z
  Code "G0 X0" 'Zero X
  
  Dim BaseX As Double
  BaseX = .0004 'Make BaseX .01 larger than needed.
  Do Until BaseX = 0
    If BaseX <= 0.002 Then BaseX = BaseX - .001 'If down to last cuts take off .001 and subtract until 0
    If BaseX > 0.0021 And BaseX < .012 Then BaseX = .002 'If within .01 of .002 then set to .002
    If BaseX > 0.012 Then BaseX = BaseX - .010 'If far away rough .01
    If BaseX < 0 Then BaseX = 0 'Catch if BaseX starts <.001 and > 0
    Code "G1 X" & BaseX + 0.110 & " Z0.00 F10"
    Code "G2 X" & BaseX + 0.190 & " Z-0.075 R-0.066 F10"
    Code "G1 X" & BaseX + 0.130 & " Z-0.600 F10"

    Code "G0 X.4" 'Back away X
    Code "G0 Z0.01" 'Back away Y
    Code "G0 X" & BaseX 'Sets x to the base to save time
  Loop

12
VB and the development of wizards / Re: Mach3 script editor bug?
« on: February 08, 2013, 01:26:31 PM »
Print 0.0999999999999999 shows up as .1
print 10/3 displays 3.3333333333333
print 10/6 displays 1.6666666666667

I definitely want to know what my program will do. Crashing would be sad.
Does this look better?
Do I need the Round(var,4) or is it not needed now?
Thanks again for all the help :)

Dim BaseX As Double
BaseX = .030
Do While (BaseX > .000)
If Round(BaseX,4) <= 0.0021 Then BaseX = BaseX - .001
If Round(BaseX,4) < 0.0101 And Round(BaseX,4) >0.0099 Then BaseX = BaseX - .008
If Round(BaseX,4) > 0.01 Then BaseX = BaseX - .010
Loop

13
VB and the development of wizards / Re: Mach3 script editor bug?
« on: February 08, 2013, 11:59:07 AM »
VB was printing it out just like I typed in my printout and I never got to far into binary.
I changed the code below and it seems to work. Is this a good fix to my problem or could you recommend a better solution?
Thanks for the help  :)

Dim BaseX As Double
BaseX = .030
Do While (BaseX > .000)
  If Round(BaseX,3) = 0.001 Then BaseX = BaseX - .001
  If Round(BaseX,3) = 0.002 Then BaseX = BaseX - .001
  If Round(BaseX,3) = 0.01 Then BaseX = BaseX - .008
  If Round(BaseX,3) > 0.01 Then BaseX = BaseX - .010
Loop

14
VB and the development of wizards / Re: Mach3 script editor bug?
« on: February 08, 2013, 09:41:46 AM »
I also tried it using Select Case with the same results

15
VB and the development of wizards / Mach3 script editor bug?
« on: February 08, 2013, 09:40:43 AM »
I can't figure out why this is happening.
If I set BaseX = .020 it works fine.
If I set BaseX = .030 or higher it is a endless loop
Is this a bug in the mach3 vb? I have used VB5 and never seen anything like this.
I am using Demo Version R3.043.066


Dim BaseX As Double
BaseX = .030
Do While (BaseX > .000)

Print "Old BaseX = " & BaseX 
If BaseX = 0.001 Then BaseX = BaseX - .001
If BaseX = 0.002 Then BaseX = BaseX - .001
If BaseX = 0.01 Then BaseX = BaseX - .008
If BaseX > 0.01 Then BaseX = BaseX - .010
Print "new BaseX = " & BaseX
Loop

'Set BaseX = .020
'1st loop OldBaseX= 0.02, NewBaseX = 0.01
'2nd loop OldBaseX= 0.01, NewBaseX = 0.002
'3rd loop OldBaseX= 0.002, NewBaseX = 0.001     
'4th loop OldBaseX= 0, NewBaseX = 0
'Exits loop

'Set BaseX = .030
'1st loop OldBaseX= 0.03, NewBaseX = 0.02
'2nd loop OldBaseX= 0.02, NewBaseX = 0.01
'3rd loop OldBaseX= 0.01, NewBaseX = 0.01     
'4th loop OldBaseX= 0.01, NewBaseX = 0.01
'endless loop???

16
G-Code, CAD, and CAM discussions / Re: Pass value from gcode to VB
« on: January 23, 2013, 08:42:28 PM »
Thanks for the code. I will do a search for the manual.

17
G-Code, CAD, and CAM discussions / Pass value from gcode to VB
« on: January 23, 2013, 01:07:04 AM »
I would like to pass a value from gcode to my macro m1234 and save it as a variable in VB.
In gcode
M1234 val1 val2

In VB
Dim val1, val2
Then fill the variables with the information.

Also passing variables from VB to gcode would be great as well.

Thanks in advance for any help.
Lewis

Pages: « 1 2