Chk1
Listing index
Chk3
Routine:        Chk2
Function:       Finds the minimum motor speed, where angle > 0.
Called by:      Range
Calls:          Read6
Entry:          None
Exit:           Mtrmin is set
Preserved:      None


CHK2    LD      A,(MTRSPD)
        LD      (MTRMIN),A
; Start at the minimum motor speed specified by the constant, Mtrspd. Below this speed the motor will not turn at all.
        XOR     A
        OUT     (142),A
CHK2A   LD      A,(MTRMIN)
        OUT     (143),A
        LD      B,5
; 5 revolutions per reading.
CHK2B   IN      A,(6)
        LD      (TIMERB),A
; Initialise timer; Read6 is used to check that 2 seconds have not passed. If no angle is seen in this time, it is assumed that the current speed is too slow, and a jump is made.
CHK2C   CALL    READ6
        JR      NC,CHK2F
        IN      A,(14)
        RL      A
        JR      C,CHK2C
        IN      A,(6)
        LD      (TIMERB),A
CHK2D   CALL    READ6
        JR      NC,CHK2F
        IN      A,(14)
        RL      A
        JR      NC,CHK2D
        DJNZ    CHK2B
CHK2E   LD      A,255
        OUT     (143),A
; Stop motor and return when a non-zero angle has been measured.
        RET
CHK2F   LD      A,(MTRMIN)
        SUB     A,8
        LD      (MTRMIN),A
; Increase motor speed and try again.
        JR      Z,CHK2E
        JR      CHK2A
 
Chk1
Listing index
Chk3