Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LM35 and pic16f877 using picbasic

Status
Not open for further replies.

kensquall

New Member
can someone help me in my project?...i am using a pic16f877 and lm35 with the output of 4x7 segment..i am using picbasic but it is not working well...so can someone help me..thanks
 
can someone help me in my project?...i am using a pic16f877 and lm35 with the output of 4x7 segment..i am using picbasic but it is not working well...so can someone help me..thanks

hi,
Post your program code..
 
What temperature range are you trying to cover? What is the Vref for the PIC's AD converter?
 
0 degree celcius to 150 degreee celcius with decimal point...sorry but i dont have a program yet..i just want a circuit and program that works in proteus..if you have can you tell me..if thats ok to you..
 
Let me try the question again. What voltage is the PIC powered from?
 
Last edited:
It's not that hard to write your own code for pic basic pro

Just open micro code studio and set for the chip you want to use 16f877

define your adc pin Example
Code:
DEFINE ADC_BITS 10       ' Set number of bits in result
DEFINE ADC_CLOCK 3     ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds 

TRISA = 255 ' Set PORTA to all input
ADCON1 = 2  ' PORTA is analog
ADCIN 0, B0 ' Read channel 0 to B0

Make some Variables

ADCIN 0,temp which puts the ADC value in temp

scale temp * 5000 / 1023
scale error * 5000 /1023
temp = temp - error

Then divide temp by 10

Place output to display
 

Attachments

  • LM35.PNG
    LM35.PNG
    20.3 KB · Views: 805
Last edited:
this is my program...the truth is i never learn to program using picbasic but i just in the internet and i dont know where is the error because when i use in proteus the display always 0000 nothing happen..can you help me fix this code..i use bc547 as decoder to commom cathode:
here is my program:

Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 12
Define ADC_SAMPLEUS = 50
Dim digit As Byte 'input variable for GETMASK subroutine
Dim digit1 As Byte 'current digit1
Dim digit2 As Byte 'current digit2
Dim digit3 As Byte 'current digit3
Dim digit4 As Byte 'current digit4
Dim mask As Byte 'output variable from GETMASK subroutine
Dim mask1 As Byte 'current digit1 mask
Dim mask2 As Byte 'current digit2 mask
Dim mask3 As Byte 'current digit3 mask
Dim mask4 As Byte 'current digit4 mask
Dim phase As Byte
Dim temp1 As Word
Dim temp2 As Word
Dim temp3 As Word
Dim i As Byte
Dim n As Byte
Symbol d1enable = PORTD.4 'enable line for display1
Symbol d2enable = PORTD.5 'enable line for display2
Symbol d3enable = PORTD.6 'enable line for display3
Symbol d4enable = PORTD.7 'enable line for display4
TRISB = %00000000 'set PORTB pins as outputs
TRISD.4 = 0 'set RD4 pin as output
TRISD.5 = 0 'set RD5 pin as output
TRISD.6 = 0 'set RD6 pin as output
TRISD.7 = 0 'set RD7 pin as output
d1enable = False
d2enable = False
d3enable = False
d4enable = False
mask1 = 0
mask2 = 0
mask3 = 0
mask4 = 0
phase = 1
INTCON.T0IE = 1 'enable Timer0 interrupts
INTCON.GIE = 1 'enable all un-masked interrupts
OPTION_REG.T0CS = 0 'set Timer0 clock source to internal instruction cycle clock
ADCON1 = %10001110
ADCON0 = %01000001
loop:
Adcin 0, temp1
Goto one
one:
temp2 = (temp1 / 1023) * 5
temp3 = temp2*100
digit1 = temp3 / 1000 'get current digit1
temp3 = temp3 Mod 1000
digit2 = temp3 / 100 'get current digit2
temp3 = temp3 Mod 100
digit3 = temp3 / 10 'get current digit3
temp3 = temp3 Mod 10
digit4 = temp1 'get current digit4
TMR0 = 0 'reset Timer0 to prevent its interrupt before both masks are determined
digit = digit1
Gosub getmask 'get mask for digit1
mask = mask1
Gosub show1
Goto three
digit = digit2
Gosub getmask 'get mask for digit2
mask2 = mask
Gosub show2
Goto four
digit = digit3
Gosub getmask 'get mask for digit3
Gosub show3
digit = digit4
Gosub getmask 'get mask for digit4
Gosub show4
'WaitMs 1500
Goto loop
End


getmask: 'get appropriate 7-segment mask for input digit
mask = LookUp(0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0xff), digit
Return

show1: 'show digit1 on its display
d2enable = False
d3enable = False
d4enable = False
PORTB = mask1
d1enable = True
Return

show2: 'show digit2 on its display
d1enable = False
d3enable = False
d4enable = False
PORTB = mask2
d2enable = True
Return

show3: 'show digit3 on its display
d2enable = False
d1enable = False
d4enable = False
PORTB = mask3
d3enable = True
Return

show4: 'show digit4 on its display
d2enable = False
d3enable = False
d1enable = False
PORTB = mask4
d4enable = True
Return
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top