1

Тема: tester

#define R1K  1000.00  // 1000.00
#define R1M  1000.00  // 1000.00
#define C_KN 2500    // 2500
#define C_KU 2100    // 2500
#define R0   -10.00

#include <Wire.h> 
#include <U8glib.h>            // https://github.com/olikraus/u8glib/
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);
int u,diod,mk;
bool d1,d2,r1,r2,rez;
float uf,ur,r,r_iz,up,r_sum;
long time0,time1,time2,ers;
int hfe,c0;
float ib,ic;
float z1,z2,z3,i1,i2,i3;
float ub,uc,hhf;
bool vt,pnp;
char*ebc;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,OUTPUT);
  delay(300);
  cl();
  analogReadResolution(12);
  analogReference(INTERNAL1V024);
  up=5.00*1.024*analogRead(VCCM)/4096;
  cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(2,1,2,0);while(analogRead(A2)>0){}pmdg(2,1,2,1);
  long time0=micros();while(analogRead(A2)<C_KN){time1=micros()-time0;if(time1>1000000){break;}}
  c0=time1*2.5;
  Serial.print("VDD=");Serial.print(up);Serial.println(" V");
  Serial.print("C_0=");Serial.print(c0);Serial.println(" pF");
  Serial.println();
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);u8g.drawStr(25,30,"RCL-RADIO.RU");} while( u8g.nextPage() );
   delay(1000);
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);u8g.drawStr(0,8,"VDD=");u8g.setPrintPos(30, 8);u8g.print(up);
   u8g.drawStr(60,8,"V");
   u8g.setFont(u8g_font_profont12r);u8g.drawStr(0,18,"C_0=");u8g.setPrintPos(30, 18);u8g.print(c0);
   u8g.drawStr(60,18,"pF");
   u8g.drawLine(0, 32, 128, 32);
   u8g.drawStr(50,44,"START");
   } while( u8g.nextPage() );
}

void loop() {
  /////////////////////////// tranz bip n-p-n /////////////////////////////////////////////////
//1 ebc
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(4,1,4,1);pmdg(3,1,3,1);delay(10);
 ub = up/4096*analogRead(A1);
 uc = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="EBC";  serial_bip();}
//2 ecb
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(2,1,2,1);delay(10);
 uc = up/4096*analogRead(A1);
 ub = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1;  ebc="ECB";serial_bip();}
//3 bce
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);delay(1000);pmdg(6,1,6,1);pmdg(5,1,5,1);pmdg(A2,1,A2,0);delay(10);
 uc = up/4096*analogRead(A1);
 ub = up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="BCE"; serial_bip();}
//4 bec
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,1);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);
 uc = up/4096*analogRead(A2);
 ub = up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="BEC"; serial_bip();}
//5 cbe
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,1);pmdg(4,1,4,1);pmdg(A2,1,A2,0);delay(10);
 uc = up/4096*analogRead(A0);
 ub = up/4096*analogRead(A1);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="CBE"; serial_bip();}
//6 ceb
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,1);pmdg(A1,1,A1,0);pmdg(2,1,2,1);delay(10);
 uc = up/4096*analogRead(A0);
 ub = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="CEB"; serial_bip();}
/////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////// tranz bip p-n-p /////////////////////////////////////////////////
//1 ebc
cl();analogReference(INTERNAL4V096);pmdg(7,1,7,1);pmdg(A1,1,A1,0);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);pmdg(4,1,4,0);pmdg(3,1,3,0);delay(100);
 ub = up-up/4096*analogRead(A1);
 uc = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0;ebc="ECB";serial_bip();}
//2 ecb
cl();analogReference(INTERNAL4V096);pmdg(5,1,5,1);pmdg(A2,1,A2,0);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);pmdg(5,1,5,0);pmdg(2,1,2,0);delay(100);
 uc = up-up/4096*analogRead(A1);
 ub = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="ECB"; serial_bip();}
//3 bce
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(5,1,5,0);pmdg(A2,1,A2,1);delay(100);
 uc = up-up/4096*analogRead(A1);
 ub = up-up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="BCE"; serial_bip();}
//4 bec
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(A1,1,A1,1);pmdg(3,1,3,0);delay(100);
 uc = up-up/4096*analogRead(A2);
 ub = up-up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="BEC"; serial_bip();}
//5 cbe
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,0);pmdg(4,1,4,0);pmdg(A2,1,A2,1);delay(100);
 uc = up-up/4096*analogRead(A0);
 ub = up-up/4096*analogRead(A1);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="CBE"; serial_bip();}
//6 ceb
cl();analogReference(INTERNAL4V096);pmdg(7,1,7,1);pmdg(A2,1,A2,0);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,0);pmdg(A1,1,A1,1);pmdg(2,1,2,0);delay(100);
 uc = up-up/4096*analogRead(A0);
 ub = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="CEB";serial_bip();}
///////////////////////////////////////////////////////////////////////////////////////////////////

if(vt==0){
//// diod ////////////////////////////////////////////////////////////////////////////////////////  
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);
  if(u<4000){d1 = 1;uf=up*u/4096.0;
  cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(2,1,2,0);delay(200);pmdg(2,1,2,1);
  long time0=micros();while(analogRead(A2)<C_KN){time1=(micros()-time0)*2.5-c0;if(time1>5000){break;}}
  }else{d1 =0;}
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);
  if(u<4000){d2 = 1;uf=up*u/4096.0;
  cl();analogReference(INTERNAL4V096);pmdg(6,1,6,0);pmdg(A2,1,A2,0);delay(200);pmdg(6,1,6,1);
  long time0=micros();while(analogRead(A0)<C_KN){time1=(micros()-time0)*2.5-c0;if(time1>5000){break;}}
  }else{d2 =0;}
  if(d1>d2){Serial.print("-|>|-");Serial.print(" Vf=");Serial.print(uf,3);Serial.println(" V");
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"DIOD");
  u8g.drawLine(0, 13, 128, 13);
  u8g.drawStr(0,30,"A-C");
    if(time1>=0){Serial.print("C=");Serial.print(time1);Serial.println(" pF");}u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,45,"Vf= ");u8g.setPrintPos(30,45);u8g.print(uf,3);u8g.drawStr(68,45,"V");
  u8g.drawStr(0,57,"C = ");u8g.setPrintPos(30,57);u8g.print(time1);u8g.drawStr(68,57,"pF");
    } while( u8g.nextPage() );}
  if(d1<d2){Serial.print("-|<|-");Serial.print(" Vf=");Serial.print(uf,3);Serial.println(" V");
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"DIOD");
  u8g.drawLine(0, 13, 128, 13);
  u8g.drawStr(0,30,"C-A");
    if(time1>=0){Serial.print("C=");Serial.print(time1);Serial.println(" pF");}
  u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,45,"Vf= ");u8g.setPrintPos(30,45);u8g.print(uf,3);u8g.drawStr(68,45,"V");
  u8g.drawStr(0,57,"C = ");u8g.setPrintPos(30,57);u8g.print(time1);u8g.drawStr(68,57,"pF");
    } while( u8g.nextPage() );  } 
