You are on page 1of 23

Design of CO Emission Monitoring System for Motorized Vehicle Based on ATMEGA8535 Microcontroller

Tika Iswara Engineering Physics Department, Faculty of Engineering, Gadjah Mada University, Yogyakarta - Indonesia http://tf.ugm.ac.id e-mail : akh_iswara@plasa.com

Abstract According to decision Minister of Environmental Affair number 141, 2003, since January 2005 every new motorized vehicle must obey to EURO 2 emission standart, while the old type of motorized vehicle have a chance to adapted until 2007. Carbonmonoxide is one of parameter which measured on EURO 2 emission standart. Until now, the quantity of emission monitoring instrument, especially for CO is limited, if compared with amount of motorized vehicle that operating on the road. A carbonmonoxide emission monitoring system had been made based on ATMEGA8535 microcontroller which had on chip 10-bit ADC. The system used an electrochemical sensor, TGS5042. Liquid Crystal Display M1632 and 5 colors LED used as output of the system. The system have measurement range 0 ppm until 1.000 ppm, accuracy + 20 % (0 ppm until 100 ppm), + 15 % (100 ppm until 500 ppm), resolution 1 ppm, respon time + 1 second and sensor have life time 7 years under natural residental condition such as 200C/40% RH. The system real time and portable operated, which can valued result of the measurement into 5 category, there are good (0 ppm until 50 ppm), bad (51 ppm until 200 ppm), indisposed (201 ppm until 400 ppm), very indisposed (401 ppm until 800 ppm) and dangerous (biger 801 ppm). Keywords : EURO 2 emission standart, motorized vehicle, ATMEGA8535 microcontroller, TGS5042, real time, portable, LCD M1632, LED.

1. INTRODUCTION The relation between environmental and engineering design is one aspect which influence human life. An instrument that created, some time not safety for environment or surrounding because this side effects such us CO, SO, HC and NOx. Today people have insteresting about healty and safety instrument. Its mean that all technology product must have concern about environment or people will leaving this product from market. Air quality is one factor that used for monitoring healthy of environment. The growth of fosil fuel today, had effects decreasing the air quality, because their gas emission such as carbonmonoxice, hydrocarbon, sulfur dioksida and nitrogen dioksida. Its toxic gas and will attack the human live. Carbonmonoxide can kill people, in some ppm amount and periode. Indonesia Minister of Environmental had the regulation about gas emission from motorized vehicle. This regulation said that since January 2005 every new motorized vehicle must obey to EURO 2 emission standart, while the old type of motorized vehicle have a chance to machine adapted until 2007. Carbonmonoxide is one of parameter which

measured on EURO 2 emission standart. Until now, the quantity of emission monitoring instrument, especially for CO is limited, if compared with number of motorized vehicle that operating on the road. 1.1 Problem Definition Design of CO emission monitoring system for motorized vehicle based on ATMEGA85835 microcontroller. This system portable and real time. 1.2 Purpose of Research This research to get a portable CO monitoring system based on AVR microcontroller ATMEGA8535, displayed by a modul LCD M1632 and LED indicator. The system will used for measure carbonmonoxide concentration from 0 ppm until 1.000 ppm. 2. CARBONMONOXIDE Carbon and oxygen will create carbonmonoxide when unperfect chemical reaction occurred in machine. Based on research in America 60,6 % CO emission from motorized vehicle, 16,8 % CO from industry, 5,6 % CO from power plant and 3,5 % from waste (City of Fort Collins home page/air quality/carbon-monoxide.php). This modestly chemical reaction occurred in motorized vehicle combustion. Fuel + O2 CO + H2O CO + 1/2O2 CO2 Carbonmonoxide is a toxic gas, because the stronger reaction with haemoglobin than oksigen reaction with haemoglobin. If occured reaction with haemoglobin in blood of human, oksigen cant spread in blood because carbosihaemoglobin more stable than oksihaemoglobin. The decrease of oksigen in blood make human died. This is the complete reaction. CO(g) + Hb(l) HbCO(l) O2(g) + Hb(l) HbO2(l) 3. ATMEGA8535 MICROCONTROLLER ATmega835 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing instructions in a single clock cycle, the ATmega8535 achieves throughputs approaching 1 MIPS per MHZ allowing the system designer to optimize power consumption versus processing speed. This microcontroller created by ATMEL inc. The ATmega8535 feature consist of 32 x 8 General Purpose Working Registers, up to 16 MIPS throughput at 16 MHZ, 130 Powerful Instruction, 8K bytes of In-System SelfProgrammable Flash, Endurance : 10,000 Write/Erase Cycles, 512 Bytes EEPROM with Endurance : 100,000 Write/Erase Cycles, 8-channel 10-bit ADC, Programmable Serial USART, 512 Bytes Internal SRAM, etc.

