G3TR Transistor Tester Identifier

I did a research on the forum about the G3TR but i have found notthing

I think it’s a preatty interessing project. It sense and identify the transistor connected to the “shield”
just 2x10k res are needed.

Here is mine :wink:

Since the owner saved the sketch is in PDF ( -.- ) , extracting it properly is quite annoying. So i will copypaste the sketch here.

Enjoy:

/******************************************************************************

 * filename: g3tr.pde
* 
* G3TR means: Giuseppe Talarico Transistor Type Recognizer
* 
* This version is for Arduino 
* 
* Just only two 10K resistors and a serial terminal program are needed to implement 
* a simple and powerfull digital Transistor Tester.
* The circuit allows to test any type of transistor ( npn,pnp, n-channel, p-channel )
* both low or High Power. 
* The program tell us if the transistor under test is working or not and which is his type
* for example: NPN-BJT, PNP-BJT, NCHANNEL-MOSFET, PCHANNEL-MOSFET.
* The program test diode too and tell us where the Anode is attached ( RED CABLE or BLACK CABLE)
* Devices broken or shorted are decoded too. 
* 
* 
* date: 6 aprile 2012 
* Author: Giuseppe Talarico 
* giuseppetalarico.wordpress.com
* 
* 
*****************************************************************************/ 
/*

* G3TR Schematic: 
* 
* 
* --------------------------------------------------------------> to GATE (BASE)
* | 
* | ----------------------* 
| | Arduino |
* | | | 
* | -------| |
* --| 10K |--------|D9 |
* | -------| |
* | | D10 |------------------> to SOURCE (EMITTER)(A)(K) 
* | | | -------* 
---------------->|D8 D11 |---| 10K |-------> to DRAIN (COLLECTOR)(K)(A)
* | | -------- | 
* ____/ ________|D6 | |
* | | | |
* ---| | | 
* | D7 |<---------------* 
----------------------- 
* 
*/ 
enum {FALSE,TRUE}; 

//------------------------- hardware abstractions ------------------------


// constants are used here to set pin numbers: 


const byte BTN1 = 6; //Button Switch 


const byte DRAIN_IN = 7; // if n-channel (npn) this bit is !(R_GATE_OUT) 
const byte BJT_MOSFET_IN = 8; // if DIGITAL PIN 8 = L the devices is a MOSFET otherwise the devices is a BJT 


const byte R_GATE_OUT = 9; // DIGITAL PIN 9 gate or base driver 
const byte SOURCE_OUT = 10; // DIGITAL PIN 10 L --> N-Channel select, H --> P-channel select 
const byte R_DRAIN_OUT = 11; // if DIGITAL PIN 11 = H then NPN else PNP 


//----------------- constant String ----------------------------------------- 


const char title[] ="\n\n\r* Transistor Type Recognizer *\n\n\r" ; 
const char prompt[] ="\n\rG3TR> "; 






//----------------------- global variables ---------------------------------

 
boolean recognized; 

//---------------------------------------------------------------------------


void setup() 
{

 Serial.begin(9600); 

//configure outputs:

 pinMode(R_GATE_OUT, OUTPUT); 
pinMode(SOURCE_OUT, OUTPUT); 
pinMode(R_DRAIN_OUT, OUTPUT); 


//configure inputs:

 pinMode(BJT_MOSFET_IN, INPUT); 
pinMode(DRAIN_IN, INPUT);


 pinMode(BTN1, INPUT); 
digitalWrite(BTN1,HIGH); // internal pull-up ON


 } 

//================================= M A I N L O O P ===================================== 

void loop() 
{

 recognized=FALSE;

 Serial.println(title); 
Serial.print(prompt); 


while (TRUE)
{
if (recognized) 
{
recognized=FALSE; 


while (digitalRead(BTN1)==1); // wait BTN1 pressed 
delay(200); 
Serial.print(prompt); 


} 

if(digitalRead(BTN1)==0) // wait BTN1 pressed 
{ 


recognized=FALSE; 
try_npn_nchannel(); 


if (!recognized)
{ 
try_pnp_pchannel(); 


if (!recognized) 
{ 
try_diode(); 


if (!recognized) 
{ 
try_short(); 


if (!recognized) 
try_broken();
} 
}
} 





 }

 }//end while 

} // end loop 

//----------------------- g3tr procedures ---------------------------------


