-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.c
2075 lines (1673 loc) · 53.7 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ************************************************************************
*
* main part
*
* (c) 2012-2019 by Markus Reschke
* based on code from Markus Frejek and Karl-Heinz Kübbeler
*
* ************************************************************************ */
/*
* local constants
*/
/* source management */
#define MAIN_C
/*
* include header files
*/
/* local includes */
#include "config.h" /* global configuration */
#include "common.h" /* common header file */
#include "variables.h" /* global variables */
#include "functions.h" /* external functions */
#include "colors.h" /* color definitions */
/*
* local variables
*/
/* program control */
uint8_t MissedParts; /* counter for failed/missed components */
/* ************************************************************************
* output components and errors
* ************************************************************************ */
/*
* show pinout for semiconductors
*
* required:
* - character for pin A
* - character for pin B
* - character for pin C
*/
void Show_SemiPinout(uint8_t A, uint8_t B, uint8_t C)
{
uint8_t n; /* counter */
uint8_t Char; /* character */
#ifdef SW_PROBE_COLORS
uint16_t Color; /* color value */
Color = UI.PenColor; /* save current color */
#endif
/* display: 123 */
for (n = 0; n <= 2; n++)
{
Display_ProbeNumber(n);
}
/* display: = */
Display_Char('=');
/* display pin IDs */
for (n = 0; n <= 2; n++) /* loop through probe pins */
{
#ifdef SW_PROBE_COLORS
UI.PenColor = ProbeColors[n]; /* set probe color */
#endif
if (n == Semi.A) Char = A; /* probe A - ID A */
else if (n == Semi.B) Char = B; /* probe B - ID B */
else Char = C; /* - ID C */
Display_Char(Char); /* display ID */
}
#ifdef SW_PROBE_COLORS
UI.PenColor = Color; /* restore old color */
#endif
}
/*
* show simple pinout
*
* required:
* - ID: characters for probes 1, 2 and 3
* 0 -> not displayed
*/
void Show_SimplePinout(uint8_t ID_1, uint8_t ID_2, uint8_t ID_3)
{
uint8_t n; /* counter */
unsigned char ID[3]; /* component pin IDs */
#ifdef SW_PROBE_COLORS
uint16_t Color; /* color value */
Color = UI.PenColor; /* save current color */
#endif
/* copy probe pin characters/IDs */
ID[0] = ID_1;
ID[1] = ID_2;
ID[2] = ID_3;
for (n = 0; n <= 2; n++) /* loop through probe pins */
{
if (ID[n] != 0) /* display this one */
{
Display_ProbeNumber(n);
Display_Char(':');
#ifdef SW_PROBE_COLORS
UI.PenColor = ProbeColors[n]; /* set probe color */
#endif
Display_Char(ID[n]);
#ifdef SW_PROBE_COLORS
UI.PenColor = Color; /* restore old color */
#endif
Display_Space();
}
}
}
/*
* show failed test
*/
void Show_Fail(void)
{
/* display info */
Display_EEString(Failed1_str); /* display: No component */
Display_NL_EEString(Failed2_str); /* display: found! */
MissedParts++; /* increase counter */
}
/*
* show error
*/
void Show_Error()
{
if (Check.Type == TYPE_DISCHARGE) /* discharge failed */
{
Display_EEString(DischargeFailed_str); /* display: Battery? */
/* display probe number and remaining voltage */
Display_NextLine();
Display_ProbeNumber(Check.Probe);
Display_Char(':');
Display_Space();
Display_Value(Check.U, -3, 'V');
}
else if (Check.Type == TYPE_DETECTION) /* detection error */
{
/* simply display: No component found! */
Show_Fail();
}
}
/*
* show single (first) resistor
*
* requires:
* - ID1: pin ID #1 character
* - ID2: pin ID #2 character
*/
void Show_SingleResistor(uint8_t ID1, uint8_t ID2)
{
Resistor_Type *Resistor; /* pointer to resistor */
Resistor = &Resistors[0]; /* pointer to first resistor */
/* show pinout */
Display_Char(ID1);
Display_EEString(Resistor_str);
Display_Char(ID2);
/* show resistance value */
Display_Space();
Display_Value(Resistor->Value, Resistor->Scale, LCD_CHAR_OMEGA);
}
/*
* show resistor(s)
*/
void Show_Resistor(void)
{
Resistor_Type *R1; /* pointer to resistor #1 */
Resistor_Type *R2; /* pointer to resistor #2 */
uint8_t Pin; /* ID of common pin */
R1 = &Resistors[0]; /* pointer to first resistor */
if (Check.Resistors == 1) /* single resistor */
{
R2 = NULL; /* disable second resistor */
Pin = R1->A; /* make B the first pin */
}
else /* multiple resistors */
{
R2 = R1;
R2++; /* pointer to second resistor */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Quantity = 2; /* got two */
#endif
if (Check.Resistors == 3) /* three resistors */
{
Resistor_Type *Rmax; /* pointer to largest resistor */
/*
* 3 resistors mean 2 single resistors and both resistors in series.
* So we have to single out that series resistor by finding the
* largest resistor.
*/
Rmax = R1; /* starting point */
for (Pin = 1; Pin <= 2; Pin++)
{
if (CmpValue(R2->Value, R2->Scale, Rmax->Value, Rmax->Scale) == 1)
{
Rmax = R2; /* update largest one */
}
R2++; /* next one */
}
/* get the two smaller resistors */
if (R1 == Rmax) R1++;
R2 = R1;
R2++;
if (R2 == Rmax) R2++;
}
/* find common pin of both resistors */
if ((R1->A == R2->A) || (R1->A == R2->B))
{
Pin = R1->A; /* pin A */
}
else
{
Pin = R1->B; /* pin B */
}
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Comp1 = (void *)R1; /* first resistor */
Info.Comp2 = (void *)R2; /* second resistor */
#endif
/*
* display the pins
*/
/* first resistor */
if (R1->A != Pin) /* A is not common pin */
{
Display_ProbeNumber(R1->A); /* display pin A */
}
else /* single resistor or A is common pin */
{
Display_ProbeNumber(R1->B); /* display pin B */
}
Display_EEString(Resistor_str);
Display_ProbeNumber(Pin); /* display common pin */
if (R2) /* second resistor */
{
Display_EEString(Resistor_str);
if (R2->A != Pin) /* A is not common pin */
{
Display_ProbeNumber(R2->A); /* display pin A */
}
else /* A is common pin */
{
Display_ProbeNumber(R2->B); /* display pin B */
}
}
/*
* display the values
*/
/* first resistor */
Display_NextLine();
Display_Value(R1->Value, R1->Scale, LCD_CHAR_OMEGA);
if (R2) /* second resistor */
{
Display_Space();
Display_Value(R2->Value, R2->Scale, LCD_CHAR_OMEGA);
}
#ifdef SW_INDUCTOR
else /* single resistor */
{
/* get inductance and display if relevant */
if (MeasureInductor(R1) == 1)
{
Display_Space();
Display_Value(Inductor.Value, Inductor.Scale, 'H');
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_R_L; /* inductance measured */
#endif
}
}
#endif
}
/*
* show capacitor
*/
void Show_Capacitor(void)
{
Capacitor_Type *MaxCap; /* pointer to largest cap */
Capacitor_Type *Cap; /* pointer to cap */
#if defined (SW_ESR) || defined (SW_OLD_ESR)
uint16_t ESR; /* ESR (in 0.01 Ohms) */
#endif
uint8_t Counter; /* loop counter */
/* find largest cap */
MaxCap = &Caps[0]; /* pointer to first cap */
Cap = MaxCap;
for (Counter = 1; Counter <= 2; Counter++)
{
Cap++; /* next cap */
if (CmpValue(Cap->Value, Cap->Scale, MaxCap->Value, MaxCap->Scale) == 1)
{
MaxCap = Cap;
}
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Comp1 = (void *)MaxCap; /* largest cap */
#endif
/* display pinout */
Display_ProbeNumber(MaxCap->A); /* display pin #1 */
Display_EEString(Cap_str); /* display capacitor symbol */
Display_ProbeNumber(MaxCap->B); /* display pin #2 */
/* show capacitance */
Display_NextLine(); /* move to next line */
Display_Value(MaxCap->Value, MaxCap->Scale, 'F');
#if defined (SW_ESR) || defined (SW_OLD_ESR)
/* show ESR */
ESR = MeasureESR(MaxCap); /* measure ESR */
if (ESR < UINT16_MAX) /* if successfull */
{
Display_Space();
Display_Value(ESR, -2, LCD_CHAR_OMEGA); /* display ESR */
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Val1 = ESR; /* copy ESR */
#endif
#endif
/* show discharge leakage current */
if (MaxCap->I_leak > 0)
{
Display_NL_EEString_Space(I_leak_str);
Display_Value(MaxCap->I_leak, -8, 'A'); /* in 10nA */
}
}
/*
* show current (leakage or whatever) of semiconductor
*/
void Show_SemiCurrent(const unsigned char *String)
{
if (CmpValue(Semi.I_value, Semi.I_scale, 50, -9) >= 0) /* show if >=50nA */
{
Display_NL_EEString_Space(String); /* display: <string> */
Display_Value(Semi.I_value, Semi.I_scale, 'A'); /* display current */
}
}
#ifndef UI_SERIAL_COMMANDS
/*
* display capacitance of a diode
*
* requires:
* - pointer to diode structure
*/
void Show_Diode_Cap(Diode_Type *Diode)
{
/* get capacitance (reversed direction) */
MeasureCap(Diode->C, Diode->A, 0);
/* and show capacitance */
Display_Value(Caps[0].Value, Caps[0].Scale, 'F');
}
#endif
/*
* show diode
*/
void Show_Diode(void)
{
Diode_Type *D1; /* pointer to diode #1 */
Diode_Type *D2 = NULL; /* pointer to diode #2 */
uint8_t CapFlag = 1; /* flag for capacitance output */
uint8_t A = 5; /* ID of common anode */
uint8_t C = 5; /* ID of common cothode */
uint8_t R_Pin1 = 5; /* B_E resistor's pin #1 */
uint8_t R_Pin2 = 5; /* B_E resistor's pin #2 */
uint8_t n; /* counter */
uint8_t m; /* counter */
D1 = &Diodes[0]; /* pointer to first diode */
/*
* figure out which diodes to display
*/
if (Check.Diodes == 1) /* single diode */
{
C = D1->C; /* make cathode first pin */
}
else if (Check.Diodes == 2) /* two diodes */
{
D2 = D1;
D2++; /* pointer to second diode */
if (D1->A == D2->A) /* common anode */
{
A = D1->A; /* save common anode */
/* possible PNP BJT with low value B-E resistor and flyback diode */
R_Pin1 = D1->C;
R_Pin2 = D2->C;
}
else if (D1->C == D2->C) /* common cathode */
{
C = D1->C; /* save common cathode */
/* possible NPN BJT with low value B-E resistor and flyback diode */
R_Pin1 = D1->A;
R_Pin2 = D2->A;
}
else if ((D1->A == D2->C) && (D1->C == D2->A)) /* anti-parallel */
{
A = D1->A; /* anode and cathode */
C = A; /* are the same */
CapFlag = 0; /* skip capacitance */
}
}
else if (Check.Diodes == 3) /* three diodes */
{
/*
* Two diodes in series are detected as a virtual third diode:
* - Check for any possible way the 2 diodes could be connected in series.
* - Only once the cathode of diode #1 matches the anode of diode #2.
*/
for (n = 0; n <= 2; n++) /* loop for first diode */
{
D1 = &Diodes[n]; /* get pointer of first diode */
for (m = 0; m <= 2; m++) /* loop for second diode */
{
D2 = &Diodes[m]; /* get pointer of second diode */
if (n != m) /* don't check same diode :-) */
{
if (D1->C == D2->A) /* got match */
{
n = 5; /* end loops */
m = 5;
}
}
}
}
if (n < 5) D2 = NULL; /* no match found */
C = D1->C; /* cathode of first diode */
A = 3; /* in series mode */
}
else /* too much diodes */
{
Display_EEString(Diode_AC_str); /* display: -|>|- */
Display_Space(); /* display space */
Display_Char(Check.Diodes + '0'); /* display number of diodes found */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Quantity = Check.Diodes; /* set quantity */
#endif
return;
}
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Comp1 = (void *)D1; /* first diode */
Info.Comp2 = (void *)D2; /* second diode */
#endif
/*
* display pins
*/
/* first diode */
if (A < 3) /* common anode: show C first */
{
Display_ProbeNumber(D1->C); /* show C */
Display_EEString(Diode_CA_str); /* show -|<- */
Display_ProbeNumber(A); /* show A */
}
else /* common cathode: show A first */
{
Display_ProbeNumber(D1->A); /* show A */
Display_EEString(Diode_AC_str); /* show ->|- */
Display_ProbeNumber(C); /* show C */
}
if (D2) /* second diode */
{
if (A <= 3) /* common anode or in-series */
{
Display_EEString(Diode_AC_str); /* show ->|- */
}
else /* common cathode */
{
Display_EEString(Diode_CA_str); /* show -|<- */
}
if (A == C) /* anti parallel */
{
n = D2->A; /* get anode */
}
else if (A <= 3) /* common anode or in-series */
{
n = D2->C; /* get cathode */
}
else /* common cathode */
{
n = D2->A; /* get anode */
}
Display_ProbeNumber(n); /* display pin */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Quantity = 2; /* got two */
#endif
}
/* check for B-E resistor of possible BJT */
if (R_Pin1 < 5) /* possible BJT */
{
/* B-E resistor below 25kOhms */
if (CheckSingleResistor(R_Pin1, R_Pin2, 25) == 1)
{
/* show: PNP/NPN? */
Display_Space();
if (A < 3) /* PNP */
{
Display_EEString(PNP_str);
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_D_R_BE | INFO_D_BJT_PNP; /* R_BE & PNP */
#endif
}
else /* NPN */
{
Display_EEString(NPN_str);
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_D_R_BE | INFO_D_BJT_NPN; /* R_BE & NPN */
#endif
}
Display_Char('?');
Display_NextLine(); /* move to line #2 */
R_Pin1 += '1'; /* convert pin ID to character */
R_Pin2 += '1';
Show_SingleResistor(R_Pin1, R_Pin2); /* show resistor */
CapFlag = 0; /* skip capacitance */
}
}
/*
* display:
* - Uf (forward voltage)
* - reverse leakage current (for single diodes)
* - capacitance (not for anti-parallel diodes)
*/
/* display Uf */
Display_NL_EEString_Space(Vf_str); /* display: Vf */
/* first diode */
Display_Value(D1->V_f, -3, 'V'); /* in mV */
Display_Space();
/* display low current Uf and reverse leakage current for a single diode */
if (D2 == NULL) /* single diode */
{
/* display low current Uf if it's quite low (Ge/Schottky diode) */
if (D1->V_f2 < 250) /* < 250mV */
{
Display_Char('(');
Display_Value(D1->V_f2, 0, 0); /* no unit */
Display_Char(')');
}
/* reverse leakage current */
UpdateProbes(D1->C, D1->A, 0); /* reverse diode */
GetLeakageCurrent(1); /* get current */
Show_SemiCurrent(I_R_str); /* display I_R */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_D_I_R; /* measured I_R */
#endif
}
else /* two diodes */
{
/* show Uf of second diode */
Display_Value(D2->V_f, -3, 'V');
}
/* display capacitance */
if (CapFlag == 1) /* if feasable */
{
Display_NL_EEString_Space(DiodeCap_str); /* display: C */
#ifndef UI_SERIAL_COMMANDS
/* first diode */
Show_Diode_Cap(D1); /* measure & show capacitance */
if (D2) /* second diode */
{
Display_Space();
Show_Diode_Cap(D2); /* measure & show capacitance */
}
#endif
#ifdef UI_SERIAL_COMMANDS
/* first diode */
MeasureCap(D1->C, D1->A, 0); /* get capacitance (reversed direction) */
Display_Value(Caps[0].Value, Caps[0].Scale, 'F');
if (D2) /* second diode */
{
Display_Space();
MeasureCap(D2->C, D2->A, 1); /* get capacitance (reversed direction) */
Display_Value(Caps[1].Value, Caps[1].Scale, 'F');
}
#endif
}
}
/*
* show BJT
*/
void Show_BJT(void)
{
Diode_Type *Diode; /* pointer to diode */
unsigned char *String; /* string pointer (EEPROM) */
uint8_t Char; /* character */
uint8_t BE_A; /* V_BE: pin acting as anode */
uint8_t BE_C; /* V_BE: pin acting as cathode */
uint8_t CE_A; /* flyback diode: pin acting as anode */
uint8_t CE_C; /* flyback diode: pin acting as cathode */
uint16_t V_BE; /* V_BE */
int16_t Slope; /* slope of forward voltage */
/*
* Mapping for Semi structure:
* A - Base pin
* B - Collector pin
* C - Emitter pin
* U_1 - U_BE (mV) (not yet)
* F_1 - hFE
* I_value/I_scale - I_CEO
*/
/* preset stuff based on BJT type */
if (Check.Type & TYPE_NPN) /* NPN */
{
String = (unsigned char *)NPN_str; /* "NPN" */
/* direction of B-E diode: B -> E */
BE_A = Semi.A; /* anode at base */
BE_C = Semi.C; /* cathode at emitter */
/* direction of optional flyback diode */
CE_A = Semi.C; /* anode at emitter */
CE_C = Semi.B; /* cathode at collector */
Char = LCD_CHAR_DIODE_CA; /* |<| */
}
else /* PNP */
{
String = (unsigned char *)PNP_str; /* "PNP" */
/* direction of B-E diode: E -> B */
BE_A = Semi.C; /* anode at emitter */
BE_C = Semi.A; /* cathode at base */
/* direction of optional flyback diode */
CE_A = Semi.B; /* anode at collector */
CE_C = Semi.C; /* cathode at emitter */
Char = LCD_CHAR_DIODE_AC; /* |>| */
}
/* display type */
Display_EEString_Space(BJT_str); /* display: BJT */
Display_EEString(String); /* display: NPN / PNP */
/* parasitic BJT (freewheeling diode on same substrate) */
if (Check.Type & TYPE_PARASITIC)
{
Display_Char('+');
}
Display_NextLine(); /* next line (#2) */
/* display pinout */
Show_SemiPinout('B', 'C', 'E');
/* optional freewheeling diode */
Diode = SearchDiode(CE_A, CE_C); /* search for matching diode */
if (Diode != NULL) /* got it */
{
Display_Space(); /* display space */
Display_Char('C'); /* collector */
Display_Char(Char); /* display diode symbol */
Display_Char('E'); /* emitter */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_BJT_D_FB; /* found flyback diode */
Info.Comp1 = Diode; /* copy diode */
#endif
}
/*
* display either optional B-E resistor or h_FE & V_BE
*/
/* check for B-E resistor below 25kOhms */
if (CheckSingleResistor(BE_C, BE_A, 25) == 1) /* found B-E resistor */
{
Display_NextLine(); /* next line (#3) */
Show_SingleResistor('B', 'E');
/* B-E resistor renders hFE and V_BE measurements useless */
#ifdef SW_SYMBOLS
UI.SymbolLine = 4; /* display fancy pinout in line #4 */
#endif
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_BJT_R_BE; /* R_BE */
#endif
}
else /* no B-E resistor found */
{
/* h_FE and V_BE */
/* display h_FE */
Display_NL_EEString_Space(h_FE_str); /* display: hFE */
Display_Value(Semi.F_1, 0, 0); /* display h_FE */
/* display reverse hFE */
#ifdef SW_REVERSE_HFE
if (Diode == NULL) /* no freewheeling diode */
{
if (Semi.F_2 > 0) /* valid value */
{
Display_NL_EEString_Space(h_FE_r_str); /* display: hFEr */
Display_Value(Semi.F_2, 0, 0); /* display reverse h_FE */
}
}
#endif
/* display V_BE (taken from diode's forward voltage) */
Diode = SearchDiode(BE_A, BE_C); /* search for matching B-E diode */
if (Diode != NULL) /* got it */
{
Display_NL_EEString_Space(V_BE_str); /* display: Vbe */
/*
* V_f is quite linear for a logarithmicly scaled I_b.
* So we may interpolate the V_f values of low and high test current
* measurements for a virtual test current. Low test current is 10µA
* and high test current is 7mA. That's a logarithmic scale of
* 3 decades.
*/
/* calculate slope for one decade */
Slope = Diode->V_f - Diode->V_f2;
Slope /= 3;
/* select V_BE based on hFE */
if (Semi.F_1 < 100) /* low h_FE */
{
/*
* BJTs with low hFE are power transistors and need a large I_b
* to drive the load. So we simply take Vf of the high test current
* measurement (7mA).
*/
V_BE = Diode->V_f;
}
else if (Semi.F_1 < 250) /* mid-range h_FE */
{
/*
* BJTs with a mid-range hFE are signal transistors and need
* a small I_b to drive the load. So we interpolate Vf for
* a virtual test current of about 1mA.
*/
V_BE = Diode->V_f - Slope;
}
else /* high h_FE */
{
/*
* BJTs with a high hFE are small signal transistors and need
* only a very small I_b to drive the load. So we interpolate Vf
* for a virtual test current of about 0.1mA.
*/
V_BE = Diode->V_f2 + Slope;
}
Display_Value(V_BE, -3, 'V'); /* in mV */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Val1 = V_BE; /* copy V_BE */
#endif
}
}
/* I_CEO: collector emitter open current (leakage) */
Show_SemiCurrent(I_CEO_str); /* display I_CEO */
}
/*
* show MOSFET/IGBT extras
* - diode
* - V_th
* - Cgs
*/
void Show_FET_Extras(void)
{
Diode_Type *Diode; /* pointer to diode */
uint8_t Anode; /* anode of diode */
uint8_t Cathode; /* cathode of diode */
uint8_t Char_1; /* pin name */
uint8_t Char_2; /* pin name */
uint8_t Symbol; /* diode symbol */
/*
* Mapping for Semi structure:
* A - Gate pin
* B - Drain pin
* C - Source pin
* U_1 - R_DS_on (0.01 Ohms)
* U_2 - V_th (mV)
*/
/*
* show instrinsic/freewheeling diode
*/
if (Check.Type & TYPE_N_CHANNEL) /* n-channel/NPN */
{
Anode = Semi.C; /* source/emitter */
Cathode = Semi.B; /* drain/collector */
Symbol = LCD_CHAR_DIODE_CA; /* |<| */
}
else /* p-channel/PNP */
{
Anode = Semi.B; /* drain/collector */
Cathode = Semi.C; /* source/emitter */
Symbol = LCD_CHAR_DIODE_AC; /* |>| */
}
if (Check.Found == COMP_FET) /* FET */
{
Char_1 = 'D';
Char_2 = 'S';
}
else /* IGBT */
{
Char_1 = 'C';
Char_2 = 'E';
}
/* search for matching diode */
Diode = SearchDiode(Anode, Cathode);
if (Diode != NULL) /* got it */
{
/* show diode */
Display_Space(); /* space */
Display_Char(Char_1); /* left pin name */
Display_Char(Symbol); /* diode symbol */
Display_Char(Char_2); /* right pin name */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_FET_D_FB; /* found flyback diode */
Info.Comp1 = Diode; /* copy diode */
#endif
}
/* skip remaining stuff for depletion-mode FETs/IGBTs */
if (Check.Type & TYPE_DEPLETION) return;
/* gate threshold voltage V_th */
if (Semi.U_2 != 0)
{
Display_NL_EEString_Space(Vth_str); /* display: Vth */
Display_SignedValue(Semi.U_2, -3, 'V'); /* display V_th in mV */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_FET_V_TH; /* measured Vth */
#endif
}
/* display gate-source capacitance C_GS */
/* todo: display "Cge" for IGBT? */
Display_NL_EEString_Space(Cgs_str); /* display: Cgs */
Display_Value(Semi.C_value, Semi.C_scale, 'F'); /* display value and unit */
#ifdef UI_SERIAL_COMMANDS
/* set data for remote commands */
Info.Flags |= INFO_FET_C_GS; /* measured C_GS */
#endif
/* display R_DS_on, if available */
if (Semi.U_1 > 0)
{
Display_NL_EEString_Space(R_DS_str); /* display: Rds */