Figure 1. ATmega8535 Microcontroller

4. ANALOG TO DIGITAL CONVERTER (ADC) The ATmega8535 features a 10-bit successive approximation ADC. The ADC is connected to an 8-channel Analog Multiplexer which allow eight single-ended voltage inputs constructed from the pins of Port A. The single-ended voltage inputs refer to 0 V (GND). The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held is held at a constant level during conversion. The ADC has a separate analog supply voltage pin, AVCC. AVCC must not differ more than + 0.3V from Vcc. Internal reference voltages of nominally 2.56V or AVCC are provided On-chip. The voltage reference may be externally decoupled at the AREF pin by a capacitor for better noise performance The ADC converts an analog input voltage to a 10-bit digital value through successive approximation. The minimum value represents GND and the maximum value represents the voltage on the AREF pin minus 1 LSB. The ADC is enabled by setting the ADC Enable bit, ADEN in ADCSRA. Voltage reference and input channel selections will not go into effect until ADEN is set. The ADC does not consume power when ADEN is cleared, so it is recommended to switch off the ADC before entering power saving modes After the conversion is complete (ADIF is high), the conversion result can be found in the ADC Result Registers (ADCL,ADCH). For single ended conversion, the result is

Vinx1023 Vref Where Vin is the voltage on the selected input pin and Vref the selected voltage reference. When an ADC conversion is complete, the result is found in these two register, ADCH and ADCL. There result is presented in twos complement form, left and right adjusted. When bit ADLAR is cleared, the result is right adjusted. When ADLAR is cleared, the result is right adjusted and other.
ADC =

Bit 15 Bit 14 ADC7 ADC6 Bit 7 Bit 6 Bit 15 ADC9 ADC1 Bit 7 Bit 14 ADC8 ADC0 Bit 6

The Right Adjusted Result Bit 13 Bit 12 Bit 11 Bit 10 ADC5 ADC4 ADC3 ADC2 Bit 5 Bit 4 Bit 3 Bit 2 The Left Adjusted Result Bit 13 Bit 12 Bit 11 Bit 10 ADC7 ADC6 ADC5 ADC4 Bit 5 Bit 4 Bit 3 Bit 2

Bit 9 ADC9 ADC1 Bit 1 Bit 9 ADC3 Bit 1

Bit 8 ADC8 ADC0 Bit 0 Bit 8 ADC2 Bit 0

5. LIQUID CRYSTAL DISPLAY M1632 represent the Module LCD with the configuraton 16 column, 2 line with each character is formed by 8 line pixel and 5 column pixel ( last 1 line pixel is cursor). This LCD is controlled by microcontroller HD44780 produced by Hitachi. HD44780 represent the microcontroller designed special to control the LCD and have the ability arrange the process scanning at screen. LCD is formed by 16 COM and 40 SEG so that microcontroller accessing this module LCD not need again arrange the process scanning at LCD screen.

Figure 2. LCD M1632 LCD M1632 if will be used to connect with a microcontroller, pursuant to its data length have the two technique interface, that is interface of 4 bit and interface of 8 bit. The technique interface of 8 bit, means that data writed or read by microcontroller to or from M1632 conducted in once process the. Data of equal to 8 bit writed or read by microcontroller accompaniedly by clock signal in pin E conection.

