{"id":815,"date":"2010-11-09T11:53:24","date_gmt":"2010-11-09T16:53:24","guid":{"rendered":"http:\/\/embedded-lab.com\/blog\/?p=815"},"modified":"2012-07-30T09:29:31","modified_gmt":"2012-07-30T13:29:31","slug":"microcontroller-based-diode-and-bipolar-junction-transistor-bjt-tester","status":"publish","type":"post","link":"https:\/\/embedded-lab.com\/blog\/microcontroller-based-diode-and-bipolar-junction-transistor-bjt-tester\/","title":{"rendered":"Microcontroller based Diode and Bipolar Junction Transistor (BJT) tester"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>Most of the digital multimeters these days have built-in features for testing diodes and sometimes transistors. The purpose of this project is to demonstrate a simple way to construct a testing device for diodes and bipolar junction transitors (BJTs) using a microcontroller. The testing algorithm is based on a simple fact that a working<span id=\"lw_1289570704_4\" class=\"yshortcuts\" style=\"border-bottom: 2px dotted #366388; background: transparent none repeat scroll 0% 0%; cursor: pointer;\"> <\/span> PN junction conducts current  in only one direction. A PIC16F688 microcontroller is used in this project that switches the bias voltage across the PN junctions of diode and transistors, and determines if a particular junction is normal, open or short.<\/p>\n<p><strong>Theory<\/strong><\/p>\n<p>The logic behind testing a diode is straightforward. A diode is a PN junction that allows the conduction of current only in one direction. Therefore, a good diode will conduct current in only one direction. If it does in both the directions, it means the diode is short, and if it does in neither direction, it is open. The circuit implementation of this logic is shown below.<\/p>\n<p style=\"text-align: left;\"><a rel=\"attachment wp-att-838\" href=\"http:\/\/embedded-lab.com\/blog\/?attachment_id=838\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-838 aligncenter\" title=\"Circuit_DiodeTesterLogic\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTesterLogic.png\" alt=\"\" width=\"578\" height=\"219\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTesterLogic.png 578w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTesterLogic-550x208.png 550w\" sizes=\"auto, (max-width: 578px) 100vw, 578px\" \/><\/a><!--more--><\/p>\n<p>This concept can be easily extended to test a transistor by realizing that a transistor consists of two PN junctions: one betwen the base and the emitter (BE junction), and the another between the base and the collector (BC junction). If both the junctions conduct in only one direction, the transistor is normal, otherwise it is faulty. We can also identify the type (PNP or NPN) of the transistor by considering the direction of the current conduction. Three I\/O pins of a microcontroller are required to implement the testing algorithm for a transistor.<\/p>\n<p style=\"text-align: center;\"><a rel=\"attachment wp-att-844\" href=\"http:\/\/embedded-lab.com\/blog\/?attachment_id=844\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-844 aligncenter\" title=\"Circuit_BJTTesterLogic\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_BJTTesterLogic.png\" alt=\"\" width=\"576\" height=\"305\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_BJTTesterLogic.png 576w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_BJTTesterLogic-550x291.png 550w\" sizes=\"auto, (max-width: 576px) 100vw, 576px\" \/><\/a><\/p>\n<p>The test sequence for a transistor would go like this.<\/p>\n<ol>\n<li>Set D2 High and read D1 and D3. If D1 is High, BE junction conducts, otherwise not. If D3 is High, BC junction conducts, otherwise not.<\/li>\n<li>Set D1 High and read D2. If D2 is High, EB junction conducts, otherwise not.<\/li>\n<li>Set D3 High and read D2. If D2 is High, CB junction conducts, otherwise not.<\/li>\n<\/ol>\n<p>Now, if only the BE and BC junctions conduct, the transistor is of NPN type and is working fine. And, if only the EB and CB junctions conduct, the transistor is still normal but the transistor type is PNP. All other cases (like EB and BE both conduct, or BC and CB both not conducting, etc.) indicate the transistor is not good.<\/p>\n<p><strong>Circuit Diagram and Description<\/strong><\/p>\n<p>The circuit diagram for this project is pretty simple. It has two push button switches for inputs, named <strong>Select<\/strong> and <strong>Detail<\/strong>. Pressing the Select button allows to choose between the diode and transistor testings, and the Detail button is active only in case of transistor testing and displays the details of the test results like the transistor type and both the junction status. The three legs of a test transistor (E, B, and C) are grounded through 1 K resistors, and the two PN junctions will be tested through RA0, RA1, and RA2 port pins of a PIC16F688 microcontroller. The testing of a diode requires only two pins, and will use the E and C pins. That&#8217;s why they have alternate labels, D1 and D2, in the circuit diagram.<\/p>\n<p style=\"text-align: center;\"><a rel=\"attachment wp-att-847\" href=\"http:\/\/embedded-lab.com\/blog\/?attachment_id=847\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-847 aligncenter\" title=\"Circuit_DiodeTester_PIC16F688\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTester_PIC16F688-550x387.jpg\" alt=\"\" width=\"550\" height=\"387\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTester_PIC16F688-550x387.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTester_PIC16F688.jpg 847w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-821\" title=\"Img_PIC16F688_DiodeTester\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester-550x348.jpg\" alt=\"\" width=\"550\" height=\"348\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester-550x348.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester.jpg 858w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p style=\"text-align: center;\">Circuit setup on the breadboard<\/p>\n<p><strong>Software<\/strong><\/p>\n<p>The firmware for this project is developed with MikroC compiler. While programming, you must be very careful about the direction settings of the three test pins (RA0, RA1, and RA2) because they change frequently while running the testing algorithm. Before setting any test pin to High, you must make sure that the other two pins are defined as input pins so that there won&#8217;t be any voltage conflict or short circuit between the port pins.<\/p>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">\/*<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">Project: Diode and Transistor Tester<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">Internal Oscillator @ 4MHz, MCLR Enabled, PWRT Enabled, WDT OFF<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">Copyright @ Rajendra Bhatt<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">November 9, 2010<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">*\/<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">\/\/ LCD module connections<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_RS at RC4_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_EN at RC5_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D4 at RC0_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D5 at RC1_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D6 at RC2_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D7 at RC3_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_RS_Direction at TRISC4_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_EN_Direction at TRISC5_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D4_Direction at TRISC0_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D5_Direction at TRISC1_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D6_Direction at TRISC2_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit LCD_D7_Direction at TRISC3_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">\/\/ End LCD module connections<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit TestPin1 at RA0_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit TestPin2 at RA1_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit TestPin3 at RA2_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit Detail at RA4_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">sbit SelectButton at RA5_bit;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">\/\/ Define Messages<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message1[] = &#8220;Diode Tester&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message2[] = &#8220;BJT Tester&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message3[] = &#8220;Result:&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message4[] = &#8220;Short&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message5[] = &#8220;Open &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message6[] = &#8220;Good &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char message7[] = &#8220;BJT is&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char *type = &#8220;xxx&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char *BE_Info = &#8220;xxxxx&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">char *BC_Info = &#8220;xxxxx&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">unsigned int select, test1, test2, update_select, detail_select;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">unsigned int BE_Junc, BC_Junc, EB_Junc, CB_Junc;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">void debounce_delay(void){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Delay_ms(200);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">}<\/span><\/div>\n<div id=\"_mcePaste\">\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">void main() {<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> ANSEL = 0b00000000; \/\/All I\/O pins are configured as digital<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> CMCON0 = 0x07 ; \/\/ Disbale comparators<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> PORTC = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> PORTA = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISC = 0b00000000; \/\/ PORTC All Outputs<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00111000; \/\/ PORTA All Outputs, Except RA3 (I\/P only)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Init(); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ Initialize LCD<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Cmd(_LCD_CLEAR); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ CLEAR display<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Cmd(_LCD_CURSOR_OFF); \u00a0 \u00a0 \u00a0 \u00a0\/\/ Cursor off<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(1,2,message1); \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Write message1 in 1st row<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> select = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> test1 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> test2 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> detail_select = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> do {<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(!SelectButton){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> debounce_delay();<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> switch (select) {<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> case 0 : select=1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> break;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> case 1 : select=0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> break;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> } \/\/case end<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(select == 0){ \u00a0 \/\/ Diode Tester<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(update_select){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Cmd(_LCD_CLEAR);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(1,2,message1);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,2,message3);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select=0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00110100; \/\/ RA0 O\/P, RA2 I\/P<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin1 = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> test1 = TestPin3 ; \/\/ Read I\/P at RA2<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin1 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00110001; \/\/ RA0 I\/P, RA2 O\/P<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin3 = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> test2 = TestPin1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin3 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if((test1==1) &amp;&amp; (test2 ==1)){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message4);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if((test1==1) &amp;&amp; (test2 ==0)){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message6);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if((test1==0) &amp;&amp; (test2 ==1)){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message6);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if((test1==0) &amp;&amp; (test2 ==0)){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message5);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> } \u00a0\/\/ End if(select == 0)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(select &amp;&amp; !detail_select){ \u00a0 \u00a0 \/\/ Transistor Tester<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(update_select){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Cmd(_LCD_CLEAR);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(1,2,message2);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for BE and BC Junctions of NPN<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00110101; \/\/ RA0, RA2 I\/P, RA1 O\/P<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin2 = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BE_Junc = TestPin1 ; \/\/ Read I\/P at RA0<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BC_Junc = TestPin3; \u00a0 \/\/ Read I\/P at RA2<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin2 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for EB and CB Junctions of PNP<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00110110; \/\/ RA0 O\/P, RA1\/RA2 I\/P<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin1 = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> EB_Junc = TestPin2;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin1 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TRISA = 0b00110011; \/\/ RA0 O\/P, RA1\/RA2 I\/P<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin3 = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> CB_Junc = TestPin2;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> TestPin3 = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(BE_Junc &amp;&amp; BC_Junc &amp;&amp; !EB_Junc &amp;&amp; !CB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,2,message3);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message6);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> type = &#8220;NPN&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BE_info = &#8220;Good &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BC_info = &#8220;Good &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> else<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(!BE_Junc &amp;&amp; !BC_Junc &amp;&amp; EB_Junc &amp;&amp; CB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,2,message3);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,message6);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> type = &#8220;PNP&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BE_info = &#8220;Good &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BC_info = &#8220;Good &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> else {<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,2,message3);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,10,&#8221;Bad &#8220;);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> type = &#8220;Bad&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(select &amp;&amp; !Detail){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> debounce_delay();<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> switch (detail_select) {<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> case 0 : detail_select=1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> break;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> case 1 : detail_select=0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> break;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> } \/\/case end<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select = 1;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(detail_select &amp;&amp; update_select){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for BE Junction open<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(!BE_Junc &amp;&amp; !EB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BE_info = &#8220;Open &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> <\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for BC Junction open<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(!BC_Junc &amp;&amp; !CB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BC_info = &#8220;Open &#8220;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> <\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for BE Junction short<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(BE_Junc &amp;&amp; EB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BE_info = &#8220;Short&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> \/\/ Test for BC Junction short<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> if(BC_Junc &amp;&amp; CB_Junc){<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> BC_info = &#8220;Short&#8221;;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> }<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Cmd(_LCD_CLEAR);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(1,1,&#8221;Type:&#8221;);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(1,7,type);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,1,&#8221;BE:&#8221;);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,4,BE_info);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,9,&#8221;BC:&#8221;);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> Lcd_Out(2,12,BC_info);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> update_select = 0;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> } \u00a0 \u00a0 \u00a0 \/\/ End if (detail_select)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"><br \/>\n<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\"> } while(1);<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #003366;\">}<\/span><\/div>\n<\/div>\n<p style=\"text-align: right;\"><a href=\"http:\/\/embedded-lab.com\/uploads\/HexFiles\/PIC16F688\/DiodeTester.zip\" target=\"_blank\">Download Source Code and HEX file<\/a><\/p>\n<p><strong>Output<\/strong><\/p>\n<p>Here are some of the pictures\u00a0 I took of my diode and BJT tester while testing various input conditions.<\/p>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-822\" title=\"Img_PIC16F688_DiodeTester_Good\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good-550x415.jpg\" alt=\"\" width=\"550\" height=\"415\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good-550x415.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good.jpg 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-819\" title=\"Img_PIC16F688_BJTTesterPNPDetails\" src=\"http:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails-550x414.jpg\" alt=\"\" width=\"550\" height=\"414\" srcset=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails-550x414.jpg 550w, https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails.jpg 600w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p><strong>Rest of the pictures<\/strong><\/p>\n\n\t\t<style>\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 25%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-815 gallery-columns-4 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Short.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Short-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Open.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Open-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester_Good-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_DiodeTester-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterShort.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterShort-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterPNPDetails-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterNPNDetails.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterNPNDetails-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterNPN.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Img_PIC16F688_BJTTesterNPN-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTesterLogic.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTesterLogic-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTester_PIC16F688.jpg'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_DiodeTester_PIC16F688-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_BJTTesterLogic.png'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/embedded-lab.com\/blog\/wp-content\/uploads\/2010\/11\/Circuit_BJTTesterLogic-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl>\n\t\t\t<br style='clear: both' \/>\n\t\t<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Introduction Most of the digital multimeters these days have built-in features for testing diodes and sometimes transistors. The purpose of this project is to demonstrate a simple way to construct a testing device for diodes and bipolar junction transitors (BJTs) using a microcontroller. The testing algorithm is based on a simple fact that a working PN junction conducts current in only one direction. A PIC16F688 microcontroller is used in this project that switches the bias voltage across the PN junctions of diode and transistors, and determines if a particular junction is normal, open or short. Theory The logic behind testing<\/p>\n","protected":false},"author":2,"featured_media":817,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[85,84,87,1307,86],"class_list":["post-815","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pic-projects","tag-bjt-tester","tag-diode-tester","tag-pic-diode-transistor-tester","tag-pic-projects","tag-transistor-tester"],"_links":{"self":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/comments?post=815"}],"version-history":[{"count":46,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":5836,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/posts\/815\/revisions\/5836"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media\/817"}],"wp:attachment":[{"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/media?parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/categories?post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/embedded-lab.com\/blog\/wp-json\/wp\/v2\/tags?post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}