IGIF16
Junior Member level 2
hi
i wrote this code every thing is good but my problem is the Pic16877A take along time to response, like when this get true
"if out_light > 1 then
portc.2 = 0
else portc.2 = 1
end if"
the portc.2 take at lest 2 second to be 0 :shock:
but i need it simultaneously
i don't have any problem with the other output delay but this portc.2 i need it simultaneously :twisted:
i wrote this code every thing is good but my problem is the Pic16877A take along time to response, like when this get true
"if out_light > 1 then
portc.2 = 0
else portc.2 = 1
end if"
the portc.2 take at lest 2 second to be 0 :shock:
but i need it simultaneously
i don't have any problem with the other output delay but this portc.2 i need it simultaneously :twisted:
Code:
dim rs_temp as integer
dim st_temp as integer
dim out_light as integer
dim x as integer
dim y as integer
dim digit_1 as byte
dim digit_10 as byte
dim Rh as integer
dim q as integer
dim tt as integer
dim i as byte
dim in as short
dim out as short
dim c4_perv as byte
dim c5_perv as byte
sub function mask(dim num as byte) as byte
select case num
case 0 result = $3F
case 1 result = $06
case 2 result = $5B
case 3 result = $4F
case 4 result = $66
case 5 result = $6D
case 6 result = $7D
case 7 result = $07
case 8 result = $7F
case 9 result = $6F
end select
end sub
main:
trisa = $FF
trisb = $0F
trisd = $00
trisc = $30
trise = $00
porte = 0
portd = 0
Adcon1 = %10000010
igi:
rs_temp = ADC_Read(1)
rs_temp = (rs_temp - 546)/2
st_temp = ADC_Read(2)
st_temp = ((st_temp/50) + 14)
Rh = ADC_Read(4)
Rh = (Rh - 4)*7
for i =1 to 40 "for multiplexing 4-digit 7segement to
x = rs_temp mod 10 "display the temperature
tt = mask (x)
portd = tt xor $FF
porte.1 = 1
delay_ms (5)
porte.1 = 0
x = (rs_temp /10) mod 10
tt = mask (x)
portd = tt xor $FF
porte.0 = 1
delay_ms (5)
porte.0 = 0
x = 0
tt = mask (x)
portd = tt xor $FF
porte.2 = 1
delay_ms (5)
porte.2 = 0
portd = $46
portc.3 = 1
delay_ms (5)
portc.3 = 0
next i
delay_ms (2500)
for i = 1 to 40 "for multiplexing 4-digit 7segement to
y = Rh mod 10 "display the humidity
q = mask (y)
portd = q xor $FF
porte.1 = 1
delay_ms (5)
porte.1 = 0
y = (Rh /10) mod 10
q = mask (y)
portd = q xor $FF
porte.0 = 1
delay_ms (5)
porte.0 = 0
y = (Rh /100) mod 10
q = mask (y)
portd = q xor $FF
porte.2 = 1
delay_ms (5)
porte.2 = 0
portd = $09
portc.3 = 1
delay_ms (5)
portc.3 = 0
next i
delay_ms (2500)
if rs_temp > st_temp then
portc.0 = 1
else portc.0 = 0
end if
if rs_temp < st_temp then
portc.1 = 1
else portc.1 = 0
end if
out_light = ADC_Read(3) "for outer lighting
out_light = (out_light) " from LDR
if out_light > 1 then
portc.2 = 0
else portc.2 = 1
end if
goto igi
end.