6. RESEARCH EXECUTION The substance used in research is 1. Microcontroller AVR ATMEGA8535 ATMEL 2. LCD M1632, LED 3. Sensor of CO TGS5042, IC Op-Amp OP-07 4. Oscillator Crystal 12 MHZ, Voltage Regulator 7805 5. Resistor, capacitor, diode 6. Acrylic 1,5 mm, 3mm, PCB 7. Rainbow Cable 10 band, cable socket, socket 10 pin 8. Motor DC 9 V, nut, saklar 9. Battery 9 V, 12 V pile alkaline Appliance used by 1. Digital multimeter 2. Mechanic Equipments ( drill the, saw, tight-fisted, screwdriver) 3. Solder and ekstractor, motorbike 4. Power Supply 5V, 9V 5. Personal Computer, dongle, software of AVR Studio 4, Ponyprog2000, OrCAD 9.2 Research managery cover the phase 1. Literature study concerning measurement instrument of CO 2. Ready of appliance and substance 3. Software design use the AVR Studio 4 4. Scheme of PCB microcontroller and system sensor used Orcad 9.2 5. Examination the sensor ouput through circuit of sensor substitution 6. Examination the amplifier circuit for sensor TGS5042 7. Comparing data of ADC reference and result of circuit examination sensor to determine amount of gain factor 8. Examination ADC of microcontroller ATMEGA8535 9. Determination voltage input of ADC showing conversion value which equal to 1.000. 10. System examination with the input in the form of electrics current variation yielding output in the form of conversion value of ADC displayed on LCD M1632 11. Determination rectify result of measurement. 12. Making of appliance tidiness. 13. Field examination. 14. Analysis the result and making of research report

7. ENGINEERING DESIGN

Figure 3. Engineering Design

Figure 4. Schematic of CO Monitoring System 8. ANALYSE RESULT Intake of examination data conducted to use the measuring instrument which have been ascertained good in a condition. Though the measuring instrument own the mistake value, measurement mistake coming from measuring instrument disregarded in analysis result. Data of the result of examination then processed by software of MATLAB 6.. Equation in the following is utilized to obtain the value of measurement deviation.

Deviation =

TR x100% R

in this case, T : Result of Measurement R : Assess The Component Reference Method of calibrate usually done by comparing new instrument with standart measuring instrument. Method utilized for the gauging of appliance made by comparing the data result of system examination with the data of component reference weared, that is sensor TGS5042. This is simple means that compare electric current of TGS5042 with ADC result of ATmega8535 microcontroller. The result of deviation system which have been made smaller than deviation of sensor TGS5042 reference, big hence deviation coming from reference data utilized by as deviation determination of entire all system, conversely; because in fact assess the deviation of larger ones represent the smaller deviation contribution. So that assess the larger ones deviation, more dominant give the measurement mistake. As according to used sensor type, measurement parameter determined from examination result, that is accuration, resolution, and time respon. The parameter represent the value which is ever determined at measuring instrument being based on electrochemical sensor.

9. RESULT AND SOLUTION 9.1 Examination of Current to Voltage Circuit The circuit of current to voltage convertion have function to obtain voltage characteristic from input which is in the form of electrics current. Span the voltage yielded by sensor, when there are CO in the range 0 ppm till 1.000 ppm important to know, because microcontroller will use the change of voltage gyration to be translated into binary logic. Figure 5 representing circuit of examination of current to voltage convertion.

Figure 5. Circuit of Current to Voltage Convertion Sensor of TGS5042 which used own function as source of electrics current. As according to reference data, sensor will awaken the electrics current in the range 0 A till 2,4 A. Battery 1,5 V and resistor 2 M have function to replace the sensor function. Electrics current of equal to 0 A till 2,4 A obtained from battery 1,5 V stringed up break evenly by resistor variable 2 M.

