Olla
peeps,
As
in for today, I will be going to explain on the testing and troubleshooting of
my prototype. As well as a little bit about my progress on my programming. I'm
aware that I have a bad programming skill, and so far my programming is still
under testing and still not done yet. Maybe, I might need more time to finish
my program. Sob3 :(
Part
1: Testing and Troubleshooting
In
Figure 1, I did some testing and troubleshooting in my room. I manage to borrow
the analogue trainer and the oscilloscope from the lab. Special thanks to Madam
Zaba and Mr. Faizal for approving my request to borrow these equipments for
testing. Its really convinient and helpful. :)
As
you can see in Figure 1 below, I give a supply of 9 DC Volt to my power supply
(mainboard) to test my circuit functionality.
Figure 1: Combined circuits
Power
supply Indicator (green LED)
As
you can see in Figure 1, once power supply is given to the prototype, you can
see that there is a green light on the mainboard. This green LED indicates that
the power supply circuit is ok. The power supply is using a voltage regulator
of 7805 to regulate the 9 DC Volts to 5 DC Volts. As long as the green LED is
still on, this indicates that the supply maintain a 5 DC Volts supply into the
circuit. If the LED is off, this indicates that more than 5 DC Volts enters the
circuit and it burns the LED.
Switches
Basically
there are 3 input switches where the first switch has been program to activate
the LM35 circuit and display the LM35 result as body temperature at the LCD in
degree Celsius. Next, is the second switch where it is program to activate the
Heart Rate circuit and display the Heart Rate value on the LCD in beats per
minutes (BPM). Finally is the third switch, which is program to activate the
Blood Pressure circuit and display the Blood Pressure value at the LCD in mmHG.
Part
2: Programming
I
am using PIC16F887A microcontroller for my project and I did some exploring on
the programming method....what language to use, what IDE and also which
compiler is best suited for this PIC... :)
So
I have decided to use assembly language instead of C language... The main
reason is that the project I been doing requires alot of programming lines and
I'm just afraid that the flash memory of the microcontroler is small and cannot
accomodate all the programming lines. For assembly language, it only require
small flash memory when compared to C language...so I have decided to use
assembly to program my project to save my flash memory space.
After
doing research on a few software, namely MPLab, CCS compiler, Proteus, PICKit2,
8051 Dats and excreta. I realise that MPLab, CCS compiler is to write and
compile C language. MPLab can be use to write and compile assembly language as
well. Then I can use PICKit2 to burn the compiled program into the PIC
microcontroller. I can't use 8051 Dats because it can only write and compile
Atmel microcontroller only.
So,
there we have it, I decided to use MPLab together with PICKit2 for my project
as it is the most suitable software for PIC mocrocontrollers; to write, compile
and burn my program.
;Project:
HOME PATIENT MONITOR
;By
Idriah Safriza Bte Idris Chin (51216110284)
;Universiti
Kuala Lumpur British Malaysian Institute (UniKL BMI)
;Project
Supervisor: Mdm Zabariah Binti Zakaria
;------------------------------------------------------------------------Home
Patient Monitor-------------------------------------------------------------------------------
list p=pic16f877a
include p16f877a.inc
__config 0x1E72
errorlevel -302 ;Suppress
bank warning
CBlock
0x20
N
;
Delay registers
N1 ;
Delay registers
count1 ;
Delay registers
counta ;
Delay registers
countb ;
Delay registers
countc ;
Delay registers
FIXDELAY ;
Delay registers
visdelay ;
Delay registers
dataL
COUNTER1
COUNTER2
temp_dig
rmng_num ;
Digit breaker registers
quotient
temp_num
rmng_num2 ;
Digit breaker registers
quotient2
temp_num2
ANALOGL ;
ANALOG variable registers
ANALOGH
ANALOGfract
Bigest
digitANALOGdata0 ;
ANALOG data digit registers
digitANALOGdata1
digitANALOGdata2
digitANALOGdataL0
digitANALOGdataL1
digitANALOGdataL2
ANALOGnonfract0 ;
Actual ANALOG digit registers
ANALOGnonfract1
ANALOGnonfract2
ANALOGfract0
ANALOGfract1
tempHtrans
tempLtrans
ANALOGHtrans
ANALOGLtrans
A1
A2
A3
D1
D2
D3
rxtime1
rxtime2
ANALOGL2 ;
ANALOG variable registers
ANALOGH2
ANALOGfract2
digitANALOGdata02 ;
ANALOG data digit registers
digitANALOGdata12
digitANALOGdata22
digitANALOGdataL02
digitANALOGdataL12
digitANALOGdataL22
ANALOGnonfract02 ;
ANALOG digit registers
ANALOGnonfract12
ANALOGnonfract22
ANALOGfract02
ANALOGfract12
ANALOGHtrans2
ANALOGLtrans2
M1
M2
TH
TL
TXSW
TimeOutCounter
TimeOutCounter1
F2
F3
F4
F5
F6
F7
F8
U1
U2
U3
ENDC
org
0x00
nop ;
Reserved for ICD II.
goto start
;-----------------------------------------Start---------------------------------------------------
start
call
initports ;
Initialize Ports as output/inputs.
call
setupUART
call
INITLCD ;
Initialize LCD
call
clrscreen ;
Clear LCD SCREEN
bcf
PORTD,3
bcf
PORTC,6
bcf
PORTC,7
call
SECOND_1 ;1s
delay before start main program
call
SECOND_1
call
SECOND_1
movlw
d'240'
movwf
TimeOutCounter
movlw
d'3'
movwf
TimeOutCounter1
movlw
A'0'
movwf
A1
movwf
A2
movwf
A3
StartMain
call
DisSelect
call
visualdelay
WaitCMD
btfss
PORTC,3
goto
TEMP_CHECKx
btfss
PORTD,1
goto
HR_CHECKx
btfss
PORTD,0
goto
BP_CHECKx
goto
WaitCMD
;-----------------------------------------End
of Start--------------------------------------------
;-------------------------------------------MODE
1------------------------------------------------
TEMP_CHECKx
call
SEND_MODE1
call
DisMODE1
call
SECOND_1
call
SECOND_1
TEMP_CHECK
call
DisLCD
call
visualdelay
call
Delay_Tx
call
SEND_TEMP
call
SECOND_1
btfss
PORTC,3
goto
StartMain
btfss
PORTD,1
goto
StartMain
btfss
PORTD,0
goto
StartMain
goto
TEMP_CHECK
;----------------------------------------END
OF MAIN 1--------------------------------------------
;-------------------------------------------MODE
2------------------------------------------------
HR_CHECKx
call
SEND_MODE2
call
DisMODE3
call
SECOND_1
call
SECOND_1
HR_CHECK
call
clrdata
btfss
PORTA,2
goto
HR_CHECK
HR_CHECK2
btfsc
PORTA,2
goto
HR_CHECK2
ReadyCount
call
DECCount
call
DelayBPM
btfss
PORTA,2
goto
ReadyCount
call
DisBPM
call
visualdelay
btfss
PORTC,3
goto
StartMain
btfss
PORTD,1
goto
StartMain
btfss
PORTD,0
goto
StartMain
goto
HR_CHECK
clrdata
movlw
A'2'
movwf
A1
movlw
A'9'
movwf
A3
movwf
A2
return
;-----------------------------------------END
OF MAIN 2-------------------------------------------
;--------------------------------------------MODE
3------------------------------------------------
BP_CHECKx
call
SEND_MODE3
call
DisMODE2
call
SECOND_1
call
SECOND_1
BP_CHECK
call
DisLCD2
call
visualdelay
call
Delay_Tx
btfss
PORTC,3
goto
ONR
btfss
PORTD,1
call
OFFR
btfss
PORTD,0
goto
StartMain
goto
BP_CHECK
ONR
bsf
PORTD,2
call
Delay_Tx
call
Delay_Tx
call
DisLCD2
call
visualdelay
movf
ANALOGnonfract1,w
xorlw
A'3'
btfss
STATUS,Z
goto
ONR
call
SECOND_1
call
SECOND_1
call
SECOND_1
bcf
PORTD,2
LoopONR
call
tempconv2 ;
Convert Pressure
call
displaydata
bsf
PORTD,3
btfss
PORTA,2
goto
LoopONR
movf
ANALOGnonfract1,w
movwf
U1
movf
ANALOGnonfract0,w
movwf
U2
movf
ANALOGfract1,w
movwf
U3
call
DisLCD2A
call
visualdelay
call
SECOND_1
call
SECOND_1
LoopDIA
call
tempconv2 ;
Convert Pressure
call
displaydata
btfss
PORTA,2
goto LoopDIA
call
SECOND_1
LoopDIA1
call
tempconv2 ;
Convert Pressure
call
displaydata
btfss
PORTA,2
goto
LoopDIA1
call
SECOND_1
LoopDIA2
call
tempconv2 ;
Convert Pressure
call
displaydata
btfss
PORTA,2
goto
LoopDIA2
bcf
PORTD,3
movf
ANALOGnonfract1,w
movwf
D1
movf
ANALOGnonfract0,w
movwf
D2
movf
ANALOGfract1,w
movwf
D3
call
DisLCD2B
call
SECOND_1
call
SECOND_1
call
SECOND_1
WaitY
btfss
PORTC,3
goto
BP_CHECKx
btfss
PORTD,0
goto
StartMain
goto
WaitY
goto
ONR
OFFR
bcf
PORTD,2
call
SECOND_1
return
;-------------------------------------------------------------------------------------------------
ADDON
incf
A3,1
movf
A3,w
xorlw
A':'
btfss
STATUS,Z
return
movlw
A'0'
movwf
A3
ADDON1
incf
A2,1
movf
A2,w
xorlw
A':'
btfss
STATUS,Z
return
movlw
A'0'
movwf
A2
ADDON2
incf
A1,1
movf
A1,w
xorlw
A':'
btfss
STATUS,Z
return
movlw
A'9'
movwf
A1
movwf
A2
movwf
A3
return
DECCount
movf
A3,w
xorlw
A'0'
btfss
STATUS,Z
goto
Dec1
movf
A2,w
xorlw
A'0'
btfss
STATUS,Z
goto
Dec2
movf
A1,w
xorlw
A'0'
btfss
STATUS,Z
goto
Dec3
return
Dec1
decf
A3,1
return
Dec2
decf
A2,1
movlw
A'9'
movwf
A3
return
Dec3
decf
A1,1
movlw
A'9'
movwf
A2
movwf
A3
return
;-----------------------------------------END
OF MAIN 3-------------------------------------------
;------------------------------------------SEND
MODE----------------------------------------------
SEND_MODE1
movlw
A'X'
call
transmit
movlw
A','
call
transmit
movlw
A'1'
call
transmit
movlw
A','
call
transmit
return
SEND_MODE2
movlw
A'X'
call
transmit
movlw
A','
call
transmit
movlw
A'2'
call
transmit
movlw
A','
call
transmit
return
SEND_MODE3
movlw
A'X'
call
transmit
movlw
A','
call
transmit
movlw
A'3'
call
transmit
movlw
A','
call
transmit
return
SEND_TEMP
movlw
A'T'
call
transmit
movlw
A','
call
transmit
movf
ANALOGnonfract2,w
call
transmit
movf
ANALOGnonfract1,w
call
transmit
movf
ANALOGnonfract0,w
call
transmit
movlw
A'.'
call
transmit
movf
ANALOGfract1,w
call
transmit
movlw
A','
call
transmit
return
SEND_BPM
movlw
A'H'
call
transmit
movlw
A','
call
transmit
movf
A1,w
call
transmit
movf
A2,w
call
transmit
movf
A3,w
call
transmit
movlw
A','
call
transmit
return
SEND_BP
movlw
A'B'
call
transmit
movlw
A','
call
transmit
movf
U1,w
call
transmit
movf
U2,w
call
transmit
movf
U3,w
call
transmit
movlw
A','
call
transmit
movf
D1,w
call
transmit
movf
D2,w
call
transmit
movf
D3,w
call
transmit
movlw
A','
call
transmit
return
SEND_PRESS
movlw
A'P'
call
transmit
movlw
A','
call
transmit
movf
ANALOGnonfract1,w
call
transmit
movf
ANALOGnonfract0,w
call
transmit
movf
ANALOGfract1,w
call
transmit
movlw
A','
call
transmit
return
;----------------------------------------END
OF MAIN PROGRAM---------------------------------------
This
is just half of the program...Next week I will revel the programming lines from
A to Z... okay...make sure to follow up with my last post next week....Take
care peeps...... :)
That's
it for today. Have a great day :)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Quote of the day.....!
"Education is
the most powerful weapon which you can use to change the world"
Nelson Mandela
Nelson Mandela
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Regards,
Idriah
Safriza Bte Idris Chin