Hello !!!
I need help. I want to make a interface that will read impulses from 4 electro mechanical counters at once. The counters operate at different speeds and duration. I have solution for 2 counters, but for 4, hm? Please HELP

Code:
DEFINE OSC 8

pinin	VAR	PORTC.7		
pinout	VAR	PORTC.6		

TRISB = 255

B var byte

Serout2 pinout,84,["OK"]

Main:
     B = PORTB
     pause 10
     If PORTB <> 255 then Counter
     goto Main

Counter:
   B = PORTB
   SELECT CASE B
      
      CASE 255
           GOTO MAIN
      CASE 254
           Serout2 pinout,84,["1"]  'counter 1'
           GOTO CEK
      CASE 253
           Serout2 pinout,84,["2"]  'counter 2'
           GOTO CEK1
      CASE 252
           Serout2 pinout,84,["3"]  'counter 1 and counter 2'
           GOTO CEK2
   END SELECT
   
  GOTO Counter
  
CEK:
  B = PORTB
     SELECT CASE B
      
      CASE 255
           GOTO MAIN
      CASE 253
           Serout2 pinout,84,["2"]
           GOTO CEK1
      CASE 252
           Serout2 pinout,84,["2"] 
           GOTO CEK2
   END SELECT
   
   GOTO CEK
   
CEK1:
  B = PORTB
     SELECT CASE B
      
      CASE 255
           GOTO MAIN
      CASE 254
           Serout2 pinout,84,["1"]
           GOTO CEK
      CASE 252
           Serout2 pinout,84,["1"] 
           GOTO CEK2
   END SELECT
   
   GOTO CEK1
   
CEK2:
  B = PORTB
     SELECT CASE B   
      CASE 255
           GOTO MAIN
      CASE 253
          GOTO CEK1
      CASE 254
          GOTO CEK

   END SELECT
   
   GOTO CEK2