Figure 6. The Result of Current to Voltage Circuit Data intake of result of examination done by using 2 digital multimeter. The circuit input in the form of electrics current of equal to 0 A till 2,4 A yield to span the output voltage of equal to 0 V till 0,24 V of]according to Figure 5. From result analyse the data obtained by a measurement mistake of equal to 0 %. This matter indicate that the circuit of current to voltage converter work better. Measurement mistake of equal to 0 % also indicate that the battery circuit 1,5 V stringed up break evenly by variable resistir 2 M can function better as source of electrics current. Assess the mistake 0 % very influenced by type of IC Op-Amp. The type Op-Amp which used in the circuit has characteristic of ultra low of offset of voltage of amplifier or lasing type with the very small offset mistake. 9.2 Examination of Amplifier Circuit. The examination done by giving variation of input voltage equal to 0 V till 0,24 V with the increase of equal to 0,01 V. The variation of input voltage come from battery 9 V compiled parallel by variable resistor 20 k . Data intake measure by using 2 digital multimeter in Figure 7.

Figure 7. Circuit of Operational Amplifier Examination

Figure 8. The Result of Amplifier Characteristic From result analyse the data, obtained a deviation mean of equal to 1,52 % or + 0,0152 volt. Assess this deviation within measure tolerance, because measurement of output voltage of amplifier circuit have the correctness 1 number rear comma.

10

9.3 Examination of ADC ATMEGA8535 Examination ADC conducted with giving input in the form of voltage variation of 0 V till 5 V with the increase equal to 0,1 V. Pin A0 at port A function as analogous voltage input. The result of conversion in the form of binary value 0000000000 till 1111111111. The binary value then processed and converted by microcontroller become the value equal to 0 till 1023, then displayed at LCD. Graph the result of examination ADC like at Figure 9.

