Code:
' MASTERBOARD.BAS
'TO DO: SET ALL REGISTERS AND DEFINES
Include "modedefs.bas"
define OSC 20
ADCON1 = %00000110
SerInPin var PORTC.7
SerOutPin var PORTC.6
ADRpin var PORTB.0
ProgLED var PORTB.7
HrtbtLED var PORTB.6
Address var byte
OutPin var byte
OutLevel var byte
BoardAdd var byte
UpdPinLvl var byte
low Progled
LOW HRTBTLED
Start:
if Adrpin then
serin SerInPin,t9600,["ADDRESS"],boardadd
IF (boardadd > 0) and (boardadd < 256) THEN
write 0,boardadd
high Progled
pause 1000
low progled
serout seroutpin,t9600,["Board address set to ",boardadd,13]
else
serout seroutpin,t9600,["Error: Address ",boardadd," not valid! Please use 1 to 256.",13]
endif
goto Start
else
read 0,boardadd
serin SerInPin,t9600,["A"],address '1 - 256
IF (ADDRESS > 0) and (ADDRESS <= 256) THEN
if address = boardadd then
serin SerInPin,t9600,["O"],outpin '1 - 24
if (outpin > 0) and (outpin <= 24) then
serin SerInPin,t9600,["L"],outlevel '0 = OFF, 5 = 5%, 10 = 10%, ...50 = 50%,...100 = 100% (by 5's)
if outlevel <= 100 then
write outpin,outlevel 'Output will match EEPROM location
read outpin,UpdPinLvl
serout seroutpin,t9600,["Updated output ",outpin," to level ",UpdPinLvl * 5,13]
select case outpin
case 1
serout portA.3,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 1
case 2
serout portB.1,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 2
case 3
serout portA.2,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 3
case 4
serout portB.2,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 4
case 5
serout portA.1,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 5
case 6
serout portB.3,n9600,[UpdPinLvl] 'CAT5 JACK 1, PIN 6
case 7
serout portE.0,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 1
case 8
serout portA.5,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 2
case 9
serout portE.1,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 3
case 10
serout portA.4,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 4
case 11
serout portE.2,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 5
case 12
serout portA.4,n9600,[UpdPinLvl] 'CAT5 JACK 2, PIN 6
case 13
serout portC.3,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 1
case 14
serout portC.2,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 2
case 15
serout portD.0,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 3
case 16
serout portC.1,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 4
case 17
serout portD.1,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 5
case 18
serout portC.0,n9600,[UpdPinLvl] 'CAT5 JACK 3, PIN 6
case 19
serout portD.4,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 1
case 20
serout portD.5,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 2
case 21
serout portC.5,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 3
case 22
serout portD.6,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 4
case 23
serout portC.4,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 5
case 24
serout portD.7,n9600,[UpdPinLvl] 'CAT5 JACK 4, PIN 6
END SELECT
else
serout seroutpin,t9600,["Error: Level ",outlevel," is not valid! Please use 0 to 100 (By FIVES).",13]
endif
else
serout seroutpin,t9600,["Error: Output ",outpin," is not valid! Please use 1 to 24.",13]
endif
endif
else
serout seroutpin,t9600,["Error: Address ",address," is not valid! Please use 1 to 256.",13]
endif
endif
TOGGLE HRTBTLED 'Flashing pretty damn fast!
goto Start
Code:
'DAUGHTERBOARD.BAS
Include "modedefs.bas"
DEFINE WRITE_INT 1
INTCON = %10010000
DimVal var byte
DimTblVal var byte
DimStore var byte
DimPause var byte
SerPin var portB.2
ZeroCross var portB.0
TriacTrig var portB.1
ON INTERRUPT GOTO ACDetect
Start:
serin serpin,t9600,dimval 'grab the Dim Value (0,5,10,15,...95,100)
write 0,dimval 'store the dim value in mem pos 0
read 0,DimStore 'read mem 0, put it in DimStore
dimstore = dimstore / 5 'convert 0-100 to 0-20 for lookup table (0=0, 5=1, 10=2, ... , 95=19, 100=20)
if DimStore > 20 then goto start 'testing for 0-20, exit if greater than 20
LOOKUP DimStore,["F",202,195,188,181,174,166,157,147,135,104,74,62,52,43,35,28,21,14,7,"N"],DimPause
goto start
ACDetect:
low triactrig
select case dimpause
case "F" 'F = OFF
low triactrig
case "N" 'N = ON
high triactrig
case else
pauseus dimpause * 5 'multiply 8 bit value by 5 for true delay
high triactrig 'fire triac after delay
end select
RESUME
Bookmarks