////////////////////////////////////////////////////////////////////////////////////////////////// 

/// r? c? /////
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);delay(1000);pmdg(7,1,7,1);
  float u1 = analogRead(A0);
  delay(100);
  float u2 = analogRead(A0);
  Serial.println(u1);
  Serial.println(u2);
  if(u2-u1<3){rez=1;}else{rez=0;}
  
//  rez=1;
//// rezistor //////////////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==1){
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);delay(10);
  float upd=up*analogRead(A0)/4096.0;
 // Serial.println(upd,3);
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(6,1,6,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
 // Serial.println(upp);
 // Serial.println(ur,3);
  r = ur*510000.0/(upd-ur);
  if(r>=6800){r2=1;r_iz=r;}else{r2=0;}
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
  r = ur*680.0/(upd-ur);
  if(r<6800){r1=1;r_iz=r;}else{r1=0;}
  if(r1==1&&r2==0){Serial.print("R=");Serial.print(r_iz+R0,1);Serial.println(" Om");}
  if(r2==1&&r1==0&&r_iz<=5000000){Serial.print("R=");Serial.print(r_iz/1000.00,1);Serial.println(" kOm");}
 }
//////////////////////////////////////////////////////////////////////////////////////////////////


//// condensator + esr /////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==0){
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);while(analogRead(A2)>20){}pmdg(7,1,7,1);
  time0=micros();
  while(analogRead(A0)<C_KU){time1=(micros()-time0)*2.5;
  if(time1>5000000){mk=2;break;}}
  //Serial.println(time1);
  if(time1<1500){mk=1;
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(6,1,6,0);pmdg(A2,1,A2,0);delay(1000);pinMode(7,INPUT);pmdg(6,1,6,1);
  time0=micros();
  while(analogRead(A0)<C_KN){time1=(micros()-time0)*2.5-c0;
  if(time1>1500000){break;}
  }}
  if(mk==1){Serial.print("C=");Serial.print(time1/1000.00,3);Serial.println(" nF");}
  if(mk==0){Serial.print("C=");Serial.print(time1/1000.00,1);Serial.println(" uF");}
  time1=0;mk=0;
// esr
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(3,1,3,0);while(analogRead(A0)>20){}
  for(int i=0;i<10000;i++){
    digitalWrite(3,1);delayMicroseconds(10);digitalWrite(7,0);delayMicroseconds(10);
    digitalWrite(3,0);delayMicroseconds(5);digitalWrite(7,1);delayMicroseconds(5);
  }
  float esr_iz = abs(analogRead(A0)-analogRead(A2))/1000.0;
  if(esr_iz<4 && mk<2){Serial.print("ESR=");Serial.print(esr_iz);Serial.println(" Om");}
  }
////////////////////////////////////////////////////////////////////////////////////////////////// 


Serial.println();

}//end vt=0
Serial.println();

//delay(1000);
 vt=0;
// u8g.firstPage();  do { } while( u8g.nextPage() );
}

void serial_bip(){
Serial.print("Vf=");Serial.print(uf,3);Serial.println(" V");  
Serial.print("ub=");Serial.print(ub,3);Serial.println(" V");
Serial.print("uc=");Serial.print(uc,3);Serial.println(" V");
Serial.print("ib=");Serial.print(ib,6);Serial.println(" mA");
Serial.print("ic=");Serial.print(ic,3);Serial.println(" mA");
Serial.print("hfe=");Serial.println(hhf,0);
if(pnp==0){Serial.println("P-N-P");}else{Serial.println("N-P-N");}
Serial.println(ebc);
u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"BJT");
if(pnp==0){u8g.drawStr(55,9,"p-n-p");}else{u8g.drawStr(55,9,"n-p-n");}
u8g.drawLine(0, 13, 128, 13);
u8g.setFont(u8g_font_profont12r);
u8g.drawStr(0,24,"Vf = ");u8g.setPrintPos(30, 24);u8g.print(uf,3);u8g.drawStr(62,24,"V");
u8g.drawStr(0,34,"Ub = ");u8g.setPrintPos(30, 34);u8g.print(ub,3);u8g.drawStr(62,34,"V");
u8g.drawStr(0,44,"Uc = ");u8g.setPrintPos(30, 44);u8g.print(uc,3);u8g.drawStr(62,44,"V");
u8g.drawStr(0,54,"Ib = ");u8g.setPrintPos(30, 54);u8g.print(ib*1000,3);u8g.drawStr(62,54,"uA");
u8g.drawStr(0,64,"Ic = ");u8g.setPrintPos(30, 64);u8g.print(ic,3);u8g.drawStr(62,64,"mA");
u8g.setFont(u8g_font_profont17r);u8g.drawStr(90,30,"HFE");u8g.setPrintPos(90, 45);u8g.print(hhf,0);
u8g.drawStr(90,64,ebc);
} while( u8g.nextPage() );
  }

void cl(){
  pinMode(2,INPUT);pinMode(3,INPUT);pinMode(4,INPUT);pinMode(5,INPUT);
  pinMode(6,INPUT);pinMode(7,INPUT);pinMode(A0,INPUT);pinMode(A1,INPUT);pinMode(A2,INPUT);
  }
void pmdg(int pinmode, bool xp, int digwrite, bool xd){pinMode(pinmode,xp);digitalWrite(digwrite,xd);}  

2

Re: tester

