Advanced Setup Options
(Auto Test Variables)
Hello Again J
Below I will attempt to describe
all the options under the Platform Settings / Auto Test Variables Dialog
Screen.
Before we start messing around
with any of these options, it Might be best if you read the Theory of Operation
Page! I say this as a lot of what’s
mentioned below will be rather difficult if you haven’t an understanding of the
method the code uses for testing J
So Here we go:

i.
Your light source should be
set to get a full 255 pixel intensity reading on the bar graph display
ii.
The light source might not
make it ALL the way to 255 depending on the mirror F/Ratio and camera selection
iii.
So long at the light source
makes it above 200, you should be ok
i.
For instance, lets say we
just started testing a mirror.
ii.
We start looking at the
zone pairs for Zone 1 (Closest to center of mirror)
iii.
The first thing we need to
do, is get a reference shade of gray established.
1. This is done by laterally (sideways) moving the knife
edge into Or out of the return light cone
2. During an auto test, the code will do the above until it
gets the “Shade of Gray” between the Min and Max intensity sliders selected
above!
iv.
Here’s the Rub, if the Min
= 30, and Max = 40, the code may never find this “Sweet spot” and will get
stuck in a loop clicking the knife in one notch, then out another notch!
v.
Conversely, If the Min = 30
and Max = 100, the code can easily find the “sweet spot”, but this will degrade
the overall test result accuracy (Not sure why, it just does!)
vi.
Here’s something fun to do
while testing a mirror:
1. Run a test with Min = 30, Max = 60. Record Results
2. Run a test with Min = 60, Max = 90, Record Results
3. Run a test with Min = 90, Max = 120, Record Results
4. Compare the results of the three tests. I’ll wager test one showed a Larger amount
of Longitudal Travel (to-from) mirror than test 3 did. Why, I’m not sure! However real world star and Ronchi-Star tests show that test 1
will be closest to what the mirror really is!

i.
As you know any video
system has inherent noise
ii.
This noise can result from:
1. Electrical noise in the camera or Capture system
2. Air Currents
3. Wiggly floors
4. Trucks driving down the road blocks away
5. Etc
iii.
All of this adds up to one
problem. No single frame of video can
be considered pristine enough for the code to make decision with!
iv.
So, to overcome this, the
code does A LOT of noise cancellation by “Stacking Frames” and averaging them.
v.
On this tab, the top slider
controls the minimum number of frames to average before making ANY decisions on
moving the platform in any direction!
vi.
If you’re testing a slow
mirror (F/8 – F/12+) you may need to crank this value up! Especially if the
code is “Hunting Around” for the correct lateral position of the knife-edge.
i.
Delta Difference (perhaps
poor choice of words J)
1. If the current “Shade of Gray” is greater or Less than
our target range (30-60?) +/- the “Delta Difference” The code will move the
knife laterally in larger steps.
2. This is handy for a few reasons, Lets say the mirror is
fully illuminated + your step size is ridiculously small. If the code just moved the knife laterally
one step at a time, it might take an eternity to get the “Shade of gray”
correct!
3. BTW, there is built in logic to prevent continually
overshooting the “Shade of Gray” value.
Once the Overshooting flag is set, the code will only use the Small
Motion step size for the remaining time the code tests at this longitudinal
location
ii.
Large Motion
1. This Is calculated by your entry in Lateral step size
previously entered
2. Make sure this value is HIGHER than the small step size!
(something I will fix in later releases!)
iii.
Small Motion
1. Again, this is calculated by your lateral step size entry
2. Preferably this will be as small as possible
3. Caveats:
a. Too Small and the test will take longer to run
b. Too Big, and the code may Hunt back and forth for the correct
Lateral position that results in the “Shade of Gray” in the correct value.
i.
Everything in my code is
done in Nested Loops!
ii.
When an Auto-test is
started, the loop begins.
iii.
Inside this loop are a
ridicules amount of If-Then statements J
iv.
So, using the above
variables, the entire loop for getting the Knife edge in the correct position
to create the “Shade of gray” looks something like this:
1. If Frame Average > 4 Then
2. If Zone
Intensity > 60 + 10 {Max + Delta} Then:
3. Cut Knife
Into Return Beam 0.00075 {Or 6 Half-Steps}
4. Reset
Current Frame Average to 1 and Start All Over!
5. End If
6.
7. If Zone
Intensity < 30 - 10 {Min - Delta} Then:
8. Cut Knife
Out of Return Beam 0.00075 {Or 6 Half-Steps}
9. Reset
Current Frame Average to 1 and Start All Over!
10. End If
11.
12. If Zone
Intensity > 60 {Max} Then:
13. Cut Knife
Into Return Beam 0.000125 {Or 1 Half-Steps}
14. Reset
Current Frame Average to 1 and Start All Over!
15. End If
16.
17. If Zone
Intensity < 30 {Min} Then:
18. Cut Knife
Out of Return Beam 0.000125 {Or 1 Half-Steps}
19. Reset
Current Frame Average to 1 and Start All Over!
20. End If
21.
22. Else
23. Get another
frame of Video data,
24. Average that
data
25. Start All Over
at the top!
26.
27. End If ** If the code gets this far,
28. ** Then
its time to Rough Adjust Distance from Mirror!

