Ali A. Noori
Newbie level 3
- Joined
- Mar 14, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,306
Hi
I found this Website very interesting and I have some equations in my attached project
I designed my project based on PIC 16F877A by using Proteus 7.6 and Proton IDE basic
the result of pressure in LCD is incorrect
Basic Code In PROTON PROGRAM
'============================
Device = 16F877A
XTAL 4
Cls
ALL_DIGITAL true
' LCD connections
'*****************
LCD_DTPIN PORTB.0
LCD_RSPIN PORTC.1
LCD_ENPIN PORTC.0
LCD_INTERFACE 8
'*****************
' Define A/D converter parameters
Declare ADIN_RES 8 ' 8-bit result required
Declare ADIN_TAD FRC ' RC OSC chosen
Declare ADIN_STIME 50 ' Allow 50us sample time
' Variables
'
Dim R As Float ' A/D converter result
Dim P1 As Float ' pressure in mmhg
Dim P2 As Float
Input PORTA.0 'TRISA = 1 ' RA0 (AN0) is input
Output PORTB 'TRISB = 0 ' PORTB is output
DelayMS 500 ' Wait 0.5sec for LCD to initialize
'
' Initialize the A/D converter
'
ADCON1 = 0 ' Make AN0 to AN4 as analog inputs, Analogue to Digital Converter control register,
'that chooses which pin is analogue and which is digital.
' make reference voltage = VDD
ADCON0 = %11000001 ' A/D clock is internal RC, select AN0 ,Analogue to Digital Converter control register.
' Turn on A/D converter
Cls ' Clear LCD
loop:
'
' Start A/D conversion
'
ADCIN 0, R ' Read Channel 0 data
P1= (0.1087*R + 9.0175)
P2= P1 *760/101.325 ' convert 760mmhg=101.325 kPa
Print At 1,1,"Pressure= ",DEC2 P2, "KPa" ' Display decimal part
DelayMS 250 ' Wait 1 second
GoTo loop ' Repeat
End
I found this Website very interesting and I have some equations in my attached project
I designed my project based on PIC 16F877A by using Proteus 7.6 and Proton IDE basic
the result of pressure in LCD is incorrect
Basic Code In PROTON PROGRAM
'============================
Device = 16F877A
XTAL 4
Cls
ALL_DIGITAL true
' LCD connections
'*****************
LCD_DTPIN PORTB.0
LCD_RSPIN PORTC.1
LCD_ENPIN PORTC.0
LCD_INTERFACE 8
'*****************
' Define A/D converter parameters
Declare ADIN_RES 8 ' 8-bit result required
Declare ADIN_TAD FRC ' RC OSC chosen
Declare ADIN_STIME 50 ' Allow 50us sample time
' Variables
'
Dim R As Float ' A/D converter result
Dim P1 As Float ' pressure in mmhg
Dim P2 As Float
Input PORTA.0 'TRISA = 1 ' RA0 (AN0) is input
Output PORTB 'TRISB = 0 ' PORTB is output
DelayMS 500 ' Wait 0.5sec for LCD to initialize
'
' Initialize the A/D converter
'
ADCON1 = 0 ' Make AN0 to AN4 as analog inputs, Analogue to Digital Converter control register,
'that chooses which pin is analogue and which is digital.
' make reference voltage = VDD
ADCON0 = %11000001 ' A/D clock is internal RC, select AN0 ,Analogue to Digital Converter control register.
' Turn on A/D converter
Cls ' Clear LCD
loop:
'
' Start A/D conversion
'
ADCIN 0, R ' Read Channel 0 data
P1= (0.1087*R + 9.0175)
P2= P1 *760/101.325 ' convert 760mmhg=101.325 kPa
Print At 1,1,"Pressure= ",DEC2 P2, "KPa" ' Display decimal part
DelayMS 250 ' Wait 1 second
GoTo loop ' Repeat
End