#define R1K  1000.00  // 1000.00
#define R1M  1000.00  // 1000.00
#define C_KN 2500    // 2500
#define C_KU 2100    // 2500
#define R0   -10.00
//A0 A1 A2
//D7 D5 D3 680
//D6 D4 D2 470K
#include <Wire.h> 
#include <U8glib.h>            // https://github.com/olikraus/u8glib/
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);
int u,diod,mk;
bool d1,d2,r1,r2,rez;
float uf,ur,r,r_iz,up,r_sum;
long c0,time0,time1,time2,ers;
int hfe;
float ib,ic;
float z1,z2,z3,i1,i2,i3;
float ub,uc,hhf;
bool vt,pnp;
char*ebc;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,OUTPUT);
  delay(300);
  cl();
  analogReadResolution(12);
  analogReference(INTERNAL1V024);
  up=5.00*1.024*analogRead(VCCM)/4096;
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A0)>0){}
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  c0=time1/1.7;
  Serial.print("VDD=");Serial.print(up);Serial.println(" V");
  Serial.print("C_0=");Serial.print(c0);Serial.println(" pF");
  Serial.println();
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);u8g.drawStr(25,30,"RCL-RADIO.RU");} while( u8g.nextPage() );
   delay(1000);
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);u8g.drawStr(0,8,"VDD=");u8g.setPrintPos(30, 8);u8g.print(up);
   u8g.drawStr(60,8,"V");
   u8g.setFont(u8g_font_profont12r);u8g.drawStr(0,18,"C_0=");u8g.setPrintPos(30, 18);u8g.print(c0);
   u8g.drawStr(60,18,"pF");
   u8g.drawLine(0, 32, 128, 32);
   u8g.drawStr(50,44,"START");
   } while( u8g.nextPage() );
}

void loop() {
  /////////////////////////// tranz bip n-p-n /////////////////////////////////////////////////
//1 ebc
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(4,1,4,1);pmdg(3,1,3,1);delay(10);
 ub = up/4096*analogRead(A1);
 uc = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="EBC";  serial_bip();}
//2 ecb
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(2,1,2,1);delay(10);
 uc = up/4096*analogRead(A1);
 ub = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1;  ebc="ECB";serial_bip();}
//3 bce
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);delay(1000);pmdg(6,1,6,1);pmdg(5,1,5,1);pmdg(A2,1,A2,0);delay(10);
 uc = up/4096*analogRead(A1);
 ub = up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="BCE"; serial_bip();}
//4 bec
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,1);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);
 uc = up/4096*analogRead(A2);
 ub = up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="BEC"; serial_bip();}
//5 cbe
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,1);pmdg(4,1,4,1);pmdg(A2,1,A2,0);delay(10);
 uc = up/4096*analogRead(A0);
 ub = up/4096*analogRead(A1);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="CBE"; serial_bip();}
//6 ceb
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,1);pmdg(A1,1,A1,0);pmdg(2,1,2,1);delay(10);
 uc = up/4096*analogRead(A0);
 ub = up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=1; ebc="CEB"; serial_bip();}
/////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////// tranz bip p-n-p /////////////////////////////////////////////////
//1 ebc
cl();analogReference(INTERNAL4V096);pmdg(7,1,7,1);pmdg(A1,1,A1,0);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);pmdg(4,1,4,0);pmdg(3,1,3,0);delay(100);
 ub = up-up/4096*analogRead(A1);
 uc = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0;ebc="ECB";serial_bip();}
//2 ecb
cl();analogReference(INTERNAL4V096);pmdg(5,1,5,1);pmdg(A2,1,A2,0);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);pmdg(5,1,5,0);pmdg(2,1,2,0);delay(100);
 uc = up-up/4096*analogRead(A1);
 ub = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="ECB"; serial_bip();}
//3 bce
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(5,1,5,0);pmdg(A2,1,A2,1);delay(100);
 uc = up-up/4096*analogRead(A1);
 ub = up-up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="BCE"; serial_bip();}
//4 bec
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(5,1,5,1);delay(10);u = analogRead(A1);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(A1,1,A1,1);pmdg(3,1,3,0);delay(100);
 uc = up-up/4096*analogRead(A2);
 ub = up-up/4096*analogRead(A0);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="BEC"; serial_bip();}
//5 cbe
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,0);pmdg(4,1,4,0);pmdg(A2,1,A2,1);delay(100);
 uc = up-up/4096*analogRead(A0);
 ub = up-up/4096*analogRead(A1);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="CBE"; serial_bip();}
//6 ceb
cl();analogReference(INTERNAL4V096);pmdg(7,1,7,1);pmdg(A2,1,A2,0);delay(10);u = analogRead(A0);uf=float(u)/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,0);pmdg(A1,1,A1,1);pmdg(2,1,2,0);delay(100);
 uc = up-up/4096*analogRead(A0);
 ub = up-up/4096*analogRead(A2);
 ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;
pnp=0; ebc="CEB";serial_bip();}
///////////////////////////////////////////////////////////////////////////////////////////////////

if(vt==0){
  /*
//// diod ////////////////////////////////////////////////////////////////////////////////////////  
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);
  if(u<4000){d1 = 1;uf=up*u/4096.0;
  cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,0);delay(200);
  pmdg(3,1,3,1);delay(100);pinMode(3,INPUT);pmdg(2,1,2,0);
  time0=micros();while(analogRead(A2)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;
  }else{d1 =0;}
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);
  if(u<4000){d2 = 1;uf=up*u/4096.0;
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);delay(200);
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;
  }else{d2 =0;}
  if(d1>d2){Serial.print("-|>|-");Serial.print(" Vf=");Serial.print(uf,3);Serial.println(" V");
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"DIOD");
  u8g.drawLine(0, 13, 128, 13);
  u8g.drawStr(0,30,"A-C");
    if(time1>=0){Serial.print("C=");Serial.print(time1);Serial.println(" pF");}u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,45,"Vf= ");u8g.setPrintPos(30,45);u8g.print(uf,3);u8g.drawStr(68,45,"V");
  u8g.drawStr(0,57,"C = ");u8g.setPrintPos(30,57);u8g.print(time1);u8g.drawStr(68,57,"pF");
    } while( u8g.nextPage() );}
  if(d1<d2){Serial.print("-|<|-");Serial.print(" Vf=");Serial.print(uf,3);Serial.println(" V");
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"DIOD");
  u8g.drawLine(0, 13, 128, 13);
  u8g.drawStr(0,30,"C-A");
    if(time1>=0){Serial.print("C=");Serial.print(time1);Serial.println(" pF");}
  u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,45,"Vf= ");u8g.setPrintPos(30,45);u8g.print(uf,3);u8g.drawStr(68,45,"V");
  u8g.drawStr(0,57,"C = ");u8g.setPrintPos(30,57);u8g.print(time1);u8g.drawStr(68,57,"pF");
    } while( u8g.nextPage() );  } 
////////////////////////////////////////////////////////////////////////////////////////////////// 
*/
/// r? c? /////
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);delay(1000);pmdg(7,1,7,1);
  float u1 = analogRead(A0);
  delay(100);
  float u2 = analogRead(A0);
  Serial.println(u1);
  Serial.println(u2);
  if(u2-u1<3){rez=1;}else{rez=0;}
  
  rez=0;
