thanks for the feedback. Faulty ground on optical switch is not the problem. Like I said I can take out a portion of the code and the optical switch works well..... I rewrote the code yet again and see the same issue. I realize it is not elegant, and it should dwell in each loop until the correct cadence....but what I see is it vectors outside of the loop and enables the start switch which is deliberated left out of the normal loop....it is only used once upon start up to kick start the checkleaf and checkopt loops. see below.
Code:@ device pic16F877A, HS_OSC, LVP_OFF, WDT_OFF ; @ Device pic16F877A, HS_OSC, BOD_OFF, PWRT_ON, WDT_ON, PROTECT_OFF DEFINE OSC 20 ;set ports to output TRISA = %00000000 TRISB = %00000111 TRISC = %00000000 TRISD = %00000000 ; analog portA direction ADCON1 = 7 CMCON = 7 ;constants brake Con %00000011 stmot con %00000000 runmot con %00000001 ;variables timeout var byte ;initialization portc = stmot HomeStart: if portb.0 = 0 then portc = runmot goto checkleaf endif goto homestart checkleaf: if portb.1 = 0 then portc = brake pause 500 portc = stmot goto checkopt endif goto checkleaf checkopt: if portb.2 = 1 then portc = runmot goto checkleaf endif goto checkopt




Bookmarks