Mach Discussion > VB and the development of wizards

scan problem

(1/2) > >>

birillo1959:
Good morning
since I have no expertise on this, I ask if anyone can help me. my problem is this I run a scan and it generates a text file:
2.0467858519169e-009,4.7808654812798e-009,-9.2617585402426
15.000320522173,4.7808654812798e-009,-8.3624861271786
30.000641042299,4.7808654812798e-009,-7.4582315954826
45.000961562425,4.7808654812798e-009,-6.6112714280539
60.001282082551,4.7808654812798e-009,-5.853989396
75.001602602676,4.7808654812798e-009,-5.1664570247932
90.001923122802,4.7808654812798e-009,-4.65578986502
105.00224364293,4.7808654812798e-009,-4.3468985098401
120.00256416305,4.7808654812798e-009,-4.3419163912082
135.00288468318,4.7808654812798e-009,-4.6159329159645
150.00320520331,4.7808654812798e-009,-5.0867431266823
165.00352572343,4.7808654812798e-009,-5.7269453708857
180.00384624356,4.7808654812798e-009,-6.4692810470438
195.00416676368,4.7808654812798e-009,-7.2539647315734
210.00448728381,4.7808654812798e-009,-8.1183623142138
2.0467858519169e-009,14.998415467348,-9.3290171417737
15.000320522173,14.998415467348,-8.4172894321298
30.000641042299,14.998415467348,-7.5329633749616
45.000961562425,14.998415467348,-6.6536194364254
60.001282082551,14.998415467348,-5.8963374043715
75.001602602676,14.998415467348,-5.2137871517966
90.001923122802,14.998415467348,-4.7031199920234
105.00224364293,14.998415467348,-4.431594526583
120.00256416305,14.998415467348,-4.4166481706872
135.00288468318,14.998415467348,-4.6632630429679
150.00320520331,14.998415467348,-5.1241090164218
165.00352572343,14.998415467348,-5.7493649047294
180.00384624356,14.998415467348,-6.4917005808875
195.00416676368,14.998415467348,-7.2863485026809
210.00448728381,14.998415467348,-8.1681835005332
2.0467858519169e-009,29.996830929914,-9.3937846839888


to use the point cloud I have to remove "e-009" I don't know why it generates this, the second problem is: is it possible to reduce the numbers after the point? (15.000320522173, 29.996830929914, -8.477074855713) the macro I use is:
Sub Main ()

Dim X As Double
Dim Y As Double

Zmin=GETOEMDRO(1006)
Zmax=GETOEMDRO(1005)
Xmax=GETOEMDRO(1001)
Ymax=GETOEMDRO(1002)
StepZsu=GETOEMDRO(1011)
StepX=GETOEMDRO(1003)
StepY=GETOEMDRO(1004)
AvanzZgiu=GETOEMDRO(1007)
AvanzZsu=GETOEMDRO(1008)
AvanzX=GETOEMDRO(1009)
AvanzY=GETOEMDRO(1010)
intNum=1

Open "C:\prova.txt" For Output As intNum ' Open to write file.

Code "G17 G21 G90"
Code "G1 Z" & Zmax & "F" & AvanzZsu
Code "G1 X0 Y0 F" & AvanzX
Code "G1 Z0 F" & AvanzZgiu

Label0:
   Code "G31 Z" & Zmin & "F" & AvanzZgiu   ' Avvia scansione fino a Zmin
   While IsMoving()            ' Aspetto mentre si muove
   Wend
   
X = GetParam("XDRO")
Y = GetParam("YDRO")
Z = GetParam("ZDRO")

Write #1, X , Y, Z
   
Label1:
   Code "G91"
   Code "G1 Z" & StepZsu & "F" & AvanzZsu   ' Salita Z dopo contatto tastatore
   While IsMoving()            ' Aspetto mentre si muove
   Wend
   Code "G90"
   If GetOemLed (825)<>0 Then         ' verifica se tastatore attivo
      GoTo Label1
   End If
Label3:
   Code "G91"
   Code "G1 X" & StepX & "F" & AvanzX
   While IsMoving()            ' Aspetto mentre si muove
   Wend
   Code "G90"

   If GetOemLed (825)<>0 Then         ' verifica se tastatore attivo
      Code "G91"
      Code "G1 X-" & StepX & "F" & AvanzX
      While IsMoving()            ' Aspetto mentre si muove
      Wend
      Code "G1 Z" & StepZsu & "F" & AvanzZsu
      While IsMoving()            ' Aspetto mentre si muove
      Wend
      Code "G90"
      'If Zdro < Zmax Then
      If GetVar(2002) < Zmax Then
         GoTo Label3
         Else
         If GetOemLed (825)<>0 Then      ' verifica se tastatore attivo
            MachMsg("Errore, asse Z max superato","ERRORE",0)
            End
         Else
            GoTo Label3
         End If
      End If
   Else
      'If Xdro < Xmax Then
      If GetVar(2000) < Xmax Then
         GoTo Label0
      End If
      Code "G0 Z" & Zmax
      While IsMoving()            ' Aspetto mentre si muove
      Wend
      Code "G0 X0"
      While IsMoving()            ' Aspetto mentre si muove
      Wend
      Code "G91"
      Code "G1 Y" & StepY & "F" & AvanzY
      While IsMoving()            ' Aspetto mentre si muove
      Wend
      Code "G90"
      'If Ydro > Ymax Then
      If GetVar(2001) > Ymax Then
         End
             Else
      GoTo Label0
      End If
         End If
      Close intNum
      End Sub   

TPS:
try to replace:

--- Code: ---Write #1, X , Y, Z

--- End code ---

by:

--- Code: ---Write #1, Format(X,"###0.000") , Format(Y,"###0.000") , Format(Z,"###0.000")

--- End code ---

birillo1959:
thanks for the help TPS !!
in part I have solved it but it puts the quotes on me and is it possible to delete them?

"0,000","0,000","-0,483"
"5,000","0,000","-0,227"
"10,000","0,000","0,035"
"15,000","0,000","0,272"
"20,000","0,000","0,553"
"25,001","0,000","0,859"
"30,001","0,000","1,141"
"35,001","0,000","1,415"
"40,001","0,000","1,664"
"45,001","0,000","1,913"
"50,001","0,000","2,170"
"0,000","3,001","-0,486"

JohnHaine:
Try omitting the quotes in the formatting statement

TPS:
use:

--- Code: ---Print #1, nFmt(X,4) & "," & nFmt(Y,4) & "," & nFmt(Z,4)

--- End code ---
insteed:

--- Code: ---Write #1, Format(X,"###0.000") , Format(Y,"###0.000") , Format(Z,"###0.000")

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version