0

recursion

Anyone who has ever programmed a procedure for an R decade has certainly wondered how to do it the easiest way.

There are different possibilities:
1. Continuing in a line (spaghetti) => this is very time-consuming and error-prone
2. In a loop => make sure that all results appear in the log
3. In a recursion => you have to be careful that the maximum depth of 8 is not exceeded

The last option described should not be used after the Met / Cal help.
But it is an elegant and powerful way of programming and it works. This proves the test procedure (see attachment). It would only be nice if the maximum depth were at least 10. Then all 10 settings of a decade could be handled with a call.


==========================================================================
INSTRUMENT: Test Rekursion
INSTRUMENT: SUB Rekursion
DATE: 05-04-2018 08:34:58
AUTHOR: Reiner Kuhnle
REVISION: 1.2
ADJUSTMENT THRESHOLD: 70%
NUMBER OF TESTS: 3
NUMBER OF LINES: 41
==========================================================================
STEP FSC RANGE NOMINAL TOLERANCE MOD1 MOD2 3 4 CON

1.001 ASK- F

1.002 JMPL SUB_Rekursion psubi("SUB Rekursion")
# main ######################################################################
1.003 HEAD Main Procedure
1.004 MATH R = 0; depth = 0
1.005 MATH @Param1 = R; @Param2 = depth
1.006 CALL SUB Rekursion
1.007 END
1.008 EVAL Dummy
#############################################################################
2.001 LABEL SUB_Rekursion
2.002 HEAD Sub Procedure
2.003 MATH R = @Param1; depth = @Param2
2.004 MATH R = R + 1; depth = depth + 1
2.005 HEAD -2 depth: [V depth]
2.006 MATH mem = R
2.007 ACC Z 0.01%
2.008 MEMI Input Value of R ([V R] ± 0.1%) Ohm
2.009 MEMCX Z 0.1%

3.001 IF depth < 8
3.002 MATH @Param1 = R; @Param2 = depth
3.003 CALL SUB Rekursion
3.004 ENDIF
3.005 HEAD -2
3.006 END
#############################################################################

2 comments

Date Votes
0
Avatar
Alan Woods

your concept is a good one I have modified it a bit to do decade boxes would be interested in your feedback

Delta Utility Services MET/CAL Procedure

============================================================================

INSTRUMENT: test recursion2

DATE: 11-07-2018 13:02:23

AUTHOR: Alan Woods

REVISION:

ADJUSTMENT THRESHOLD: 100%

NUMBER OF TESTS: 1

NUMBER OF LINES: 33

=============================================================================

STEP FSC RANGE NOMINAL TOLERANCE MOD1 MOD2 3 4 CON

#set accuracy

1.001 MATH M[6]= 0.5

# testing 1 to 10 ohms

1.002 MATH M[2]=1

1.003 MATH S[2] =""

1.004 CALL Test RekursionLow

1.005 CALL Test RekursionHigh

# testing 10 to 100 ohms

1.006 MATH M[2]=10

1.007 MATH S[2] =""

1.008 CALL Test RekursionLow

1.009 CALL Test RekursionHigh

# testing 1 to 10 kohms

1.010 MATH M[2]=1

1.011 MATH S[2] ="k"

1.012 CALL Test RekursionLow

1.013 CALL Test RekursionHigh

# testing 1 to 10 Mohms

1.014 MATH M[2]=1

1.015 MATH S[2] ="M"

1.016 CALL Test RekursionLow

1.017 CALL Test RekursionHigh

END

 

Delta Utility Services MET/CAL Procedure

=============================================================================

INSTRUMENT: Test RekursionLow

INSTRUMENT: Test RekursionHigh

INSTRUMENT: SUB Rekursion

DATE: 11-07-2018 13:00:30

AUTHOR: Reiner Kuhnle alan wooods

REVISION: 1.2

ADJUSTMENT THRESHOLD: 70%

NUMBER OF TESTS: 5

NUMBER OF LINES: 69

=============================================================================

STEP FSC RANGE NOMINAL TOLERANCE MOD1 MOD2 3 4 CON

1.001 ASK- F

1.002 ASK+ U

1.003 JMPL SUB_Rekursion psubi("SUB Rekursion")

# main ######################################################################

1.004 HEAD Main Procedure

#Set to tolerance

1.005 TOL M[6]%

# if high multiply decade start value by 5

1.006 JMPF 1.009 Test RekursionHigh

1.007 MATH R = 5*M[2]; depth = 0

1.008 JMP 1.010

1.009 MATH R = 0; depth = 0

1.010 MATH @Param1 = R; @Param2 = depth

1.011 CALL SUB Rekursion

1.012 END

1.013 EVAL Dummy

#############################################################################

2.001 LABEL SUB_Rekursion

2.002 HEAD Sub Procedure

2.003 MATH R = @Param1; depth = @Param2

# add the decade start value to current value

2.004 MATH R = R + m[2]; depth = depth + 1

2.005 HEAD -2 depth: [V depth]

2.006 MATH mem = R

#set accuracy to scale

2.007 MATH m[10]=zcmpi(S[2],"M")

2.008 IF zcmp(S[2],"M")

2.009 ACC MZ 0.01%

2.010 ENDIF

2.011 IF zcmp(S[2],"k")

2.012 ACC kZ 0.01%

2.013 MATH S[3]="kZ"

2.014 ENDIF

2.015 IF zcmp(S[2],"")

2.016 ACC Z 0.01%

2.017 ENDIF

2.018 MEMI Input Value of R ([V R] ± 0.1%) [S2]Ohm

#output value according to scale

2.019 IF zcmp(S[2],"M")

2.020 MEMCX MZ TOL

3.001 ENDIF

3.002 IF zcmp(S[2],"k")

3.003 MEMCX kZ TOL

4.001 ENDIF

4.002 IF zcmp(S[2],"")

4.003 MEMCX z TOL

5.001 ENDIF

5.002 IF depth < 5

5.003 MATH @Param1 = R; @Param2 = depth

5.004 CALL SUB Rekursion

5.005 ENDIF

5.006 HEAD -2

5.007 END

#############################################################################

 

 

 

0
Avatar
Reiner Kuhnle

Hi Alan,
that looks very good.
To program a resistance decate with a few lines in a clear way.

 

Please sign in to leave a comment.