//// rezistor //////////////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==1){
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);delay(10);
  float upd=up*analogRead(A0)/4096.0;
 // Serial.println(upd,3);
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(6,1,6,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
 // Serial.println(upp);
 // Serial.println(ur,3);
  r = ur*510000.0/(upd-ur);
  if(r>=6800){r2=1;r_iz=r;}else{r2=0;}
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
  r = ur*680.0/(upd-ur);
  if(r<6800){r1=1;r_iz=r;}else{r1=0;}
  if(r1==1&&r2==0){Serial.print("R=");Serial.print(r_iz+R0,1);Serial.println(" Om");}
  if(r2==1&&r1==0&&r_iz<=5000000){Serial.print("R=");Serial.print(r_iz/1000.00,1);Serial.println(" kOm");}
 }
//////////////////////////////////////////////////////////////////////////////////////////////////


//// condensator + esr /////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==0){
  /// c > 0.5 uF
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,1);pmdg(7,1,7,1);while(analogRead(A2)<3000){}pmdg(7,1,7,0);
  time0=micros();
  while(analogRead(A0)>600){time1=(micros()-time0)/1.46;}
  if(time1<500){mk=0;}else{mk=1;}
  if(mk==0){
  //// c < 0.5 uf
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A0)>0){}
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;}
  if(mk==0){Serial.print("C=");Serial.print(time1/1000.00,3);Serial.println(" nF");}
  if(mk==1){Serial.print("C=");Serial.print(time1/1000.00,1);Serial.println(" uF");}
  time1=0;mk=0;
// esr
//A0 A1 A2
//D7 D5 D3 680
//D6 D4 D2 470K
  long a=0,b=0,c=0,d=0;
  long uzh,uzl;
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);while(analogRead(A0)>0){}
  cl();analogReference(INTERNAL4V096);pmdg(3,1,3,0);pmdg(A0,1,A0,0);while(analogRead(A2)>0){}
    cl();
  for(int i=0;i<1000;i++){
    pmdg(7,1,7,1);pmdg(A2,1,A2,0);a=a+analogRead(A0);
  cl();  pinMode(7,INPUT);pinMode(A2,INPUT);b=b+analogRead(A0);
    pmdg(3,1,3,1);pmdg(A0,1,A0,0);c=c+analogRead(A2);
  cl();  pinMode(3,INPUT);pinMode(A0,INPUT);d=d+analogRead(A2);}
  float esr_iz = abs(b-d)/100000.00;
  Serial.print("ESR=");Serial.print(esr_iz);Serial.println(" Om");
 }
////////////////////////////////////////////////////////////////////////////////////////////////// 


Serial.println();

}//end vt=0
Serial.println();

//delay(1000);
 vt=0;
// u8g.firstPage();  do { } while( u8g.nextPage() );
}

void serial_bip(){
Serial.print("Vf=");Serial.print(uf,3);Serial.println(" V");  
Serial.print("ub=");Serial.print(ub,3);Serial.println(" V");
Serial.print("uc=");Serial.print(uc,3);Serial.println(" V");
Serial.print("ib=");Serial.print(ib,6);Serial.println(" mA");
Serial.print("ic=");Serial.print(ic,3);Serial.println(" mA");
Serial.print("hfe=");Serial.println(hhf,0);
if(pnp==0){Serial.println("P-N-P");}else{Serial.println("N-P-N");}
Serial.println(ebc);
u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"BJT");
if(pnp==0){u8g.drawStr(55,9,"p-n-p");}else{u8g.drawStr(55,9,"n-p-n");}
u8g.drawLine(0, 13, 128, 13);
u8g.setFont(u8g_font_profont12r);
u8g.drawStr(0,24,"Vf = ");u8g.setPrintPos(30, 24);u8g.print(uf,3);u8g.drawStr(62,24,"V");
u8g.drawStr(0,34,"Ub = ");u8g.setPrintPos(30, 34);u8g.print(ub,3);u8g.drawStr(62,34,"V");
u8g.drawStr(0,44,"Uc = ");u8g.setPrintPos(30, 44);u8g.print(uc,3);u8g.drawStr(62,44,"V");
u8g.drawStr(0,54,"Ib = ");u8g.setPrintPos(30, 54);u8g.print(ib*1000,3);u8g.drawStr(62,54,"uA");
u8g.drawStr(0,64,"Ic = ");u8g.setPrintPos(30, 64);u8g.print(ic,3);u8g.drawStr(62,64,"mA");
u8g.setFont(u8g_font_profont17r);u8g.drawStr(90,30,"HFE");u8g.setPrintPos(90, 45);u8g.print(hhf,0);
u8g.drawStr(90,64,ebc);
} while( u8g.nextPage() );
  }

void cl(){
  pinMode(2,INPUT);pinMode(3,INPUT);pinMode(4,INPUT);pinMode(5,INPUT);
  pinMode(6,INPUT);pinMode(7,INPUT);pinMode(A0,INPUT);pinMode(A1,INPUT);pinMode(A2,INPUT);
  }
void pmdg(int pinmode, bool xp, int digwrite, bool xd){pinMode(pinmode,xp);digitalWrite(digwrite,xd);}  

3

Re: tester

Что-то интересное, но не сильно понятное

4

Re: tester

#define R1K  1000.00  // 1000.00
#define R1M  1000.00  // 1000.00
#define C_KN 2500    // 2500
#define C_KU 2100    // 2500
#define R0   -10.00
//A0 A1 A2
//D7 D5 D3 680
//D6 D4 D2 470K
#include <Wire.h> 
#include <U8glib.h>            // https://github.com/olikraus/u8glib/
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);
int u,diod,mk,mosfet;
bool d1,d2,r1,r2,rez;
float uf,ur,r,r_iz,up,r_sum;
long c0,time0,time1,time2,ers;
int hfe;
float ib,ic;
float z1,z2,z3,i1,i2,i3;
float ub,uc,hhf,upd;
bool vt,pnp,mosf;
char*ebc;
char* mos;
char* mos1;
float ud,ug,vtt,u_d;
int g;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,OUTPUT);
  pinMode(9,INPUT_PULLUP);
  delay(300);
  cl();
  analogReadResolution(12);
  analogReference(INTERNAL1V024);
  up=5.00*1.024*analogRead(VCCM)/4096;
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A0)>0){}
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  c0=time1/1.7;
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);u8g.drawStr(25,30,"RCL-RADIO.RU");} while( u8g.nextPage() );
   delay(1000);
  u8g.firstPage(); do {u8g.drawStr(0,8,"VDD=");u8g.setPrintPos(30, 8);u8g.print(up);u8g.drawStr(60,8,"V");
  u8g.drawStr(0,18,"C_0=");u8g.setPrintPos(30, 18);u8g.print(c0);u8g.drawStr(60,18,"pF");
  u8g.drawLine(0, 32, 128, 32);u8g.drawStr(50,44,"START"); } while( u8g.nextPage() );
}

