' D:\Projects\ATU\SoftATU_2.bs2 ' 18th August 2003 ' This program receives 1200 Baud serial data ' writes the bits to the relays ' Debug display and "R" responses commented out to speed up loop '{$STAMP BS2} '{$PBASIC 2.5} '{$PORT COM2} Tune VAR Byte ' byte for the Tune (CTrx) cap relays msTune VAR tune.HIGHNIB ' MS nibble lsTune VAR tune.LOWNIB ' LS nibble Band VAR Byte ' byte for the Band inductor relays msBand VAR band.HIGHNIB ' MS nibble lsBand VAR band.LOWNIB ' LS nibble Load VAR Byte ' byte for the Load (CAnt) cap relays msLoad VAR load.HIGHNIB ' MS nibble lsLoad VAR load.LOWNIB ' LS nibble sData VAR Byte ' serial receive data register addr VAR sData.HIGHNIB ' MS nibble bits VAR sData.LOWNIB ' LS nibble ' Initialise shift registers Tune = $00 ' start with all relays de-energised Band = $00 Load = $00 SHIFTOUT 10, 9, 0, [Load, Band, Tune] PULSOUT 8, 5 '10 us Strobe pulse start: SERIN 6, 813, [sData] 'Serial in pin 6, 1200 Bd, 8-bit, non-inverted, no parity ' DEBUG HEX sData, CR ' Display received hex char (comment out to inc loop speed) IF (addr = 0) THEN '$0x, MS nibble of Tune msTune = bits ELSEIF (addr = 1) THEN '$1x, LS nibble of Tune lsTune = bits ELSEIF (addr = 2) THEN '$2x, MS nibble of Band msBand = bits ELSEIF (addr = 3) THEN '$3x, LS nibble of Band lsBand = bits ELSEIF (addr = 4) THEN '$4x, MS nibble of Load msLoad = bits ELSEIF (addr = 5) THEN '$5x, LS nibble of Load lsLoad = bits ENDIF SHIFTOUT 10, 9, 0, [Load, Band, Tune] PULSOUT 8, 5 '10 us Strobe pulse ' SEROUT 7, 813, ["R"] 'respond with "R" (comment out to inc loop speed) GOTO START