Hello Guest it is April 26, 2024, 12:11:16 AM

Author Topic: scan problem  (Read 1785 times)

0 Members and 1 Guest are viewing this topic.

scan problem
« on: July 08, 2022, 07:39:16 AM »
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   

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: scan problem
« Reply #1 on: July 09, 2022, 02:42:18 AM »
try to replace:
Code: [Select]
Write #1, X , Y, Z

by:
Code: [Select]
Write #1, Format(X,"###0.000") , Format(Y,"###0.000") , Format(Z,"###0.000")
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: scan problem
« Reply #2 on: July 09, 2022, 03:20:40 AM »
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"
Re: scan problem
« Reply #3 on: July 09, 2022, 08:01:30 AM »
Try omitting the quotes in the formatting statement

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: scan problem
« Reply #4 on: July 09, 2022, 10:02:44 AM »
use:
Code: [Select]
Print #1, nFmt(X,4) & "," & nFmt(Y,4) & "," & nFmt(Z,4)
insteed:
Code: [Select]
Write #1, Format(X,"###0.000") , Format(Y,"###0.000") , Format(Z,"###0.000")
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: scan problem
« Reply #5 on: July 10, 2022, 03:14:53 AM »
good morning
the modification " Print #1, nFmt(X,4) & "," & nFmt(Y,4) & "," & nFmt(Z,4)" works perfectly !!!
thanks TPS once again for the help offered !! :)
Re: scan problem
« Reply #6 on: June 12, 2023, 12:04:57 AM »
Try removing the quotation marks. Hope it helps you to solve the problem.
« Last Edit: June 12, 2023, 12:10:18 AM by johnny4827 »