void loop() {
 if(digitalRead(9)==0){
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont12r);
   u8g.drawLine(0, 32, 128, 32);
   u8g.drawStr(50,44,"TEST");
   } while( u8g.nextPage() );
  delay(200); 

mosfet=0;  // G             D            S
/////// n-channel
cl();pmdg(7,1,7,1);pmdg(5,1,5,1);pmdg(A2,1,A2,0);
if(digitalRead(A1)==0 && digitalRead(A0)==1 && mosfet==0){
  cl();pmdg(7,1,7,0);pmdg(5,1,5,1);pmdg(A2,1,A2,0);
  if(digitalRead(A1)==1 && digitalRead(A0)==0){mosfet=1;}}
           // S             D            G
cl();pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(3,1,3,1);
if(digitalRead(A1)==0 && digitalRead(A2)==1 && mosfet==0){
  cl();pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(3,1,3,0);
  if(digitalRead(A1)==1 && digitalRead(A2)==0){mosfet=2;}}
          // G             D            S
cl();pmdg(7,1,7,1);pmdg(A1,1,A1,0);pmdg(3,1,3,1);
if(digitalRead(A2)==0 && digitalRead(A0)==1 && mosfet==0){
  cl();pmdg(7,1,7,0);pmdg(A1,1,A1,0);pmdg(3,1,3,1);
  if(digitalRead(A2)==1 && digitalRead(A0)==0){mosfet=3;}}

           //    S             G            D
cl();  pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(3,1,3,1);
if(digitalRead(A1)==1 && digitalRead(A2)==0 ){
  cl();pmdg(A0,1,A0,0);pmdg(5,1,5,0);pmdg(3,1,3,1);
  if(digitalRead(A1)==0 && digitalRead(A2)==1){mosfet=4;}}

           //    D             G            S
cl();  pmdg(7,1,7,1);pmdg(5,1,5,1);pmdg(A2,1,A2,0);Serial.println(digitalRead(A0));Serial.println(digitalRead(A1));
if(digitalRead(A0)==0 && digitalRead(A1)==1 ){
  cl();pmdg(7,1,7,1);pmdg(5,1,5,0);pmdg(A2,1,A2,0);Serial.println(digitalRead(A0));Serial.println(digitalRead(A1));
  if(digitalRead(A0)==1 && digitalRead(A1)==0){mosfet=5;}}



/// p
cl();pmdg(7,1,7,1);pmdg(5,1,5,0);pmdg(A2,1,A2,1);
if(digitalRead(A1)==0 && digitalRead(A0)==1 && mosfet==0){
  cl();pmdg(7,1,7,0);pmdg(5,1,5,0);pmdg(A2,1,A2,1);
  if(digitalRead(A1)==1 && digitalRead(A0)==0){mosfet=7;}}

cl();pmdg(A0,1,A0,1);pmdg(5,0,5,0);pmdg(3,1,3,0);
if(digitalRead(A1)==1 && digitalRead(A2)==0 && mosfet==0){
  cl();pmdg(A0,1,A0,1);pmdg(5,1,5,0);pmdg(3,1,3,0);
  if(digitalRead(A1)==1 && digitalRead(A2)==0){mosfet=8;}}  

Serial.println(mosfet);

pmdg(3,1,3,0);pmdg(5,1,5,0);pmdg(7,1,7,0);delay(10);

