8-input video switch Mark II

The Software

Type the software listing into the PICAXE programmer/editor and download it into the 18M2 chip.


	;External, Manual and Auto Camera Control

	#com4					;or as appropriate
	#picaxe 18M2
	#no_data

	init:
 	  let dirsC = %11001111			;set port C outputs
 	  let b1 = 0				;initial start camera
 	  read 0, b3				;
 	  if b3 = 0 then			;if max cameras not set then
 	    let b3 = 7		 		;set initial max cameras..
 	    write 0, b3				;and save.
 	  endif


	external:
 	  if pinB.7 = 0 then         		;switch 2 not set to internal
 	    let pinC.7 = 0			;pass-thru so dec point off
	    let b1 = pinsB and %00000111	;we only want pinsB0,B1,B2	
 	    let pinsC = b1  			;pass pinsB thru to pinsC
       
 	    goto external
 	  endif
  

	manual:
 	  if pinB.5 = 1 then			;switch 1 at B.5 is biased off
  	    let pinC.7 = 0	     		;manual so dec point off
 	    if b1 < 7 then			;manual scans through non-
	      inc b1				;existent cameras to allow
 	    else				;maximum auto-scan count
   	      let b1 = 0			;to be set & saved in eeprom
   	    endif
   	    let pinsC = b1
 	    pause 500
    
 	    goto external
 	  endif
  

	auto:
 	  if pinB.6 = 1 then			;switch 1 at B.6 is on Auto
   	    let pinC.7 = 1	     	 	;Auto so dec point is on
    
   	    let pinsC = b1 or %10000000		;make sure dec point stays on
    
  	    readadc B.4, w2			;get setting from pot.(0-255)
   	    let w2 = w2 + 50 * 2		;convert to 100-610 for 100ms loop
    						; = 10 to 61 seconds (approx)
   	    for w3 = 1 to w2
    	      pause 100	   			;delay before incrementing.

   	      if pinB.6 = 0 then external	;not Auto
  	      if pinB.7 = 0 then external	;not Internal

              readadc B.4, w4			;get setting from pot again
              let w4 = w4 + 50 * 2		;if it's changed then restart
              if w2 <> w4 then auto		;timing loop (saves waiting!)
 
   	    next w3
    
  	    read 0, b3				;get max setting from eeprom
 	    if b1 < b3 then			;and only scan up to max.
 	      inc b1
 	    else
   	      let b1 = 0
   	    endif
        
    	    goto auto
          else
            let pinC.7 = 0 			;not auto so dec point off    
          endif
  
	setmax:  
 	  if pinB.3 = 1 then 			;b1 = current count on pinsC
   	    if b1 = 0 then			;0 means only one camera!
  	      b1 = 1				;so default to 2 camera (0 and 1)
  	    endif				
            write 0, b1				;so save in eeprom as maximum
   	    for b0 = 0 to 20
              toggle C.7			
              pause 100				;confirm with dec. point.
            next
          endif					
  
          goto external

First Page | Previous Page