void try_npn_nchannel(void)
{ 

//Serial.println("try npn/N-channel...\n"); 
// Polarize the transistor under test like NPN or NCHANNEL 
digitalWrite(R_GATE_OUT, HIGH); // gate (base) -------> H 
digitalWrite(R_DRAIN_OUT, HIGH); // drain (collector)--> H 
digitalWrite(SOURCE_OUT, LOW); // source (emitter) --> L


 delay( 20 ); // msec 

if(digitalRead(DRAIN_IN)== 0)
{ 


// may be npn or n-channel 
digitalWrite(R_GATE_OUT,LOW); // gate (base) -------> L
delay(20); 
if(digitalRead(DRAIN_IN)!=0)


{

//It is npn or n-channel

 recognized =TRUE; 

// now it decides for npn-bjt or nchannel-mosfet 
digitalWrite(R_GATE_OUT,HIGH); // gate (base) ------ > H 
delay(20);
if( digitalRead(BJT_MOSFET_IN)!= 0)


 Serial.println(" N-CHANNEL MOSFET");

else

 Serial.println(" NPN BJT");
}
} 


}//end try_npn_nchannel 

//----------------------------------------------------------------------------------------------------


void try_pnp_pchannel(void) 
{ 

//Serial.println("try pnp/P-channel...\n");
// Polarize the transistor under test like PNP or PCHANNEL 
digitalWrite(R_DRAIN_OUT,LOW); // drain (collector)---> L 
digitalWrite(SOURCE_OUT, HIGH); // source (emitter) ----> H 
digitalWrite(R_GATE_OUT, HIGH); // gate (base) -------> H
delay(20); 
if( digitalRead(DRAIN_IN)==0)


{ 

// may be pnp or p-channel 
digitalWrite(R_GATE_OUT, LOW); // gate (base) --> L
delay(20);
if( digitalRead(DRAIN_IN)!=0)


 {

//It is pnp or p-channel

recognized =TRUE; 

// now it decides for pnp-bjt or p-channel mosfet 
digitalWrite(R_GATE_OUT, LOW); // gate (base) --> L
delay(20);
if( digitalRead(BJT_MOSFET_IN)== 0)


 Serial.println("P-CHANNEL MOSFET");

else

 Serial.println("PNP BJT"); 
}
} 






}//end try_pnp_pchannel() 

//---------------------------------------------------------------------------------------


void try_diode(void) 
{ 

//Serial.println("try DIODE...");
//Polarize the DIODE under test 
digitalWrite(R_DRAIN_OUT, HIGH); // Anode ---> H 
digitalWrite(SOURCE_OUT, LOW); // Catode---> L
delay(20); 


if(digitalRead(DRAIN_IN)==LOW)
{


//may be a DIODE; to verify, invert Polarization 
digitalWrite(R_DRAIN_OUT, LOW); // Anode ---> L 
digitalWrite(SOURCE_OUT, HIGH); // Catode---> H


 delay(20);
if( digitalRead(DRAIN_IN) ==LOW)


{ 
recognized =TRUE; 
Serial.println("DIODE [Anode on RED cable]");


} 
}
if (!recognized)
{


//Polarize the DIODE under test in a different way 
digitalWrite(R_DRAIN_OUT, LOW); // Catode--> L 
digitalWrite(SOURCE_OUT, HIGH); // Anode---> H
delay(20); 
if(digitalRead(DRAIN_IN)==HIGH)


{

//may be a DIODE, so invert Polarization 
digitalWrite(R_DRAIN_OUT,HIGH); // Catode --> H 
digitalWrite(SOURCE_OUT,LOW); // Anode --> L
delay(20);
if( digitalRead(DRAIN_IN)==HIGH)


 { 
recognized =TRUE; 
Serial.println("DIODE [Anode on BLACK cable]");


 }
}
} 


}//end try_diode() 

//-----------------------------------------------------------------------------------------


void try_short(void)
{ 

 digitalWrite(R_DRAIN_OUT, HIGH); // H 
digitalWrite(SOURCE_OUT, LOW); // L 
delay(20); 


if( digitalRead(DRAIN_IN)==0)

 { 
digitalWrite(R_DRAIN_OUT, LOW); // L 
digitalWrite(SOURCE_OUT, HIGH); // H 
delay(20);
if(digitalRead(DRAIN_IN)!=0)


{ 
recognized =TRUE; 
Serial.println("DEVICE SHORTED");


}
} 
}//end try_short(); 

//---------------------------------------------------------------------------------


void try_broken(void) 
{

 digitalWrite(R_DRAIN_OUT, HIGH); // H 
digitalWrite(SOURCE_OUT, LOW); // Ldelay(20); 
if( digitalRead(DRAIN_IN)!=0)

{ 
digitalWrite(R_DRAIN_OUT, LOW); // L 
digitalWrite(SOURCE_OUT, HIGH); // Hdelay(20);
if(digitalRead(DRAIN_IN)==0)

 { 
recognized =TRUE; 
Serial.println("DEVICE BROKEN");

} 
} 


}//end try_broken()