// N-channel
/*
if(mosfet==1){mos="GDS";mos1="N-E-MOS";mosf=1;
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(3,1,3,1);delay(10);uf=float(analogRead(A2))/1000.0;
cl();analogReference(INTERNAL1V024);pmdg(A2,1,A2,0);pmdg(5,1,5,1);pmdg(7,1,7,1);delay(10);
u_d = 1.024/4096*analogRead(A1);r = ((u_d*680.0/(up-u_d))-9.6)/90;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(5,1,5,0);pmdg(A2,1,A2,0);delay(10);pmdg(6,1,6,1);pmdg(5,1,5,1);
while(analogRead(A1)>4000){g=analogRead(A0);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);delay(200);
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  if(mosf==1){serial_mos();}
}*/
if(mosfet==2){mos="SDG";mos1="N-E-MOS";mosf=1;
cl();analogReference(INTERNAL4V096);pmdg(A1,1,A1,0);pmdg(7,1,7,1);delay(10);uf=float(analogRead(A0))/1000.0;
cl();analogReference(INTERNAL1V024);pmdg(A0,1,A0,0);pmdg(5,1,5,1);pmdg(3,1,3,1);delay(10);
u_d = 1.024/4096*analogRead(A1);r = ((u_d*680.0/(up-u_d))-9.6)/90;
cl();analogReference(DEFAULT);pmdg(2,1,2,0);pmdg(5,1,5,0);pmdg(A0,1,A0,0);delay(10);pmdg(2,1,2,1);pmdg(5,1,5,1);
while(analogRead(A1)>4000){g=analogRead(A2);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,0);delay(200);
  pmdg(3,1,3,1);delay(100);pinMode(3,INPUT);pmdg(2,1,2,0);
  time0=micros();while(analogRead(A2)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  if(mosf==1){serial_mos();}
}
if(mosfet==3){mos="GSD";mos1="N-E-MOS";mosf=1;
/*cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(5,1,5,1);delay(10);uf=float(analogRead(A1))/1000.0;
cl();analogReference(INTERNAL1V024);pmdg(A1,1,A1,0);pmdg(3,1,3,1);pmdg(7,1,7,1);delay(10);
u_d = 1.024/4096*analogRead(A2);r = ((u_d*680.0/(up-u_d))-9.6)/90;*/

 mos_1(3,1, 14,0, 16, 7,1, 5,1, 16,0, 14);//

cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(A1,1,A1,0);pmdg(3,1,3,0);delay(10);pmdg(6,1,6,1);pmdg(3,1,3,1);
while(analogRead(A2)>4000){g=analogRead(A0);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);delay(200);
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  if(mosf==1){serial_mos();}
}
if(mosfet==4){mos="SGD";mos1="N-E-MOS";mosf=1;
 mos_1(7,1, 16,0, 14, 14,0, 5,1, 3,1, 16);

cl();analogReference(DEFAULT);pmdg(A0,1,A0,0); pmdg(4,1,4,0);pmdg(3,1,3,0);delay(10);pmdg(4,1,4,1);pmdg(3,1,3,1);
while(analogRead(A2)>4000){g=analogRead(A1);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(5,1,5,0);delay(200);
  pmdg(5,1,5,1);delay(100);pinMode(5,INPUT);pmdg(4,1,4,0);
  time0=micros();while(analogRead(A1)>50){time1=micros()-time0;}time2=time1/1.7-c0;
 if(mosf==1){serial_mos();}
}
                 //SGD
if(mosfet==5){mos="DGS";mos1="N-E-MOS";mosf=1;
 mos_1(3,1, 14,0, 16, 7,1, 5,1, 16,0, 14);

cl();analogReference(DEFAULT);pmdg(7,1,7,0); pmdg(4,1,4,0);pmdg(A2,1,A2,0);delay(10);pmdg(4,1,4,1);pmdg(7,1,7,1);
while(analogRead(A0)>4000){g=analogRead(A1);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(5,1,5,0);delay(200);
  pmdg(5,1,5,1);delay(100);pinMode(5,INPUT);pmdg(4,1,4,0);
  time0=micros();while(analogRead(A1)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  if(mosf==1){serial_mos();}
}



// P-CANNEL
if(mosfet==7){mos="GDS";mos1="P-E-MOS";mosf=1;
cl();analogReference(INTERNAL4V096);pmdg(5,1,5,1);pmdg(A2,1,A2,0);delay(10);uf=float(analogRead(A1))/1000.0;
cl();analogReference(DEFAULT);pmdg(7,1,7,0);pmdg(5,1,5,0);pmdg(A2,1,A2,1);delay(10);
u_d = up-up/4096*analogRead(A1);r = ((u_d*680.0/(up-u_d))-9.6)/90;
cl();analogReference(DEFAULT);pmdg(6,1,6,0);pmdg(5,1,5,0);pmdg(A2,1,A2,1);delay(10);pmdg(6,1,6,1);pmdg(5,1,5,0);
while(analogRead(A1)>4000){g=analogRead(A0);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A0)>0){}
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  serial_mos();
}

if(mosfet==8){mos="SDG";mos1="P-E-MOS";mosf=1;
cl();analogReference(INTERNAL4V096);pmdg(5,1,5,1);pmdg(A0,1,A0,0);delay(10);uf=float(analogRead(A1))/1000.0;
cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);pmdg(5,1,5,0);pmdg(3,1,3,0);delay(10);
u_d = up-up/4096*analogRead(A1);r = ((u_d*680.0/(up-u_d))-9.6)/90;
cl();analogReference(DEFAULT);pmdg(2,1,2,0);pmdg(5,1,5,0);pmdg(A0,1,A0,1);delay(10);pmdg(2,1,2,1);pmdg(5,1,5,0);
while(analogRead(A1)>4000){g=analogRead(A2);}vtt = up/4096*g;
cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,0);while(analogRead(A2)>0){}
  pmdg(3,1,3,1);delay(100);pinMode(3,INPUT);pmdg(2,1,2,0);
  time0=micros();while(analogRead(A2)>50){time1=micros()-time0;}time2=time1/1.7-c0;
  serial_mos();
}

/*
 bip_arr(14,0, 5,1, 15, 14,0 ,4,1, 3,1, 15,16);

//2 ecb
 bip_arr(14,0, 3,1, 16, 14,0 ,5,1, 2,1, 15,16);

//3 bce
 bip_arr(16,0, 7,1, 14, 6,1 ,5,1, 16,0, 15,14);
*/
 
  /////////////////////////// tranz bip n-p-n /////////////////////////////////////////////////
//1 ebc
 bip_arr(0, 14,0, 5,1, 15, 14,0 ,4,1, 3,1, 16,15);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1;ebc="EBC";serial_bip();}
//2 ecb
 bip_arr(0, 14,0, 3,1, 16, 14,0 ,5,1, 2,1, 15,16);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1;ebc="ECB";serial_bip();}
//3 bce
 bip_arr(0, 16,0, 7,1, 14, 6,1 ,5,1, 16,0, 15,14);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1;ebc="BCE";serial_bip();}
//4 bec
 bip_arr(0, 15,0, 7,1, 14, 6,1 ,15,0, 3,1, 16,14);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1;ebc="BEC";serial_bip();}
//5 cbe
 bip_arr(0, 16,0, 5,1, 15, 7,1 ,4,1, 16,0, 14,15);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1;ebc="CBE";serial_bip();}
//6 ceb
 bip_arr(0, 15,0, 3,1, 16, 7,1 ,15,0, 2,1, 14,16);arr_0();
if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=1; ebc="CEB"; serial_bip();}
/////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////// tranz bip p-n-p /////////////////////////////////////////////////
//1 ebc
 bip_arr(1, 7,1, 15,0, 14, 14,1 ,4,0, 3,0, 16,15);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="EBC";serial_bip();}
//2 ecb
 bip_arr(1, 5,1, 16,0, 15, 14,1 ,5,0, 2,0, 15,16);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="ECB";serial_bip();}
//3 bce
 bip_arr(1, 14,0, 3,1, 16, 6,0 ,5,0, 16,1, 15,14);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="BCE";serial_bip();}
//4 bec
 bip_arr(1, 14,0, 5,1, 15, 6,0 ,15,1, 3,0, 16,14);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="BEC";serial_bip();}
//5 cbe
 bip_arr(1, 15,0, 3,1, 16, 7,0 ,4,0, 16,1, 14,15);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="CBE";serial_bip();}
//6 ceb
 bip_arr(1, 7,1, 16,0, 14, 7,0 ,15,1, 2,0, 14,16);arr_0();
 if(hhf>0&&uc>2&&ub<3&&uf<1.0&&uf>0.0&&uc<up*0.95){vt=1;pnp=0;ebc="CEB";serial_bip();}
///////////////////////////////////////////////////////////////////////////////////////////////////