Figure 9. The Result of ADC Examination From the result analyse the data, a deviation mean of equal to 3,04 % or + 0,0304 volt. 9.4 System Examination Examination to system or engineering design which have been designed to be conducted without entangling sensor TGS5042. System examination [done/conducted] [blike Picture 5.7 with giving input in the form of variation [of] of electrics current [of] equal to 0 A till 2,4 A. System output in the form of conversion value of ADC presented at LCD ( showing rate of gas CO in set of ppm), assessment of quality of gas CO, and blaze the lamp LED 5 colour. The result of system examination presented by graph at Figure 10.

11

Figure 10. Result of Monitoring System Examination Assessment the examination result of CO become 5 category of pursuant to data at Table 1. While determination of colour of LED adapted by condition of assessment of CO concentration. The system which have been made show 5 category, there are green colour is good condition indication, yellow mean bad, pink mean indisposed, red mean very indisposed, and blue mean dangerous. Table 1. The Category of CO Concentration Effect for Human Body Second Row of ADC Register First Row of Color of LED ADCH/ADCL LCD Screen LCD Screen 0 50 $0000 - $0032 good Green 51 200 $0033 - $00C8 bad Yellow 201 400 $00C9 - $0190 indisposed Pink 401 800 $0191 - $0320 very indisposed Red Biger of 801 $0321 - $03FF dangerous Blue

From result analyse the data, obtained by deviation average value equal to 2,87 %. The deviation average of equal to 2,87 % will be used to determine the system accuration which have been designed.

12

10. CONCLUSION 1. Monitoring system of CO can work by portable and real time, capable to be operated to measure the rate of CO motorized vehicle. 2. Monitoring system have measurement span 0 ppm till 1.000 ppm, accuration + 20 % ( 0 ppm till 100 ppm), + 15 % ( 100 ppm till 500 ppm) and 1 ppm resolution. 3. System which have been made able to give the assessment of CO quality pursuant into 5 category, that is goodness ( 0 ppm till 50 ppm of CO), bad ( 51 ppm till 200 ppm of CO), indisposed ( 201 ppm till 400 ppm of CO), very indisposed ( 401 ppm till 800 ppm of CO) and dangerous ( above 801 ppm of CO).

13

ENCLOSURE [ Top Side ]

ATmega8535 microcontroller

LCD M1632

LED indicator

14

;*********************************************************************** ; Title : Sistem Monitoring Gas CO Kendaraan Bermotor ; Target : ATmega8535 ; Hari/Tanggal : Jum'at/21 Januari 2006 ; Engineer : Iswara ;*********************************************************************** ; Bismillaahirrahmaanirraahiim .include "m8535def.inc" .def tmp =r16 .def tmpa =r17 .def tout =r18 .def tmpT1 =r19 .def tmpLCD =r20 .def tmpLed =r23 .def plus =r24 .def plus1 =r25 ;LCD .equ .equ .equ RS RW E =0 =1 =2 ;kaki pin 0 pada portd ;kaki pin 1 pada portd ;kaki pin 2 pada portd ;alamat tBCD0 ;alamat tBCD1 =r13 ;nilai digit BCD 1 dan 0 =r14 ;nilai digit BCD 3 dan 2 =r15 ;nilai digit BCD 4 =r16 ;nilai biner dari bit rendah =r17 ;nilai biner dari bit tinggi ;kalang pencacah ;nilai register sementara

;Bin2BCD16 .equ AtBCD0 =13 .equ AtBCD2 =15 .def .def .def .def .def .def .def tBCD0 tBCD1 tBCD2 fbinL fbinH cnt16a =r18 tmp16a =r19

;****************************** ; Interupsi ;****************************** .cseg .org 0000 rjmp Mulai ;menuju preparasi .org $00E rjmp ;vektor interupsi ADC St_con ;loncatan agar terjadi interupsi

;******************************************* ; Prosedur-prosedur ;******************************************* ;****************************** ; Prosedur interupsi ADC ;****************************** St_con: in in ldi out sei reti ;***************************** ; Prosedur tampilan LCD awal ;***************************** Tampil: lpm tst r0 breq PL r21,ADCL r22,ADCH tmp,0b11101111 ADCSRA,tmp

15

PL: AWAL:

mov rcall adiw rjmp ret rcall ldi ldi rcall rcall ldi ldi rcall ret

tmpa,r0 lcdput ZL,1 Tampil

baris1 ZH,HIGH(2*StAWAL1) ZL,LOW(2*StAWAL1) tampil baris2 ZH,HIGH(2*StAWAL2) ZL,LOW(2*StAWAL2) tampil

;============================================================ PENYUSUNAN: rcall baris1 ldi ZH,HIGH(2*StNama) ldi ZL,LOW(2*StNama) rcall tampil rcall ldi ldi rcall ret baris2 ZH,HIGH(2*StNIM) ZL,LOW(2*StNIM) tampil

;============================================================ kampus: rcall baris1 ldi ZH,HIGH(2*StKampus) ldi ZL,LOW(2*StKampus) rcall tampil rcall ldi ldi rcall ret Judul: baris2 ZH,HIGH(2*StKota) ZL,LOW(2*StKota) tampil

rcall ldi ldi rcall

baris1 Zh,high(2*StAwal1) Zl,low(2*StAwal1) tampil

rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ret baris1:

ldi rcall ret

tmpa,0b00000010 lcdcmd

baris2:

ldi tmpa,0b11000000 rcall lcdcmd ret ;**************************** ; Prosedur BCD ;**************************** ;bin2BCD16=Konversi biner 16 bit ke BCD bin2BCD16: ldi clr cnt16a,16 tBCD2 ;inisialisasi kalang pencacah ;memberi logika "0" (3 bytes)

16

clr clr clr bBCDx_1: lsl rol rol rol rol dec brne ret bBCDx_2:ldi bBCDx_3: ld subi sbrc st ld subi sbrc st cpi brne rjmp

tBCD1 tBCD0 ZH

;memberi logika "0" pada ZH

fbinL ;pergeseran nilai masukan fbinH ;through all bytes tBCD0 tBCD1 tBCD2 cnt16a ;pengurangan kalang pencacah bBCDx_2 ;if counter not zero ;return r30,AtBCD2+1 tmp16a,-Z tmp16a,-$03 tmp16a,3 Z,tmp16a tmp16a,Z tmp16a,-$30 tmp16a,7 Z,tmp16a ZL,AtBCD0 bBCDx_3 bBCDx_1 ;Z points to result MSB+1 ;get (Z) with pre-decrement ;tambahkan dengan nilai 0x03 ;if bit 3 not clear ;store back ;get(Z) ;add 0x30 ;if bit 7 not clear ;store back ;done all three? ;loop again if not

;**************************************** ; Prosedur tunda ;**************************************** tunda: ldi tmpT1,250 lagi: dec tmpT1 brne lagi dec brne ret tout tunda

;************************ ; Prosedur LCD ;************************************************* ; Prosedur tunggu LCD ;************************************************* TungguLCD: ldi out sbi cbi looptg: sbi cbi in sbi cbi sbrc rjmp ser out ret tmpLCD,$07 ddrd,tmpLCD portd,RW portd,RS portd,E portd,E tmpLCD,pind portd,E portd,E tmpLCD,6 looptg tmpLCD ddrd,tmpLCD

;************************************************** ; Prosedur kirim perintah ke LCD ;************************************************* LCDCMD: rcall tungguLCD mov tmpLCD,tmpa ror tmplcd

17

andi out sbi cbi mov swap ror andi out sbi cbi sbi sbi ret

tmpLCD,$f8 portd,tmpLCD portd,E portd,E tmpLCD,tmpa tmpLCD tmplcd tmpLCD,$f8 portd,tmpLCD portd,E portd,E portd,RW portd,RS

;************************************************** ; Prosedur kirim karakter ;************************************************** LCDPUT: rcall tungguLCD cbi portd,RW sbi portd,RS in tmp,portd mov ror andi out sbi sbi cbi mov swap ror andi out sbi sbi cbi sbi ret tmpLCD,tmpa tmplcd tmpLCD,$f8 portd,tmpLCD portd,RS portd,E portd,E tmpLCD,tmpa tmpLCD tmplcd tmpLCD,$f8 portd,tmpLCD portd,RS portd,E portd,E portd,RW

;*************************************** ; Preparasi ;*************************************** Mulai: ldi r16,High(RAMEND) out SPH,r16 ldi out ser out out ser out out clr out r16,low(RAMEND) SPL,r16 tmp ddrd,tmp portd,tmp tmp ddrb,tmp portb,tmp tmp ddra,tmp

ldi tmp,$40 out ADMUX,tmp sei ;****************************************** InitLCD: cbi portd,RW cbi portd,RS

18

ldi rcall ldi out sbi cbi ldi rcall ldi out sbi cbi ldi rcall ldi out sbi cbi ldi out sbi cbi ldi rcall ldi rcall ldi rcall ldi rcall ldi rcall rcall ldi ldi wAwal: rcall dec brne rcall ldi rcall ldi

tout,250 tunda tmp,$30 portd,tmp portd,E portd,E tout,80 tunda tmp,$30 portd,tmp portd,E portd,E tout,2 tunda tmp,$30 portd,tmp portd,E portd,E tmp,$20 portd,tmp portd,E portd,E tmpa,0b00101000 LCDCMD tmpa,0b00001000 LCDCMD tmpa,0b00001100 LCDCMD tmpa,0b00000010 LCDCMD tmpa,0b00000110 LCDCMD Awal tmp,$3F tmpa,$2F Tunda tmp wAwal Penyusunan tout,250 Tunda tmpa,$2F tunda tmpa akampus kampus tout,250 tmpa,$2F tunda tmpa tunggu1 judul tmp,0b10101111 ADCSRA,tmp ADCSRA,ADSC

;tunggu sdktnya 15 ms stlh power up

akampus: rcall dec brne rcall ldi ldi tunggu1: rcall dec brne rcall ldi out sei sbi

;tunggu sdktnya 15 ms stlh power up

;*************************************** ; Program Utama ;*************************************** main: mov fbinL,r21

19

mov rcall

fbinH,r22 bin2BCD16

;konversi biner ke BCD ;loncat ke penilaian kualitas udara

rcall nilai_gas ldi rcall mov andi ldi add rcall ldi rcall mov andi swap ldi add rcall ldi rcall mov andi ldi add rcall

tmpa,$cb lcdcmd tmpa,tbcd0 tmpa,$0f tmp,$30 tmpa,tmp lcdput tmpa,$ca lcdcmd tmpa,tbcd0 tmpa,$f0 tmpa tmp,$30 tmpa,tmp lcdput tmpa,$c9 lcdcmd tmpa,tbcd1 tmpa,$0f tmp,$30 tmpa,tmp lcdput

ldi tmpa,$c8 rcall lcdcmd mov tmpa,tbcd1 andi tmpa,$f0 swap tmpa ldi tmp,$30 add tmpa,tmp rcall lcdput rjmp main ;**********penyalaan LED & tampilan baris pertama LCD**************** nyala1: ;*** menampilkan tulisan 'B A I K' *** rcall baris1 ldi Zh,high(2*StNilai1) ldi Zl,low(2*StNilai1) rcall tampil rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ldi tmpLed,0b01111111 ;led hijau menyala out portb,tmpLed ret nyala2: ;*** menampilkan tulisan 'TIDAK BAIK' *** rcall baris1 ldi Zh,high(2*StNilai2) ldi Zl,low(2*StNilai2) rcall tampil rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ldi tmpLed,0b10111111 ; led kuning menyala out portb,tmpLed ret nyala3: ;*** menampilkan tulisan 'TIDAK SEHAT' *** rcall baris1 ldi Zh,high(2*StNilai3) ldi Zl,low(2*StNilai3)

20

rcall

tampil

rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ldi tmpLed,0b11011111 ;led merah muda menyala out portb,tmpLed ret nyala4: ;*** menampilkan tulisan 'SANGAT TDK SEHAT' *** rcall baris1 ldi Zh,high(2*StNilai4) ldi Zl,low(2*StNilai4) rcall tampil rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ldi tmpLed,0b11101111 ;led merah menyala out portb,tmpLed ret nyala5: ;*** menampilkan tulisan 'BERBAHAYA !' *** rcall baris1 ldi Zh,high(2*StNilai5) ldi Zl,low(2*StNilai5) rcall tampil rcall baris2 ldi Zh,high(2*StJudul2) ldi Zl,low(2*StJudul2) rcall tampil ldi tmpLed,0b11110111 ;led biru menyala out portb,tmpLed ret ;*****penilaian hasil pengukuran***** nilai_gas : cpi r22,3 ;nilai register ADC=0b11xxxxxxxx breq loncat2 cpi r22,2 ; bandingkan nilai r22 dengan 2 breq nyala4 cpi r22,1 breq loncat1 cpi r21,51 ;bandingkan hasil konversi dengan 51 ppm brlo nyala1 ; jika lebih kecil dari 51 ppm meloncat ke:nyala1 cpi r22,0 brne loncat1 cpi r21,201; bandingkan hasil konversi dengan 201 ppm brlo nyala2 ; jika lebih kecil dari 201 ppm meloncat ke:nyala2 loncat1: cpi r22,0 breq nyala3 mov plus,r21 ; copy nilai r21 ke register plus(r24) mov plus1,r22 ; copy nilai r22 ke register plus1(r25) add plus,plus1 ;menjumlah nilai r21(ADCL) dan r22(ADCH) cpi plus,$92 ;$92=hasil penjumlahan r21(ADCL) dan r22(ADCH) pada ; nilai 401 ppm brlo nyala3 cpi r21,$91 brge nyala4 cpi r22,2 breq nyala4 ret loncat2: cpi r21,$21 ;bandingkan dengan 801 ppm brlo nyala4 rcall nyala5 ;loncat ke prosedur nyala5 ret

21

;**************************** StAwal1: .db " [ CO meter ] ",0 StAwal2: .db " [ DIGITAL ] ",0 StNama: .db " TIKA ISWARA ",0 StNIM: .db " NIM:25535 ",0 StKampus: .db " TEKNIK FISIKA ",0 Stkota: .db " FT UGM JOGJA ",0 StNilai1: .db " B A I K ",0 StNilai2: .db " TIDAK BAIK ",0 StNilai3: .db " TIDAK SEHAT ",0 StNilai4: .db "SANGAT TDK SEHAT",0 StNilai5: .db " BERBAHAYA ! ",0 stJudul2: .db "Gas CO: ppm",0 ; Alhamdulillaahirrabbilalamiin ;********************************************************* ; Program ini telah berjalan dengan baik, tanpa error ; jika ada masalah tentang kode program ini silakan ; hubungi penulis ke : 0815 780 77882 atau ; kirim e-mail ke : akh_iswara@plasa.com ; Jazakumullah khairan katsiira ;*********************************************************

22

23

You might also like