i.
The purpose is again noise
cancellation
ii.
Also, during the process of
frame average counting up, the Previous code that controls Lateral position of
the knife is still in play!
i.
This is how the code tests
for Oblate mirrors!
ii.
In addition, this part of
the code helps to eliminate back lash in the test system by Always approaching
a zone null by moving away from the mirror.
iii.
For instance:
1. Lets say we have a perfect paraboilic mirror and zone 1
is perfectly nulled
2. Also lets say the ‘Shade of Gray’ is in the appropriate
range
3. The problem is the code has no way of knowing the amount
of backlash in the system!
4. Consequently the first thing the code is going to do is
ensure that the zone opposite the knife edge side is brighter than the zone on
the same side of the knife edge
5. The amount of difference is the Fwd Delta Variable.
6. So in this case, zone left and right side are equal,
consequently, the code will move the platform forward until there is a
difference of 15 pixel counts!
7. The amount of distance to move forward is set by the Fwd
Travel variable.
8. This will continue until the difference in pixel intensity (left vs right) exceeds the
Fwd Delta variable
9. At the end of this loop, the code KNOWS FOR CERTAIN that
the zone being tested is Further away from the mirror than the platform
currently is. Thus each zone tested
will always be tested with a motion that started closer to the mirror, and
moves away from the mirror.
10. The goal for this is to eliminate backlash AND enable the
testing of oblate mirrors!
i.
This portion will only come
into play once the Forward Delta and Forward Travel section has been satisfied
ii.
When this section of code
starts, WE KNOW that the zone being tested is further away from the mirror than
the knife-edge is currently.
iii.
Consequently the zone side
opposite the knife edge will be in the Min/Max “Shade of gray” Range (30/60 by
default)
iv.
In addition, odds are that
the zone side ON the same side of the knife probably has a pixel intensity of
near zero.
v.
This results in the
platform moving the distance set in the “Away Distance” variable, ONLY if the Difference
between the two zones is greater than the “Away Delta” variable
1. ***Assuming Knife On Right side of light source!***
2. If Frame Average > 15 Then
3. If
Found_Oblate = False Then:
4. If Left Zone Value > Right Zone Value +
15 Then:
5. Move Knife Towards Mirror 0.005 {or 40
Half-Steps}
6. Reset Frame Average to 1 and Start Over!
7. Else
8. Found_Oblate = True
9. End
If
10. End
If
11.
12. If Found_Oblate
= True Then:
13. If Left Zone Value > Right Zone Value +
20 Then:
14. Move Knife Away From Mirror 0.002 {or 16 Half-Steps
15. Reset Frame Average to 1 and Start Over!
16. End If
17. End IF
18. Else
19. Get another
video Frame, integrate it, then and
start over at the top!
20. End If
21. **** If we made it this far, then its time to Move onto
Final Null Code!

i.
Default value is 0.001” (if
English used, else its (0.0254mm))
ii.
You can make this value
smaller, which might improve the test accuaracy, but at the cost of a longer
test run!
Private
Sub Magic_Right()
If
ZoneOn = False Then
MsgBox "Please setup zones first
;)", vbOKOnly, "Do the Zones!"
Exit Sub
End If
abort
= 0
Manual
= False
Timer1.Enabled
= False
DoEvents
Dim
series As Long
Dim
CurrZone As Long
Dim
CurrFrame As Long
Dim
Dummy As Long
Dim
Delay As Long
Dim
TextBuff As String
Dim
TxtZone As Long
Dim
TxtSeries As Long
Dim
StartTime As Currency
Dim
EndTime As Currency
Dim
LastMoveIsLeft As Boolean
Dim
LastMoveIsRight As Boolean
Dim
FoundOblate As Boolean
Dim WW
As Long
Dim
Filehandle%
Dim
data As String
Dim
file As String
QueryPerformanceCounter
StartTime
Move_Mot
Text1.Text
= ""
For
Dummy = 0 To 16 'Clear any old Knife
edge readings!
KEZ(Dummy, 0) = 0
KEZ(Dummy, 1) = 0
KEZ(Dummy, 2) = 0
KEZ(Dummy, 3) = 0
Next
Dummy
MirRad.Enabled
= False 'keeps user from accidentally
chaning mirror radius slider
Command3.Enabled
= False
Command1.Enabled
= False
Command5.Enabled
= False
Picture3.Visible
= False 'Hide the Manual speed indicator
Form_Resize
'This
will be the new and improved main loop (I hope!)
For
series = 0 To Reps
For CurrZone = 1 To NZ
APlay App.Path &
"\Sound\Z" & CurrZone & ".wav"
Text1.Text = "Now working on Zone
" & CurrZone & vbCrLf & Text1.Text
WorkZone = "Testing Zone "
& CurrZone
For CurrFrame = 1 To TFFinalFrames
capGrabFrameNoStop lwndC
FrameAverage = CurrFrame
Call Plot_Zones
If CurrFrame > LRMinFrames Then
'Only do this if we have averaged enough frames!
If LZV(CurrZone) > Max Then
'Only do this if Left zone intenesity is > Max and we need to move the knife
Left
If LZV(CurrZone) > Max
+ LRDelta And LastMoveIsRight = False Then
For Dummy = 1 To LRLgMove
x = x - 1
If x < 0 Then x
= 7
Xpos = Xpos - 1
Out &H378,
(coil(x, Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked),
Abs(mnuSwapMotors.Checked)) + coil(Y, Abs(mnuinvert.Checked),
Abs(mnuTFswap.Checked), Abs(Not (mnuSwapMotors.Checked))))
Delay = 0
Do While Delay
< Mindelay.Value * 2
Delay = Delay
+ 1
Loop
Next Dummy
LastMoveIsLeft = True
CurrFrame = 1
Else 'Since we got here
with a need to move knife left, then if either zone is > max and < Max +
LR Delta *OR* Last move was right (Since we don't want to overshoot!) then move
in Small increments
For Dummy = 1 To
LRSmMove
x = x - 1
If x < 0 Then x = 7
Xpos = Xpos - 1
Out &H378,
(coil(x, Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked),
Abs(mnuSwapMotors.Checked)) + coil(Y, Abs(mnuinvert.Checked), Abs(mnuTFswap.Checked),
Abs(Not (mnuSwapMotors.Checked))))
Delay = 0
Do While Delay
< Mindelay.Value * 2
Delay = Delay
+ 1
Loop
Next Dummy
LastMoveIsLeft = True
CurrFrame = 1
End If
End If 'This will take care of Reducing zone
intensity
If LZV(CurrZone) < Min Then
If LZV(CurrZone) < Min - LRDelta And LastMoveIsLeft = False
Then
For Dummy = 1 To
LRLgMove
x = x + 1
If x > 7 Then x
= 0
Xpos = Xpos + 1
Out &H378, (coil(x,
Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked), Abs(mnuSwapMotors.Checked)) +
coil(Y, Abs(mnuinvert.Checked), Abs(mnuTFswap.Checked), Abs(Not
(mnuSwapMotors.Checked))))
Delay = 0
Do While Delay
< Mindelay.Value * 2
Delay = Delay
+ 1
Loop
Next Dummy
LastMoveIsRight = True
CurrFrame = 1
Else
For Dummy = 1 To
LRSmMove
x = x + 1
If x > 7 Then x
= 0
Xpos = Xpos + 1
Out &H378, (coil(x,
Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked), Abs(mnuSwapMotors.Checked)) +
coil(Y, Abs(mnuinvert.Checked), Abs(mnuTFswap.Checked), Abs(Not
(mnuSwapMotors.Checked))))
Delay = 0
Do While Delay
< Mindelay.Value * 2
Delay = Delay
+ 1
Loop
Next Dummy
LastMoveIsRight = True
CurrFrame = 1
End If
End If 'this should resolve all Knife IN/Out motions,
and if we moved knife, then currframe is reset to one, so lets goto init
To/From checks.
End If
If CurrFrame > TFRoughFrames
And FoundOblate = False Then
If LZV(CurrZone) -
TFOblatedelta < RZV(CurrZone) Then
Text1.Text = "Zone
" & CurrZone & " Is Closer to mirror, moving forward
0.01""" & " LZV =" & LZV(CurrZone) &
" RZV = " & RZV(CurrZone) & vbCrLf & Text1.Text 'Move tester
forward .01"
For Dummy = 1 To
TFOblateMove
Y = Y + 1
If Y > 7 Then Y = 0
Ypos = Ypos - 1
Out &H378,
(coil(x, Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked),
Abs(mnuSwapMotors.Checked)) + coil(Y, Abs(mnuinvert.Checked),
Abs(mnuTFswap.Checked), Abs(Not (mnuSwapMotors.Checked))))
Delay = 0
Do While Delay < Mindelay.Value * 3
Delay = Delay + 1
Loop
Next Dummy
CurrFrame = 1
LastMoveIsRight = False
LastMoveIsLeft = False
Else
FoundOblate = True
End If
End If
If CurrFrame > TFRoughFrames
And FoundOblate = True Then
If LZV(CurrZone) - TFRoughDelta
> RZV(CurrZone) Then
For Dummy = 1 To
TFRoughMove
Y = Y - 1
If Y < 0 Then Y = 7
Ypos = Ypos + 1
Out &H378,
(coil(x, Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked),
Abs(mnuSwapMotors.Checked)) + coil(Y, Abs(mnuinvert.Checked),
Abs(mnuTFswap.Checked), Abs(Not (mnuSwapMotors.Checked))))
Delay = 0
Do While Delay <
Mindelay.Value * 3
Delay = Delay + 1
Loop
Next Dummy
CurrFrame = 1
LastMoveIsRight = False
LastMoveIsLeft = False
End If
End If
If CurrFrame = TFFinalFrames And
FoundOblate = True Then
If LZV(CurrZone) >
RZV(CurrZone) Then
For Dummy = 1 To
TFFinalMoves
Y = Y - 1
If Y < 0 Then Y = 7
Ypos = Ypos + 1
Out &H378,
(coil(x, Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked),
Abs(mnuSwapMotors.Checked)) + coil(Y, Abs(mnuinvert.Checked),
Abs(mnuTFswap.Checked), Abs(Not (mnuSwapMotors.Checked))))
Delay = 0
Do While Delay <
Mindelay.Value * 3
Delay = Delay + 1
Loop
Next Dummy
CurrFrame = 1
LastMoveIsRight = False
LastMoveIsLeft = False
Else
If CurrZone = 1 And series
= 0 Then
Ypos = 0
Xpos = 0
TextBuff = Text2.Text
capGrabFrame lwndC
Call Plot_Zones
End If
If Metric = True Then
KEZ(CurrZone, series)
= Round(Ypos * StepSize * 25.4, 4)
Else
KEZ(CurrZone, series)
= Round(Ypos * StepSize, 4)
End If
Text2.Text = ""
For TxtZone = 1 To NZ
Text2.Text =
Text2.Text & "Zone " & TxtZone
For TxtSeries = 0 To
Reps
Text2.Text =
Text2.Text & vbTab & KEZ(TxtZone, TxtSeries)
Next TxtSeries
Text2.Text = Text2.Text
& vbCrLf
Next TxtZone
Text2.Text = Text2.Text
& vbCrLf & TextBuff
If Save_picture.Value = 1
Then
On Error Resume Next
MkDir textpath
MkDir textpath &
"\" & WorkFile
MkDir textpath &
"\" & WorkFile & "\Images"
MkDir textpath &
"\" & WorkFile & "\Images" & "\"
& "Test" & WorkNum
SavePicture
Picture1.Image, textpath & "\" & WorkFile &
"\Images\" & "Test" & WorkNum & "\"
& "Zone" & CurrZone & "rep" & series &
".bmp"
SavePicture
Picture1.Picture, textpath & "\" & WorkFile &
"\Images\" & "Test" & WorkNum & "\"
& "Raw_Zone" & CurrZone & "rep" & series
& ".bmp"
'MkDir textpath & "\Images"
'MkDir App.Path &
"\Images\" & WorkFile
'MkDir App.Path &
"\Images\" & WorkFile & "\" & "Test"
& WorkNum
'SavePicture
Picture1.Image, App.Path & "\Images\" & WorkFile &
"\" & "Test" & WorkNum & "\" &
"Zone" & CurrZone & "rep" & series &
".bmp"
'SavePicture
Picture1.Picture, App.Path & "\Images\" & WorkFile &
"\" & "Test" & WorkNum & "\" &
"Raw_Zone" & CurrZone & "rep" & series &
".bmp"
End If
Text1.Text = "Found
Zone " & CurrZone & " @ " & Time & " LZV
=" & LZV(CurrZone) & " RZV = " & RZV(CurrZone) &
vbCrLf & Text1.Text
End If
End If
If abort = 1 Or UloadMe = True
Then GoTo skip
Next CurrFrame
LastMoveIsRight = False
LastMoveIsLeft = False
FoundOblate = False
Next CurrZone
'Rewind our Platform to
Where ever it ended up back to 0
If Ypos > 1 Then WW = -1 Else WW = 1
Text1.Text = "Rewinding " &
Ypos & " Steps to " & WW & "steps" & vbCrLf
& Text1.Text
DoEvents
For Dummy = Ypos To -WW Step WW
Y = Y + -WW
If Y > 7 Then Y = 0
If Y < 0 Then Y = 7
Ypos = Ypos + WW
Out &H378, (coil(x,
Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked), Abs(mnuSwapMotors.Checked)) +
coil(Y, Abs(mnuinvert.Checked), Abs(mnuTFswap.Checked), Abs(Not
(mnuSwapMotors.Checked))))
Delay = 0
Do While Delay < Mindelay.Value * 2
Delay = Delay + 1
Loop
Next Dummy
If Xpos > 1 Then WW = -1 Else WW = 1
For Dummy = Xpos To -WW Step WW
x = x + WW
If x > 7 Then x = 0
If x < 0 Then x = 7
Xpos = Xpos + WW
Out &H378, (coil(x,
Abs(mnuinvert.Checked), Abs(mnuLRswap.Checked), Abs(mnuSwapMotors.Checked)) +
coil(Y, Abs(mnuinvert.Checked), Abs(mnuTFswap.Checked), Abs(Not
(mnuSwapMotors.Checked))))
Delay = 0
Do While Delay < Mindelay.Value * 2
Delay = Delay + 1
Loop
Next Dummy
If DebugWin = False Then 'Save the debug
text so as to save Memory!
Text1.Text = ""
Else
data = Text1.Text
file = App.Path +
"\Debug.txt"
Filehandle% = FreeFile
Open file For Append As #Filehandle%
Print #Filehandle%, data
Close #Filehandle%
Text1.Text = ""
End If
Next
series
skip:
If
abort = 1 Then
WorkZone = "Test Aborted!"
Else
WorkZone = "Test Complete! :)"
End If
capGrabFrame
lwndC
Call
Plot_Zones
MirRad.Enabled
= True
If
mnuinvert.Checked = False Then
Out &H378, 0
Else
Out &H378, MyMod
End If
If
UloadMe = True Then Unload Me
Manual
= True
Command3.Enabled
= True
Command1.Enabled
= True
Command5.Enabled
= True
Timer1.Enabled
= True
QueryPerformanceCounter
EndTime
QueryPerformanceCounter
TimeStart
Text2.Text
= "Elapsed Test Time, " & ((EndTime - StartTime) / TimeFreq) \ 60
& " Minutes " & ((EndTime - StartTime) / TimeFreq) Mod 60
& " seconds" & vbCrLf & Text2.Text
Text1.Text
= "Elapsed Test Time, " & ((EndTime - StartTime) / TimeFreq) \ 60
& " Minutes " & ((EndTime - StartTime) / TimeFreq) Mod 60
& " seconds" & vbCrLf & Text1.Text & Text2.Text
Chk_trak.Value
= 0
If
abort = 0 Then Play App.Path & "\Sound\transpec.wav"
If
abort = 0 And UloadMe = False And ZoneOn = True Then
If Reps > 0 Then
Dim StdDevTmp As Double
Dim a As Double
Dim b As Double
Dim tmp1 As Double
StdDev = 0
For a = 1 To NZ
StdDevTmp = 0
For b = 0 To Reps
StdDevTmp = StdDevTmp + KEZ(a,
b)
Next b
tmp1 = StdDevTmp / (Reps + 1)
StdDevTmp = 0
For b = 0 To Reps
StdDevTmp = StdDevTmp + ((tmp1
- KEZ(a, b)) ^ 2)
Next b
StdDev = StdDev + ((StdDevTmp /
(Reps)) ^ 0.5)
Next a
StdDev = StdDev / NZ
If Metric = False Then
Text1.Text = "Standard
Deviation for this test was: " & Round(StdDev, 5) & units &
vbCrLf & Text1.Text
Text2.Text = "Standard
Deviation for this test was: " & Round(StdDev, 5) & units &
vbCrLf & Text2.Text
StdDev = StdDev * 25.4
Else
Text1.Text = "Standard
Deviation for this test was: " & Round(StdDev, 5) & units &
vbCrLf & Text1.Text
Text2.Text = "Standard
Deviation for this test was: " & Round(StdDev, 5) & units &
vbCrLf & Text2.Text
End If
Else
StdDev = 0.01
End If
Call Command5_Click
End If
If
DebugWin = False Then 'Save the debug text so as to save Memory!
Text1.Text = ""
Else
data = Text1.Text
file = App.Path + "\Debug.txt"
Filehandle% = FreeFile
Open file For Append As #Filehandle%
Print #Filehandle%, data
Close #Filehandle%
Text1.Text = ""
End If
QueryPerformanceCounter
TimeEnd
Picture3.Visible
= True
Form_Resize
End
Sub