if(vt==0 && mosf==0){
  
//// diod ////////////////////////////////////////////////////////////////////////////////////////  
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);u = analogRead(A0);
  if(u<4000){d1 = 1;uf=up*u/4096.0;}else{d1 =0;}
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,0);pmdg(3,1,3,1);delay(10);u = analogRead(A2);
  if(u<4000){d2 = 1;uf=up*u/4096.0;}else{d2 =0;}
  if(d1!=d2){
  if(d1==1){
  cl();analogReference(INTERNAL4V096);pmdg(A0,1,A0,0);pmdg(3,1,3,0);delay(200);
  pmdg(3,1,3,1);delay(100);pinMode(3,INPUT);pmdg(2,1,2,0);
  time0=micros();while(analogRead(A2)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;}
  if(d2==1){
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);delay(200);
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;}
  }
  if(d1!=d2){
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"DIOD");
  u8g.drawLine(0, 13, 128, 13);
  if(d1>d2){u8g.drawStr(0,30,"A-C");}else{u8g.drawStr(0,30,"C-A");}
    u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,45,"Vf= ");u8g.setPrintPos(30,45);u8g.print(uf,3);u8g.drawStr(68,45,"V");
  u8g.drawStr(0,57,"C = ");u8g.setPrintPos(30,57);u8g.print(time1);u8g.drawStr(68,57,"pF");
    } while( u8g.nextPage() );}
  
  
////////////////////////////////////////////////////////////////////////////////////////////////// 

/// r? c? /////
  cl();analogReference(DEFAULT);pmdg(3,1,3,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
  Serial.println(ur,3);
  if(ur>up*0.85){rez=1;}else{rez=0;}
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A2)>0){}
  pmdg(7,1,7,1);delay(100);pmdg(7,1,7,0);
  delay(10);
  int u1 =analogRead(A0);
  delay(200);
  int u2 =analogRead(A0);
 // Serial.println(u1);
 // Serial.println(u2);
  if(u1!=u2){rez=0;}

//// rezistor //////////////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==1){
  cl();analogReference(DEFAULT);pmdg(A0,1,A0,1);delay(10);
  upd=up*analogRead(A0)/4096.0;
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(6,1,6,1);delay(100);
  ur=up*analogRead(A0)/4096.0;
  r = ur*510000.0/(upd-ur);
  if(r>=6800){r2=1;r_iz=r;}else{r2=0;}
  cl();analogReference(DEFAULT);pmdg(A2,1,A2,0);pmdg(7,1,7,1);delay(10);
  ur=up*analogRead(A0)/4096.0;
  r = ur*680.0/(upd-ur);
  if(r<6800){r1=1;r_iz=r;}else{r1=0;}

  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"RESISTOR");
  u8g.drawLine(0, 13, 128, 13);u8g.setFont(u8g_font_profont15r);
  
  if(r1==1&&r2==0){Serial.print("R=");Serial.print(r_iz+R0,1);Serial.println(" Om");
  u8g.drawStr(0,30,"R= ");u8g.setPrintPos(30,30);u8g.print(r_iz+R0,1);u8g.drawStr(80,30," Om");}
  
  if(r2==1&&r1==0&&r_iz<=5000000){Serial.print("R=");Serial.print(r_iz/1000.00,1);Serial.println(" kOm");
  u8g.drawStr(0,30,"R= ");u8g.setPrintPos(30,30);u8g.print(r_iz/1000.00,1);u8g.drawStr(80,30," kOm");}

    } while( u8g.nextPage() );
 }
//////////////////////////////////////////////////////////////////////////////////////////////////


//// condensator + esr /////////////////////////////////////////////////////////////////////////// 
 if(d1==d2 && rez==0){
  /// c > 0.5 uF
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);while(analogRead(A0)>0){}
  cl();analogReference(INTERNAL4V096);pmdg(3,1,3,0);pmdg(A0,1,A0,0);while(analogRead(A2)>0){}
  
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,1);pmdg(7,1,7,1);while(analogRead(A2)<3000){}pmdg(7,1,7,0);
  time0=micros();
  while(analogRead(A0)>600){time1=(micros()-time0)/1.46;}
  if(time1<500){mk=0;}else{mk=1;}
  if(mk==0){
  //// c < 0.5 uf
  cl();analogReference(INTERNAL4V096);pmdg(A2,1,A2,0);pmdg(7,1,7,0);while(analogRead(A0)>0){}
  pmdg(7,1,7,1);delay(100);pinMode(7,INPUT);pmdg(6,1,6,0);
  time0=micros();while(analogRead(A0)>50){time1=micros()-time0;}
  time1=time1/1.7-c0;}
  if(mk==0){Serial.print("C=");Serial.print(time1/1000.00,3);Serial.println(" nF");}
  if(mk==1){Serial.print("C=");Serial.print(time1/1000.00,1);Serial.println(" uF");}
// esr
//A0 A1 A2
//D7 D5 D3 680
//D6 D4 D2 470K
  long a=0,b=0,c=0,d=0;
  long uzh,uzl;
  cl();analogReference(INTERNAL4V096);pmdg(7,1,7,0);pmdg(A2,1,A2,0);while(analogRead(A0)>0){}
  cl();analogReference(INTERNAL4V096);pmdg(3,1,3,0);pmdg(A0,1,A0,0);while(analogRead(A2)>0){}
    cl();
  for(int i=0;i<1000;i++){
    pmdg(7,1,7,1);pmdg(A2,1,A2,0);delayMicroseconds(5);//a=a+analogRead(A0);
  cl();  pinMode(7,INPUT);pinMode(A2,INPUT);b=b+analogRead(A0);
    pmdg(3,1,3,1);pmdg(A0,1,A0,0);delayMicroseconds(5);//c=c+analogRead(A2);
  cl();  pinMode(3,INPUT);pinMode(A0,INPUT);d=d+analogRead(A2);}
  float esr_iz = abs(b-d)/100000.00;
  Serial.print("ESR=");Serial.print(esr_iz);Serial.println(" Om");
  u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"CAPACITOR");
  u8g.drawLine(0, 13, 128, 13);u8g.setFont(u8g_font_profont15r);
  u8g.drawStr(0,30,"C= ");u8g.setPrintPos(30,30);
  if(mk==0){u8g.print(time1/1000.0,3);u8g.drawStr(80,30," nF");}
  if(mk==1){u8g.print(time1/1000.0,2);u8g.drawStr(80,30," uF");
  u8g.drawStr(0,45,"ESR= ");u8g.setPrintPos(35,45);u8g.print(esr_iz);u8g.drawStr(70,45," Om");}
    } while( u8g.nextPage() );
    time1=0;mk=0;
 }
