'******************** '* Cable tester '* Phillip Webb 11/2/2011 '* PICAXE 28X1 '* deleted battery test '* Ver 3 '******************** 'Short circuit bits symbol SC0 = 4 symbol SC1 = 5 symbol SC2 = 6 symbol SC3 = 7 'Open circuit bits symbol OC0 = 3 symbol OC1 = 2 symbol OC2 = 1 symbol OC3 = 0 'Misc symbols symbol testshots = b1 'maximum core scans symbol testime = b2 'the number of repeat scans per core - varies symbol volts = b6 'analogue voltage symbol tempbyte = b4 'temporary value symbol powerdownsecs = w4 '(b8.b9) symbol x = w5 '(b10,11) 'set values of variables testshots = 60 'sets the maximum number of scans each core gets powerdownsecs = 300 'seconds until power down testime = 5 'set the initial testime to fast scan settimer 49910 'sets the preload for 1 second timer clicks 'Initialise and lamp test gosub ledson gosub ledsoff 'main scan loop main: 'powerdown check if timer = powerdownsecs then 'Power down after time out gosub ledsoff do disablebod 'disable brown out detector sleep 13 ' sleep 30 secs enablebod 'enable brown out detector high 3 ' flash led pause 100 low 3 loop end if 'change the scan rate testime = testime - 1 'slow scan at first to observe LEDs if testime = 0 then testime = testshots end if if testime = 52 then ' speed up to fast scan testime = 20 end if 'Check each core testcore0: high portc 4 'core 0 for x = 1 to testime 'test shell core 0 if portc pin0 = 0 then 'OC of core 0 high OC0 end if 'note core 0 & core 1 normally SC if portc pin2 = 1 then 'SC to core 2 high SC0 end if if portc pin3 = 1 then 'SC to core 3 high SC0 end if next x low portc 4'0 'set core low testcore1: high portc 5 'core 1 for x = 1 to testime 'test screen core 1 if portc pin1 = 0 then 'OC of core 1 high OC1 end if 'note core 0 & core 1 normally SC if portc pin2 = 1 then'SC to core 2 high SC1 end if if portc pin3 = 1 then 'SC to core 3 high SC1 end if next x low portc 5 'set core low testcore2: high portc 6 'core 2 for x = 1 to testime 'test Hot core 2 if portc pin2 = 0 then'OC of core 2 high OC2 end if if portc pin0 = 1 then'SC to core 0 high SC2 end if if portc pin1 = 1 then'SC to core 1 high SC2 end if if portc pin3 = 1 then 'SC to core 3 high SC2 end if next x low portc 6 'set core low testcore3: high portc 7 'core 3 for x = 1 to testime 'test Cold core 3 if portc pin3 = 0 then 'OC of core 3 high OC3 end if if portc pin0 = 1 then 'SC to core 0 high SC3 end if if portc pin1 = 1 then 'SC to core 1 high SC3 end if if portc pin2 = 1 then 'SC to core 2 high SC3 end if next x low portc 7 'set core low goto main 'LEDs all on ledson: for x = 0 to 7 'set all SC & OC LEDS high x next x for x = 4 to 7 high portc x'set Send LEDs next x pause 1000 return 'LEDs all off ledsoff: for x =0 to 7 'reset all LEDs low x next x for x = 4 to 7 'reset send leds low portc x next x pause 200 return