First time post, long time player. I have been playing with the Picaxe for several years, and this project has finally stumped me. I am working on a project to monitor LED life spans at various power settings, all the control functions have been straight forward, however the "elapsed" timer function is proving troublesome. Under simulation my timer sequence works as it should. However when I tie the system to the hardware, I cannot get the OLED to update the displayed elapsed time, other variables and signals work fine.
I am using a 28x2 and axe134y, and some of my research seems to indicate I may have a serout or interrupt conflict between the two MCs, which is beyond my current skills. Does anyone have some suggestions on what i may be missing?? Not to be presumptuous, but before someone asks, I will post the code I am currently working with. Thanks in advance.
BTW, Please feel free to critique my code formatting, I am a hardware guy by trade and all my SW experience is by hack.
I am using a 28x2 and axe134y, and some of my research seems to indicate I may have a serout or interrupt conflict between the two MCs, which is beyond my current skills. Does anyone have some suggestions on what i may be missing?? Not to be presumptuous, but before someone asks, I will post the code I am currently working with. Thanks in advance.
BTW, Please feel free to critique my code formatting, I am a hardware guy by trade and all my SW experience is by hack.
Code:
;Integrate timer sequance
;
;Uses 28x2,
;
;Symbols
Let dirsA = %10111 ;A0,A1,A2,A4 =Outputs
Let dirsB = %11100000 ;B7,B6,B5 =Outputs
Let dirsC = %01011110 ;C6,C4,C3,C2,C1 =Outputs
DACsetup %10101000 ;Sets up pin4 to analog out
fvrsetup fvr1024 ;Max ref voltage
Let w6 =4 ;LED 50%
Let w5 =4 ;Base value
Let b2 =0 ;Clear all signals out to track
pullup %00011111 ;enable pullups on portB0-4 on 28X2
Begin: ;LED Unit power up
Pause 1000
serout A.4,N2400,(254,212,"LED Use ");Line2 Display saved use time
pause 1000
serout A.4,N2400,(254,148,"LED Type DUV4a-2a ");Line3, icRev-oledRev
pause 1000
Pause 2000
let pinB.5 =0 ;clears previous lamp ON command
let pinC.4 =0 ;clears previous lamp ON to track
let pinC.3 =0 ;clears previous lamp RDY to track
LEDP: ;LED light power sequance, sets initial power and normal operations
;Temp check sequance
readtemp C.5, B1 ; Read the DS18B20 temperature
pause 10 ; Wait a while
serout A.4,N2400,(254,148," LED Temp = ",#B1,"c ");Text on 2nd line
If B1>40 then
serout A.4,N2400,(254,148,"LED is at Over-Temp ");Text on 2nd line
let pinC.6 =0 ;LED OVT error to track
else let pinC.6=1
endif
;Manual Operation
if pinB.2 =1 then ;checks for filter signal from track
let pinC.1 =1 ;filter active to track
else
let pinC.1=0 ;Filter not active to track
end if
if pinB.1 =0 then
let pinC.2 =1 ;Shutter active to track
else
let pinC.2 =0 ;Shutter not active to track
let pinC.2=0
end if
;Lamp on
If pinB.0 =0 then ;lamp on comand from track NEEDS A FLAG?
Pause 20 ;Wait lamp to turn on
let pinC.4 =1 ;lamp ON simulated confirm to track
Pause 20 ;wait lamp to warm up
let pinC.3 =1 ;lamp RDY simulated confirm to track
let w7=w6/1
serout A.4,N2400,(254,192,"LED Power = ",#w7,"mJ ");Displays current LED pwr setting line2
else
let pinC.4=0 ;lamp is not ON to the track
let pinC.3=0 ;lamp not RDY to track
goto LEDP
end if
;Timer Sequance
serout A.4,N2400,(254,212,"LED Use: ", #W12 ," Hrs ", #w11 ," min");Real time display line2
if pinB.1 =0 then
settimer t1s_4 ;Timer counts at 4mhz
;TMR3SETUP %00110011 ;1:8 prescale, on
;let w10=timer3
let w10=timer
end if
if pinB.1 =1 then
;Tmr3SETUP %00110010 ;1:8 prescale, off
settimer off
let timer=0
end if
if w10>59 then ;Elapsed Seconds
let w11=w11+1
let w10=0
let timer=0
end if
if w11>59 then ;Elapsed Minutes
let w12=w12+1 ;Elapsed Hours
let w11=0
end if
;Normal operation
If pinB.1 =0 and pinB.0 =0 then ;Shutter open and lamp ON comand
daclevel w6 ;Lamp on to set analog out level
serout A.4,N2400,(254,192,"LED Power = ",#w7,"mJ ") ;Displays current LED pwr setting line2
serout A.4,N2400,(254,128," LED is Radiating ") ;LED is ON line1
let pinC.2 =1 ;shutter not blocking to track
endif
if pinB.1 =1 then ;No shutter open comm from track
daclevel 0 ;No analog signal out to lamp
serout A.4,N2400,(254,128,"LED is Not Radiating") ;LED is OFF line1
let pinC.2 =0 ;shutter blocking to track
endif
if pinB.0 =1 then ;No lamp ON comm from track
daclevel 0 ;No analog signal out to lamp
serout A.4,N2400,(254,128,"LED is Not Radiating") ;LED is OFF line1
let pinC.2 =0 ;shutter blocking
let pinC.3 =0 ;Lamp not ready
goto LEDP
endif
if pinB.4 =1 and pinB.1 =0 and pinB.0 =0 then ;Inc ON, Shutter OPEN, and Lamp on
gosub PWRINC ;Power increase sub routine
end if
if pinB.3 =1 and pinB.1 =0 and pinB.0 =0 then ;DEC ON, Shutter OPEN, and Lamp on
gosub PWRDEC ;Power decrease sub routine
end if
;write 16,b10,b11 ;write saved power to manipulated power
if pinB.2 =1 and pinB.1 =0 and pinB.0 =0 and w6>w4 then ;Filter IN, Shutter open,lamp ON
gosub Filtr ;Filter sub routine
endif
if pinB.2 =0 and w6<w5 then
gosub FiltrOFF ;Saves adjusted value W6 to Main saved W5
end if
;let w5=w6
goto LEDP
PWRINC:
if w5<31 then ;Track increases LED pwr 32max
let w6=w5+1
let w5=w6
endif
write 16,b12,b13
if w5>31 then ;Track increases LED pwr
serout A.4,N2400,(254,192,"LED Power is at max ");Displays max power warning line2
endif
return
PWRDEC:
if w5>2 then ;Track decreases LED pwr 2 min
let w6=w5-1
let w5=w6
endif
write 16,b12,b13
;write 16,b10,b11
if w5<2 then ;Track decreases LED pwr
serout A.4,N2400,(254,192,"LED Power is at min ");Displays min power warning line2
endif
return
Filtr: ;Filter in sequance
;serout A.4,N2400,(254,212," Filter is active ");Displays filter status line4
let pinC.1 =1 ;filter active to track
if b3 bit 0 clear then
let w4=w5/2 ;cut power by50%
let w6=w4 ;send cut power to pwm value
setbit b3,0 ;sets power filtered bit
endif
return
FiltrOFF:
;serout A.4,N2400,(254,212,"Filter is not active");Displays filter status line4
let pinC.1=0 ;Filter not active to track
clearbit b3,0 ;clears power filtered bit
let w6=w5
;write 16,b12,b13 ;Saves adjusted value w6 to EPROM
return