////////////////////////////////////////////////////////////////////////////////////////////////// 


Serial.println();

}//end vt=0
Serial.println();

//delay(1000);
 vt=0;mosf=0;
// u8g.firstPage();  do { } while( u8g.nextPage() );
}//D9
}

void arr_0(){ib=(up-ub)/470.0;ic=(up-uc)/0.680;hhf = ic/ib;}

void serial_mos(){
/*Serial.println(mos1);
Serial.println(mos);
Serial.print(" Vf=");Serial.print(uf,3);Serial.println(" V");
Serial.print(" Vt=");Serial.print(vtt,3);Serial.println(" V");
Serial.print(" Cg=");Serial.print(time2);Serial.println(" pF");
Serial.print(" Usd=");Serial.print(u_d,3);Serial.println(" V");*/
u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,mos1);
u8g.drawLine(0, 13, 128, 13);
u8g.setFont(u8g_font_profont12r);
u8g.drawStr(0,26,"Vf = ");u8g.setPrintPos(30, 26);u8g.print(uf,3);u8g.drawStr(62,26,"V");
u8g.drawStr(0,38,"Vt = ");u8g.setPrintPos(30, 38);u8g.print(vtt,3);u8g.drawStr(62,38,"V");
u8g.drawStr(0,50,"Cg = ");u8g.setPrintPos(30, 50);u8g.print(time2,1);u8g.drawStr(62,50,"pF");
u8g.drawStr(0,62,"Rds= ");u8g.setPrintPos(30, 62);u8g.print(r,3);u8g.drawStr(62,62,"Om");
u8g.setFont(u8g_font_profont17r);u8g.drawStr(90,64,mos);
} while( u8g.nextPage() );  
  }
void serial_bip(){/*
Serial.print("Vf=");Serial.print(uf,3);Serial.println(" V");  
Serial.print("ub=");Serial.print(ub,3);Serial.println(" V");
Serial.print("uc=");Serial.print(uc,3);Serial.println(" V");
Serial.print("ib=");Serial.print(ib,6);Serial.println(" mA");
Serial.print("ic=");Serial.print(ic,3);Serial.println(" mA");
Serial.print("hfe=");Serial.println(hhf,0);
if(pnp==0){Serial.println("P-N-P");}else{Serial.println("N-P-N");}
Serial.println(ebc);*/
u8g.firstPage(); do {u8g.setFont(u8g_font_profont17r);u8g.drawStr(0,11,"BJT");
if(pnp==0){u8g.drawStr(55,9,"p-n-p");}else{u8g.drawStr(55,9,"n-p-n");}
u8g.drawLine(0, 13, 128, 13);
u8g.setFont(u8g_font_profont12r);
u8g.drawStr(0,24,"Vf = ");u8g.setPrintPos(30, 24);u8g.print(uf,3);u8g.drawStr(62,24,"V");
u8g.drawStr(0,34,"Ub = ");u8g.setPrintPos(30, 34);u8g.print(ub,3);u8g.drawStr(62,34,"V");
u8g.drawStr(0,44,"Uc = ");u8g.setPrintPos(30, 44);u8g.print(uc,3);u8g.drawStr(62,44,"V");
u8g.drawStr(0,54,"Ib = ");u8g.setPrintPos(30, 54);u8g.print(ib*1000,2);u8g.drawStr(62,54,"uA");
u8g.drawStr(0,64,"Ic = ");u8g.setPrintPos(30, 64);u8g.print(ic,3);u8g.drawStr(62,64,"mA");
u8g.setFont(u8g_font_profont17r);u8g.drawStr(90,30,"HFE");u8g.setPrintPos(90, 45);u8g.print(hhf,0);
u8g.drawStr(90,64,ebc);
} while( u8g.nextPage() );
  }

void pmdg(int pinmode, bool xp, int digwrite, bool xd){pinMode(pinmode,xp);digitalWrite(digwrite,xd);} 
void cl(){
  pinMode(2,INPUT);pinMode(3,INPUT);pinMode(4,INPUT);pinMode(5,INPUT);
  pinMode(6,INPUT);pinMode(7,INPUT);pinMode(A0,INPUT);pinMode(A1,INPUT);pinMode(A2,INPUT);
  }  
 

void bip_arr(bool tip, byte p1,bool ps1, byte p2,bool ps2, byte an1, byte p3,bool ps3,byte p4,bool ps4, byte p5,bool ps5,byte an2,byte an3){
cl();analogReference(INTERNAL4V096);pmdg(p1,1,p1,ps1);pmdg(p2,1,p2,ps2);delay(10);uf=float(analogRead(an1))/1000.0;
cl();analogReference(DEFAULT);pmdg(p3,1,p3,ps3);pmdg(p4,1,p4,ps4);pmdg(p5,1,p5,ps5);delay(10);
 if(tip==0){uc = up/4096*analogRead(an2);ub = up/4096*analogRead(an3);}
 if(tip==1){uc = up-up/4096*analogRead(an2);ub = up-up/4096*analogRead(an3);}
 }

void mos_1(byte p1,bool ps1, byte p2,bool ps2, byte a1, byte p3,bool ps3, byte p4,bool ps4, byte p5,byte ps5, byte a2){
  cl();analogReference(INTERNAL4V096);pmdg(p1,1,p1,ps1);pmdg(p2,1,p2,ps2);delay(10);uf=float(analogRead(a1))/1000.0;
  if(uf>1.0){mosfet=0;mosf=0;}
  cl();analogReference(INTERNAL1V024);pmdg(p3,1,p3,ps3);pmdg(p4,1,p4,ps4);pmdg(p5,1,p5,ps5);delay(10);
  u_d = 1.024/4096*analogRead(a2);r = ((u_d*680.0/(up-u_d))-9.6)/90;
  } 

5

Re: tester

http://forum.rcl-radio.ru/uploads/images/2023/11/ced9ad7e29c53f726d149dcf86d0c404.png

6

Re: tester

Прикольно и симпатично.
Это что-то типа Транзистор тестера?
Можно озвучить ТТХ Вашего прибора?

7

Re: tester

Этот прибор всего лишь попытка создать аналог тестера радиоэлементов, над ним еще много работы, возможно он ни когда не будет завершен. В нынешнем виде он измеряет сопротивление, емкость, измеряет параметры биполярных и мосфет транзисторов, диоды.