Author Topic: WTF!? Atmega328P vs 2N7002F - fails to turn off!  (Read 23379 times)

0 Members and 1 Guest are viewing this topic.

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
WTF!? Atmega328P vs 2N7002F - fails to turn off!
« on: February 29, 2016, 04:13:38 pm »
What the #¤%& am i doing wrong here? A circuit that couldn't be simpler fails to work, and yet it works when done on the breadboard.

This is a dead simple indicator LED / isolator opto driver from Atmega328 GPIO pin to 2N7002F fet. Gate resistor is 10 to 100 ohms and there is a gate pulldown 1 to 10k ( i.e. those are the limits that i have tried). The load is a LED fed from 12V thru a limiter of some 470 ohms or so (varies - there are several circuits that behave like this). The problem is that the fet does not turn off but leaks like crazy. If the load is a LED it stays lit although the brightness goes down so the gate drive does go down as well. But the fet never turns off properly.
I have encountered this in 2 separate projects now. The first one was done using Arduino Due and the 2nd one is a DIY board with the Atmega on board. No matter what combo of gate resistors i try the behavior is the same.
If i force (short) the gate to ground the LED goes dark immediately as it should. I have made the same circuit on breadboard and driven it from a signal generator. That way it is not the least sensitive to parameter variations. A low drive level of over 300 mV still causes the LED to turn off nicely. Scoping the Atmega shows the drive signal to go well below that but still the LED stays on.
After thoroughly isually inspecting the circuit i can guarantee that the connections are right (4 bad circuits in 4 different places for the particular function and nothing else would be a stretch anyway).
What the hell is going on here? What am i missing?


Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #1 on: February 29, 2016, 05:25:07 pm »
Too many words to read, but I suspect the output pin was not defined as an output.  That leaves it floating and gate capacitance holds fet on.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #2 on: February 29, 2016, 05:45:13 pm »
Too many words to read, but I suspect the output pin was not defined as an output.  That leaves it floating and gate capacitance holds fet on.

This was my first guess too.

Kremmen, can you post your complete code?
The easiest person to fool is yourself. -- Richard Feynman
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #3 on: February 29, 2016, 09:09:09 pm »
Too many words to read, but I suspect the output pin was not defined as an output.  That leaves it floating and gate capacitance holds fet on.

This was my first guess too.

Kremmen, can you post your complete code?
I know you mean well, but that ain't it. But in the interest of not being difficult, here it is. Sorry about the language in the comments - you'll have to live with that.
Any better ideas?

Code: [Select]
/*
 * PWRcontroller.cpp
 *
 * Created: 15.2.2016 11:53:03
 * Author : martti
 */

#include <avr/io.h>
#include <avr/interrupt.h>

#define F_CPU 8000000L

uint16_t cmscounter;
volatile uint16_t mscounter; // millisekuntilaskuri (laskee millisekunteja pwm-syklin alusta)
uint16_t tmpsetpoint, csetpoint;
volatile uint16_t setpoint; // asetusarvo (0 - 1000)
uint16_t ADsum;
uint8_t ADindex;
#define  ADINDEXMAX 64 // oltava 2:n potenssi!
uint16_t ADvalue[ADINDEXMAX];
volatile bool cyclestart;
bool pwroutput, indicator;
uint8_t portvalue;


int main(void) {
uint8_t i;

 // Alustetaan GPIO
PORTD = 0; // lähdöt ensin pois päältä
DDRD = 0x03; // 2 alinta bittiä outputteja
 
    // Alustetaan kello, timeri1 ja A/D-muunnin
CLKPR = 1 << CLKPCE; // enable prescaler
CLKPR = 0; // prescaler = 1 (8MHz kello)

TCCR1A = 0; // Compare outputit pois päältä WGM bitit 0 ja 1 = =
TCCR1B = 1<<WGM12 | 1<<CS10; // CTC moodi, prescaler = 1
TIMSK1 = 1 << OCIE1A; // Timer 1 keskeytys vertailurekisteristä A
OCR1A = 0x1f40; // vertailu = 8000  --> 1ms aikakeskeytykset

ADMUX = 0x00;
ADCSRA = 1 << ADEN | 1 << ADIE | 1 << ADPS0; // muunnin päälle, keskeytykset päälle, muuntimen kellojakaja /4

for ( i=0; i<ADINDEXMAX; i++ ) {
ADvalue[i] = 0;
}
ADindex = 0;
ADsum = 0;

sei();
//pwm-looppi
    while (1)
    {
if (cyclestart) {
cli();
cyclestart = false;
sei();
pwroutput = true;
}
cli();
cmscounter = mscounter;
csetpoint = setpoint;
sei();
if ( cmscounter >= csetpoint ) pwroutput = false;
portvalue = (PIND & 0xfc);
portvalue |= pwroutput & 0x01;
portvalue |= ((pwroutput & 0x01 ) | (indicator & 0x01)) << 1;
PORTD = portvalue;
    }
}

// Timer1 Compare A: 1 millisekunnin keskeytys
// kasvatetaan millisekuntilaskuria
//
ISR(TIMER1_COMPA_vect) {
ADCSRA = ADCSRA |  1 << ADSC | 1 << ADIE; // käynnistetään uusi A/D-muunnos
if ( ++mscounter > 1000) {
mscounter = 0;
cyclestart = true;
}
indicator = !indicator;
}

// A/D-muuntimen keskeytys
ISR(ADC_vect) {
ADsum -= ADvalue[ADindex];
ADvalue[ADindex] = ADC;
ADsum += ADvalue[ADindex];
ADindex++;
if ( ADindex >= ADINDEXMAX) ADindex = 0;
tmpsetpoint = ADsum >> 6; // jako 64:llä. Synkattava ADINDEXMAX:in kanssa!

// A/D-muunnos tuottaa lukeman 0 - 1024. Jaksonaika on 1000 ms joten
// setpoint on 24 isompi kuin jakso. Käytetään ero hyväksi tekemällä hieman välystä molempiin päihin
// Lukemat 0-12 tulkitaan nollaksi ja isommista vähennetään 12. Tällöin viimeiset 12 inkrementtiä vastaavat "täyttä kaasua"
// Näin varmistetaan, että potikalla päästään ihan nollasta ihan täysille.

if (tmpsetpoint < 12 ) setpoint = 0;
else setpoint = tmpsetpoint - 12;

}


Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline kfitch42

  • Frequent Contributor
  • **
  • Posts: 300
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #4 on: February 29, 2016, 09:49:46 pm »
Let's break this down: Is the problem inside or outside the atmega328/arduino?

Build up the breadboard/siggen circuit that works (LED goes out): replace siggen with ATmega328, does is still go out? Replace siggen with arduino, does it still go out?

or alternately, take the system that is not working, and replace the atmega/arduino with the siggen.

Could it be something as simple as the gate pulldown is actually a pull up?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #5 on: February 29, 2016, 10:01:26 pm »
Set a breakpoint at code right after you turn off jfet and look at gate drive Vgs with a voltmeter.
Sounds like output of opto isolator is a bipolar threshold above ground and keeping the fet on.
If you can't breakpoint it do a while( 1 ) { }; right after you turn off JFET.

Do you have a schematic snippit from Arduino pin all the way to LED load you can post, along
with opto coupler part number ?

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #6 on: February 29, 2016, 10:07:13 pm »
One other thing, in a design like this the Rgs should be >> than any series Rintogate,
as that forms a V divider and robs you of gate drive when yiou are turning on the fet.
So lean more towards the 10K size to insure you get the fet turned hard on which limits
Pdiss in the jfet and makes the Iled more predictable and set primarily by its Rled and
Vsupply.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #7 on: March 01, 2016, 06:25:20 am »
The switching frequency is so low as to be effectively DC on the timescale of gate oscillations that usually occur at >100 MHz. The indicator LED cycles at 1 Hz with a 1 kHz brightness modulation on top so there is all the time in the world for the gate drive to stabilize to whatever it is aiming at.
I have scoped the circuit using a reasonable scope (Rigol 2202) and no gate oscillations visible. Voltage levels are about what one would expect.


The actual circuit looks like this.  R7 is directly connected to a GPIO pin of an Atmega 328P. There is a similar circuit done with Arduino Due (an Atmel SAM ARM chip) and it behaves exactly the same. When switched off there is a significant and persistent leakage. That case is made simple by the fact that the indicator LEDs are idle at start so there are no switching events at all. The gate voltage is 43.96 mV and still the LED is visibly on.
I can only come to the conclusion that either 2N7002 is unsuitable for this application or that i have a batch of shitty components.
Interestingly, the same ARM drives a bunch of BS170 fets on a satellite board with zero issues.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #8 on: March 01, 2016, 06:27:49 am »
Some of your variables are not defined volatile and should be.

Every variable/array/boolean used in an interrupt should be volatile unless it is only used in the interrupt and nowhere else.

(Except if your using nested interrupts, then make the sucker volatile if it even thinks about going near an interrupt) your not using nested, so that's fine
« Last Edit: March 01, 2016, 06:37:39 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #9 on: March 01, 2016, 06:48:35 am »
While you are formally correct it won't impact the overall working of the code. And it is anyway irrelevant to the problem at hand because variable volatility and GPIO drive levels are unrelated.
Perhaps you didn't have time to read my latest reply before posting. In my last i noted that in some of the cases it is easy to verify that the outputs are stable at low output level and still the LED is visibly on.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #10 on: March 01, 2016, 07:20:43 am »
I do not know what is going on, but you can place a diode (1N4001 or 1N4148)  between the Q3's drain (pin 2) and ground which will make the Gate negative relative to the drain when driven "0" and it should turn the Q3 off. Or, you have the R7 there, so you can replace the Q3 with an NPN and make R7 to 1K.

The MOC3061M is an opto-triac which is suitable only for driving AC-loads as it will stay on when triggered until the load's voltage drops to zero.
« Last Edit: March 01, 2016, 07:23:43 am by Kalvin »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #11 on: March 01, 2016, 07:40:38 am »
Yes the triac opto is used exactly for that purpose and is free to stay on for the rest of the cycle, that is the idea after all. The issue is on the LED side of the opto, not on the hi voltage side.

Good question about the ground. I should have mentioned that it was one of the first things i checked and there is no practical difference in ground potential. Additionally in some of the physival circuits you can see by eyeball that the ground plane extends directly to the common point at the regulator. Anyway, the decisive thing controlling turn on/off is the Vgs as measured between the fet gate and source. I confirmed by measuring directly from the pins of the fet and get 40.03 mV that definitely should not turn the fet on, whatever the load might be...

Thanks all for the suggestions. I don't think i want to rape the circuit by adding any kludge diodes or other hacks to get such a simple thing working. I'll just replace the fet with a known good type.
My original purpose in posting was to find out if this was a known issue with one or the other, or perhaps just this combo. But apparently it is not.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #12 on: March 01, 2016, 07:48:32 am »
You could take the faulty 2N7002 and measure the gate-source and gate-drain resistance (in both polarities, of course) and check whether you still have a MOSFET or something else.  :) I am not sure how easy it is to break the 2N7002 and what it its common breaking mechanism, but during the winter-time static electricity is everywhere.
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #13 on: March 01, 2016, 08:55:17 am »
While that is a good suggestion i have 4 individual fets all showing the same behavior. 2 of those are soldered in an SMD oven using a controlled heating cycle, 2 are hand soldered.
Anything wrong with all 4 of them either indicates an issue with the component itself or some gross violation in the soldering process. Just for your information i have ~40 years experience in soldering so i do know how that is done right. And component overheating is not a problem otherwise so why just these fets?
Of course all of them could still be kaput due to something in the process that they cannot take. But that would only be an indication to change fet type to something that works.

Soldering wires to the fet dead bug style and then playing with it using a signal generator results in exactly the kind of behavior one would expect. But same does not happen when a similar fet is driven by the processor. Hence the WTF...
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #14 on: March 01, 2016, 09:04:22 am »
Truly bizarre.

Is there any chance your uC output ports are toasted, and there is nothing wrong with the FETs?

The confounding part is that the FETs work as expected off board...
« Last Edit: March 01, 2016, 09:31:29 am by dadler »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #15 on: March 01, 2016, 10:09:43 am »
Well. it is possible (but i say not likely) for the Atmega that sits on a DIY board. For the Arduino Due i highly doubt it because i have not soldered the processor of course, only the "shield" with all the other stuff.

Playing with the signal generator you can swear it is the processor because everything works.
In the processor circuit all voltages indicate the fet must be off yet isn't. So you can swear it is the fet.
So which is it...?
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline xtoffer

  • Contributor
  • Posts: 33
  • Country: se
  • A CS turned electronic hobbyist.
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #16 on: March 01, 2016, 02:29:30 pm »
Hello, I wanna try one guess. Since everything should work there is probably a false assumption somewhere.

I keep getting stuck on the ground part and feel that there still might be something fussy there. -If- the grounds were not connected funny things would happen. The reason it would work by connecting the signal generator could be that through connecting it you also make a proper ground connection.  (And likewise when you manually pulled the gate low.) The reason it measured roughly the same potential could possibly be that the meter pulled the two grounds together?

To put my mind to rest, could you measure the resistance between the microcontroller GND pins (there are multiple on that one I think) and the FET source?

Otherwise... footprint? Nah I don't know..
 

Offline Farley

  • Regular Contributor
  • *
  • Posts: 88
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #17 on: March 01, 2016, 03:45:43 pm »
I might have missed it in the preceding posts, but did you confirm which pin (by pin number) on the ATMEGA386 that R7 is connected to?
 

Offline ivan747

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #18 on: March 01, 2016, 10:24:19 pm »
Is the pinout on the FET right?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #19 on: March 02, 2016, 02:52:17 am »
The substrate of the Opto Coupler is no connect, left floating ?

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #20 on: March 02, 2016, 03:01:54 am »
Quote
Playing with the signal generator you can swear it is the processor because everything works.
In the processor circuit all voltages indicate the fet must be off yet isn't. So you can swear it is the fet.
So which is it...?
If you are measuring gate voltage below threshold, and the LED is not fully off, it's because the FET is truly off... most of the time, but not all the time. (Did you scope it?) So if it's really dim and you can't see it flickering, you know the duty cycle is pretty low, and the average frequency is higher than 50Hz. And that the problem is most likely your code. (With a slight possibility it's a silicon errata that is not due to your error).

Step 1. Disable your interrupt routine.
Step 2. Set LED pin to output off. loop.
Step 3. Watch it really turn off.
Step 4. Change your test code to turn ON the LED. And watch it turn on.
Step 5. Repeat 2-4 as many times as necessary for you to accept that you have made a mistake.
Step 6. Now stop dicking around playing with your signal generator and get to work. :)

Step 7. Go back to the "turn off led" test loop. And enable your ISR. See if the LED is all the way off.
Step 8. If you have a scope, turn on the LED, and see if it's really on 100% of the time.

I put money it's your ISR, and a good chance it's due to what Psi posted. If that doesn't fix your problem, also try clearing all of your variables at startup. That's a shotgun approach, but it may be helpful. Also if you have a scope, try toggling a pin at the start of your ISR and toggling it off before exiting, then look at it on your scope. This is good, in general, to see if it's really doing what you think it is. Scope the LED pin on the other channel to find out where this spike is occurring in relation to your ISR as a whole.
« Last Edit: March 02, 2016, 04:39:02 am by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #21 on: March 02, 2016, 06:38:16 am »
I will respond to the latest posts here one by one. Some of the suggestions have been verified already several times but in the interest of keeping the thread readable, i will respond to each question here.

Hello, I wanna try one guess. Since everything should work there is probably a false assumption somewhere.

I keep getting stuck on the ground part and feel that there still might be something fussy there. -If- the grounds were not connected funny things would happen. The reason it would work by connecting the signal generator could be that through connecting it you also make a proper ground connection.  (And likewise when you manually pulled the gate low.) The reason it measured roughly the same potential could possibly be that the meter pulled the two grounds together?

To put my mind to rest, could you measure the resistance between the microcontroller GND pins (there are multiple on that one I think) and the FET source?

Otherwise... footprint? Nah I don't know..

The grounds have been originally designed along generally accepted design practices although the fact that these boards are only 2 layer do place certain limitations. Still, it is easily verifiable from the design documents and visually, that there is plenty of copper fill available for the ground connections. In a previous post i already reported that the fet pin voltages (those and those only decide if the fet is on or not) indicate turn off. Still to put minds at rest i measured the resistance (3 out of 4 cases) and every one is below 0.005 ohms (measured with rather accurate a Rohde&Schwarz lab multimeter).

I might have missed it in the preceding posts, but did you confirm which pin (by pin number) on the ATMEGA386 that R7 is connected to?
Yes of course. Again i remind that there are 2 different devices both showing the same symptoms. One is driven by an Arduino Due where it is hardly likely that the pinout would be wrong.
Both units are done using a PCB CAD with confirmed footprints. The same processor footprint has been used in numerous projects and is known good. It would be difficult to pass DRC and connectivity verification in the PCB CAD if that was wrong. Also the signals demonstrably go to the fets they should, it is just that the fets behave erratically.


Is the pinout on the FET right?
Yes. Again, this is a standard SOT-23 package footpring in the PCB CAD, with tons of use cases all over the place. Also the 2N7002 has been used in any number of projects with no issues until this. 2N7002 data sheet agrees with what is on the PCB.

The substrate of the Opto Coupler is no connect, left floating ?

Regards, Dana.
Yes, as specified in the data sheet. Anyway, it would have no impact on the ordinary LEDs, especially those on a totally separate board :)


[...]
If you are measuring gate voltage below threshold, and the LED is not fully off, it's because the FET is truly off... most of the time, but not all the time. (Did you scope it?) So if it's really dim and you can't see it flickering, you know the duty cycle is pretty low, and the average frequency is higher than 50Hz. And that the problem is most likely your code. (With a slight possibility it's a silicon errata that is not due to your error).
You may want to re-read what i wrote earlier regarding the Arduino Due use case: "... That case is made simple by the fact that the indicator LEDs are idle at start so there are no switching events at all. ..."
Quote

Step 1. Disable your interrupt routine.
Step 2. Set LED pin to output off. loop.
Step 3. Watch it really turn off.
Step 4. Change your test code to turn ON the LED. And watch it turn on.
Step 5. Repeat 2-4 as many times as necessary for you to accept that you have made a mistake.
Step 6. Now stop dicking around playing with your signal generator and get to work. :)

Step 7. Go back to the "turn off led" test loop. And enable your ISR. See if the LED is all the way off.
Step 8. If you have a scope, turn on the LED, and see if it's really on 100% of the time.
So i guess dicking must continue while we wait for more relevant suggestions if you have any.
Quote

I put money it's your ISR, and a good chance it's due to what Psi posted. If that doesn't fix your problem, also try clearing all of your variables at startup. That's a shotgun approach, but it may be helpful. Also if you have a scope, try toggling a pin at the start of your ISR and toggling it off before exiting, then look at it on your scope. This is good, in general, to see if it's really doing what you think it is. Scope the LED pin on the other channel to find out where this spike is occurring in relation to your ISR as a whole.
OK, i'll take your money. How much did we bet, again?

This is how the Arduino thing looks. Both LEDs are statically OFF in the procesor outputs. No interrupts, no nothing. I/O driven low with no changes and this is what i get.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline station240

  • Supporter
  • ****
  • Posts: 967
  • Country: au
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #22 on: March 02, 2016, 07:36:34 am »
Perhaps it's simply the mosfet is too sensitive. What voltage does the GPIO pin output when it's logically 0 ? It could be as high as 0.8V for example.
I'd try increasing the 100ohm resistor.
 

Offline jwm_

  • Frequent Contributor
  • **
  • Posts: 319
  • Country: us
    • Not A Number
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #23 on: March 02, 2016, 07:40:06 am »
A long shot but since you are reusing the TxD and RxD pins, you don't have a bootloader or something that is leaving the UART enabled do you?

Offline fable

  • Regular Contributor
  • *
  • Posts: 71
  • Country: cs
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #24 on: March 02, 2016, 08:33:46 am »
I had similar problem long time ago...Just replace gate drive resistor with 10k and remove resistor from gate to ground and it will work.
Sorry for my bad english.
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #25 on: March 02, 2016, 08:37:59 am »
Quote
In the processor circuit all voltages indicate the fet must be off yet isn't.
If you measure essentially 0V on the gate in circuit and you have verified LED turns completely off when you ground the gate, physically, then perhaps you should scope your FET gate? You must have a low duty cycle pwm going on??  :-//

You mentioned an optocoupler. Be sure to take your ground from the FET source pin when you scope it. This ain't rocket science. I don't believe in no ghosts.

Quote
You may want to re-read what i wrote earlier regarding the Arduino Due use case: "... That case is made simple by the fact that the indicator LEDs are idle at start so there are no switching events at all. ..."
So you think... You can be sure as you want what your Arduino is or isn't doing. But something is moving the FET gate. Or you are measuring voltage incorrectly. Are you saying you have a function generator but no scope?

If I'm wrong, fine. But if you haven't checked it, yet, this is the only logical explanation, IMO. You can speculate about unicorns all you want, but turn over the first rock at your feet, first.
« Last Edit: March 02, 2016, 08:54:22 am by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #26 on: March 02, 2016, 08:55:03 am »
Perhaps it's simply the mosfet is too sensitive. What voltage does the GPIO pin output when it's logically 0 ? It could be as high as 0.8V for example.
I'd try increasing the 100ohm resistor.
That won't do anything much to the static condition because the fet gate is essentially a capacitor with zero bias current. The only thing affected is the voltage division ratio between the drive and grounding resistors. And if you read the earlier posts that has been tried already. Combinations of 10/1k, 10/10k, 100/1k, 100/10k have all been tried with zip improvement in the problem.
But i agree that the fet could simply be too sensitive for some reason. Maybe a bad batch or something because the 2N7002 should take at least a volt at the gate before significant turn on. When i have time i will replace one with something else and see what happens.

A long shot but since you are reusing the TxD and RxD pins, you don't have a bootloader or something that is leaving the UART enabled do you?
No. Good suggestion but that is not it. No bootloader in the non-Arduino device. UART functionality is not programmed as is apparent from the non-Arduino source in an earlier post.

I had similar problem long time ago...Just replace gate drive resistor with 10k and remove resistor from gate to ground and it will work.
Sorry for my bad english.
Now that is just plain silly.

Quote
In the processor circuit all voltages indicate the fet must be off yet isn't.
If you measure essentially 0V on the gate in circuit and you have verified LED turns completely off when you ground the gate, physically, then perhaps you should scope your FET gate. You must have a low duty cycle pwm going on??
Not unless there are elves somewhere pwming the output. Where would such a pwm come from? I am the master of my code at least in the non-Arduino unit and i promise you there is no secret pwm going on. And in the Arduino unit the outputs are held statically at low level. There is no modulation at all for those pins in the code. I promise you i would know.
But yes, i have scoped all the signals multiple times and no secret pwm is going on. In fact the signals are quite clean so you would assume everything must work. Only not.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #27 on: March 02, 2016, 09:13:17 am »
If you scoped it properly. At the actual gate and source of the FET. At your fastest time base and trigger set to somewhere south of the gate threshold, with the probes and channel voltage divisions set right. And there is no signal there. Gate is always at the same potential as the source. And the LED is dimly lit, but it goes out when you physically ground the gate, changing nothing. Then you don't have a problem. You have something really interesting going on, indeed!

Quote
I am the master of my code
These are words that will never cross my lips, again. :)

Quote
Not unless there are elves somewhere pwming the output.
I call them bugs. Elves, that works, too.

If you are so sure, try tying your AVR LED output pin to the rail (whichever one is supposed to turn the LED off). This won't harm the AVR, if it's doing what you think. (And it probably won't do any harm if it's pwming at such a low duty cycle, either). If this results in a dimly lit LED, then you will know it's the circuit. And then I will start believing in this unicorn. Who cares what I think? And then, you should start considering a unicorn. RF interference, too fast to scope?

You mentioned an optocoupler. Maybe you need to check this part, next. At any rate, I don't think this has anything to do with the electrical levels of the Atmega. Volts are volts, and you are measuring them as ok.
 
« Last Edit: March 02, 2016, 10:02:27 am by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #28 on: March 02, 2016, 09:59:03 am »

Quote
I am the master of my code
These are words that will never cross my lips, again. :)
 
I knew someone would make that kind of comment  ;D. My admittedly arrogant claim was mainly targeted at the suggestions of checking for all kinds of n00b level mistakes. While none of us are incapable of error like HAL9000, I want to think myself able to avoid such elementaries in the first place and at least able to find them when they occur nevertheless.
Some code is hastily written and logical errors do creep in, but i have difficulty recalling when coding language or the hardware would have been issues.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #29 on: March 02, 2016, 10:04:53 am »
Sorry, I'm not intending to be a smartass or to give you attitude. Just imploring you to do your due diligence and to rule out any source of human error before getting us all excited about a new and mysterious FET phenomenon. Even "picking up" a non-signal with a scope, you might want to prove to yourself that the scope is setup correctly by picking up a minimally equivalent test signal (because no one has ever made a mistake setting up a scope before!) And I am sorry I took your words out of context, a bit. I know you meant that this problem was not dependent on Arduino libraries. :)

Personally, for me, it's ALWAYS my own error, and usually my code, until proven otherwise. But I am terrible at coding, and I know it.

And I'm not suggesting it's a n00b mistake, or even your mistake, even if it is the code. There are innumerable ways to get unintended bugs. It might be your compiler, errata, erroneous documentation or header files, or a very un-n00b coding error. I can't read your code, but Psi and jwm_ have mentioned some things that have bitten me, repeatedly.
« Last Edit: March 02, 2016, 11:28:42 am by KL27x »
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2145
  • Country: fi
  • Embedded SW/HW.
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #30 on: March 02, 2016, 10:22:32 am »
Try removing R7 when you see the phenomenon. If the MOSFET still conducts after removing the R7, you have a 2N7002-thyristor :)

Have you checked the 12V power supply? Is it noisy? Does it contain fast voltage spikes which could couple capacitively to 2N7002 and keep the 2N7002 in conducting state?

You could also try changing the 10K gate resistor to 1K which would make the gate less sensitive to the capacitive coupling and noise.

Pretty weird problem you have in your hands.
 

Offline deksnis

  • Newbie
  • Posts: 3
  • Country: lv
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #31 on: March 02, 2016, 10:25:17 am »
Once I had similar problem.
Then I had no time for experiments and just added resistor from drain to power which probably draw 1mA more when LED was turned on, but also it ate leaked current.
Probably LEDs are very sensitive and can glow even with very small current. Did you measure LED current in OFF state?
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #32 on: March 02, 2016, 10:38:49 am »
Oh, another test. If you think your atmega (or is it the optocoupler?) isn't pulling close enough to ground, try manually grounding the FET pin through a diode or three to see if that doesn't still turn the LED completely off!
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #33 on: March 02, 2016, 11:36:56 am »
When you measure LED current are you measuring Id of 2N7002 or Iled.
If the opto coupler has been stressed, or you have terminated the opto
coupler substrate to some potential other than floating you could have
Iled > 0 while Idfet = 0, eg. the 2N7002 is in fact off. The opto coupler
could have been damaged, over stressed, and the internal isolated substrates
for the Triac and LED bridged.

Earlier comment to reduce Rgs of 2N7002 due to noise. That infers that
Zgs is set by the 10K, which is not the case, unless Atmel output in high
Z. Its the high or low Rdson of the Atmel PMOS or NMOS output transistor
that will set the noise susceptibility. Still a good idea to make sure the 12 Vdc
supply is clean however.

The upper limiting value of Rgs is established by leakage (Rgs x Leakage << Vthmosfet)
and stray C coupling and wasted power consumption when 2N7002 is being driven high.

For the people who keep implying you need to measure Vgs of 2N7002 to see if its
being driven off, they clearly missed your earlier post where you measured it to be
~ 40 mV.



Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #34 on: March 02, 2016, 11:43:12 am »
Sorry, I'm not intending to be a smartass or to give you attitude. Just imploring you to do your due diligence before getting us all excited about a new and mysterious FET phenomenon. And I took your words out of context, a bit. I know you meant that this was not dependent on Arduino libraries. :)
Personally, for me, it's ALWAYS my code until proven otherwise. I am terrible at coding, and I know it.
No offense taken. I have seen enough to agree with you in principle.
At the risk of again sounding arrogant, i am not terrible at coding. I have been employed for decades to write code that is often safety-of-life critical, as well as code to control heavy industrial machinery (distributed paper machine drive systems, FMS centers, all manner of heavy manufacturing automation). Some of it in days when the words "best" and "practice" did not usually appear one after the other. You had ruled paper and pencil and precious little else. Learned many things in the school of hard knocks.
Quote
And I'm not suggesting it's a n00b mistake, or even your mistake, even if it is the code. There are innumerable ways to get unintended bugs. It might be your compiler, errata, erroneous documentation or header files, or a very un-n00b coding error. I can't read your code, but Psi and jwm_ have mentioned some things that have bitten me, repeatedly.
But that is part of my point. The 328P code is absolutely trivial and there is no way in hell it won't do what the source says. If a simple GPIO output was an errata case, the whole product would be unusable for anything. It is guaranteed by experience from numerous earlier cases that the functionality the code exercises does work, and i can see it work by all the tests i care to apply. The output pins switch state exactly when they are supposed to (this has been debugged thoroughly) in both cases.

Try removing R7 when you see the phenomenon. If the MOSFET still conducts after removing the R7, you have a 2N7002-thyristor :)
Now that is one thing i have not tried yet. I will, but it will be tomorrow as today i am busy with other things.
Quote

Have you checked the 12V power supply? Is it noisy? Does it contain fast voltage spikes which could couple capacitively to 2N7002 and keep the 2N7002 in conducting state?
Only superficially. The 12V is nominal only as it is unregulated and varies (it is also clearly higher but that is OK, it has been accounted for). The regulator is a simple LDO so no spiking or ripple appears in the supply, other than the 100 Hz capacitor ripple that is insignificant.
Quote

You could also try changing the 10K gate resistor to 1K which would make the gate less sensitive to the capacitive coupling and noise.
Tried it already. No help there.
Quote

Pretty weird problem you have in your hands.
You don't say :) Before experiencing this i would have laughingly dismissed such problems as just incompetence if someone else had reported it.
But i have now 4 similar circuits on 2 physically separate PCBs driven by 2 different processors (Atmega 328P AVR on the DIY board and a SAM3X ARM on Arduino Due + DIY shield). 3 of those are visible LEDs and the last is the triac opto. All share 1 thing in common and that is the 2N7002 fet and all have the same problem.
Additionally, the above Arduino drives an essentially identical fet circuit on a separate satellite PCB where the fets control internally optoisolated Toshiba SSRs. Those function perfectly and the only difference is that the fet for there is BS170, not 2N7002.

Oh, another test. If you think your atmega (or is it the optocoupler?) isn't pulling close enough to ground, try manually grounding the FET pin through a diode or three to see if that doesn't still turn the LED completely off!
The SAM at least pulls down to ~40mV and if that doesn't turn the fet off then there is no justice. Having said that the fet _does_ turn off if i forcibly ground the gate using a piece of wire. So that would indicate that 40 mV is enough for turn on against everything the data sheet says. At least Fairchild data sheet indicates that not much happens with Vgs below 2 volts. I know from experience that many specimens do conduct between 1 and 2 volts but 40 mV is way below that...
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #35 on: March 02, 2016, 11:54:36 am »
Quote
The SAM at least pulls down to ~40mV and if that doesn't turn the fet off then there is no justice. Having said that the fet _does_ turn off if i forcibly ground the gate using a piece of wire. So that would indicate that 40 mV is enough for turn on against everything the data sheet says. At least Fairchild data sheet indicates that not much happens with Vgs below 2 volts. I know from experience that many specimens do conduct between 1 and 2 volts but 40 mV is way below that...
Maybe you misunderstood what I meant. Instead of grounding it with a bare wire short, try shorting it through a diode drop. So you're only pulling it down to 0.6-0.7V, which is higher than the 40mV you are currently measuring. If 40mV is truly letting the FET leak, 0.6-0.7V won't turn it off any further. If clamping through a diode turns off the LED, then you know there's a phantom signal.

Quote
Those function perfectly and the only difference is that the fet for there is BS170, not 2N7002.
Well this is eye-opening. It surely sounds plausible that the trench FET and the LED are both extremely sensitive. Maybe a simple thing to try is to change out the FET for another part number?

FWIW, I concur that Figure 10 of the datasheet appears to show less than 1 microamp should be passed with 5V at the drain and gate voltage less than 0.6V under the most extreme circumstance. 1uA could definitely cause a visible glow in a sensitive LED, and your Vds is closer to 12V. But at gate voltage of 40mA 40mV one would presume much less leakage.

Please keep us posted on tomorrow's experiments!
« Last Edit: March 02, 2016, 10:26:39 pm by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #36 on: March 02, 2016, 12:13:37 pm »

Maybe you misunderstood what I meant. Instead of grounding it with a bare wire short, try shorting it through a diode drop. So you're only pulling it down to 0.6-0.7V, which is higher than the 40mV you are currently measuring. If 40mV is truly letting the FET leak, 0.6-0.7V won't turn it off any further. If clamping through a diode turns off the LED, then you know there's a phantom signal.
I may indeed have misunderstood you. I will try that also when i'm at it next.
Quote
Quote
Those function perfectly and the only difference is that the fet for there is BS170, not 2N7002.
Well this is eye-opening. It surely sounds plausible that the trench FET and the LED are both extremely sensitive. Maybe a simple thing to try is to change out the FET for another part number?

Quote
The 328P code is absolutely trivial and there is no way in hell it won't do what the source says. If a simple GPIO output was an errata case, the whole product would be unusable for anything.
I have no experience with this device. I have plenty of experience with GPIO not doing what I think, because it is multipurpose and the configuration not set right. And I have plenty of experience with my code not behaving as I thought, even when it seems to be doing exactly what I want it to!
I have lots of experience with the Atmega328P and it is my default processor for small items. For this current application it is gross overkill but who cares. It does the job (well, YMMV apparently...) and cost is no issue. The point is that i do know how the part behaves and i am confident that whatever silicon errors there lurk, this basic GPIO functionality is not one of them. If that were the case most of my projects would be in serious trouble.
Quote
Please keep us posted on tomorrow's experiments!
I will do that.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #37 on: March 02, 2016, 01:41:26 pm »
I am such a sucker. I actually wired up one of my most sensitive FETs (http://www.mouser.com/ds/2/115/DMN65D8L-219098.pdf) to my most sensitive LED (orange, no part number, but it is fantastically sensitive. Diode test lights it up almost as bright as you'd want for an indicator!), no series resistor on the LED, at all.

12V to the anode on my bench psu, limited to 150mA. 1.2K pullup on the gate which is also clamped to the source with a diode. I measured the Vgs at 0.69V. No glow, at all. (Until I put DMM voltmeter probe on the cathode, and it lights up a bit taking the reading!). Probed all the points to make sure I had everything wired, correctly, all good. Turned the current limiting down to 10mA and removed the diode, and bright light ensues.

Doesn't prove anything except what a lack of a life I have, but I thought I'd share! :blah: (These FETs are pretty cheap, too, AFAIC. So maybe you can use it if your FET is to blame.)
« Last Edit: March 02, 2016, 01:50:28 pm by KL27x »
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2183
  • Country: au
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #38 on: March 02, 2016, 02:12:45 pm »
This is a long shot but have you any freeze it spray handy (compressed air cans upside down work also)
It would be interesting to see if cooling the fet helps it turn off. Gate threshold voltage drops with increase in heat perhaps this may be a problem :-//
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26751
  • Country: nl
    • NCT Developments
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #39 on: March 02, 2016, 03:10:44 pm »
I vote for ESD damage. The 2N7002 has very little gate capacitance so it is very easy to destroy.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #40 on: March 02, 2016, 04:17:50 pm »
PD0 is shared with RXD and the description of the UART says it owns that pin unless it is disabled (i.e. it does not get overriden by DDRD).

A bit of RXEN0 = 0 ?

If you switch to a GPIO not shared with RXD does it behave?

As per...

A long shot but since you are reusing the TxD and RxD pins, you don't have a bootloader or something that is leaving the UART enabled do you?

RXEN does give you a pull up on PD0 but RXEN is default to 0 so you would have to have something else enabling it as per jwm_'s suggestion.
« Last Edit: March 02, 2016, 04:44:17 pm by NivagSwerdna »
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #41 on: March 02, 2016, 04:49:59 pm »
Where were these 2N7002s sourced from?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #42 on: March 02, 2016, 04:52:40 pm »
At this point it would be real tempting to pull an LED and 2N7002 off the board, set it up
in a protoboard, and see if it works as one expects. The primary thing that would make
drain current in the 2N7002 with a Vgs = 0 would be either blown gate, or the output
drain to source diode damaged (usually done by exceeding safe area, L dominant transients).

Not applicable but also notice Idss at Vgs = 0, hot, 1 mA is the spec.

Regards, Dana.
« Last Edit: March 02, 2016, 05:01:04 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #43 on: March 02, 2016, 05:11:59 pm »
Where were these 2N7002s sourced from?
If memory serves, from Mouser. Actually i am convinced because i seldom get semiconductors from anywhere else. Definitely not from cheapo Asian sources.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #44 on: March 02, 2016, 05:45:11 pm »
Where were these 2N7002s sourced from?
If memory serves, from Mouser. Actually i am convinced because i seldom get semiconductors from anywhere else. Definitely not from cheapo Asian sources.

Should be good then. I do know that 2N7002s are extremely ESD sensitive. I just fried a couple of them a few weeks ago when testing a circuit in my bench. One would leak about 200uA of current and never fully shut off. But when you ground the gate, yours DO turn off...
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #45 on: March 02, 2016, 08:11:53 pm »
To guard against this my workbench is protected with proper ESD conductive mat, wrist straps and ground connections. It is still possible to zap a very sensitive part but i don't think that is the problem. Not for all 4 of the cases.
I had time for a quick hack just now and replaced one of the 2N7002s with a BS170. I can report that the corresponding LED is now fully off as it should be. So it was the fet as i suspected, after all. Later i could try to run some components thru a Peak tester to get the characteristic curves. Those could be revealing.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #46 on: March 02, 2016, 09:15:03 pm »
Quote
Not applicable but also notice Idss at Vgs = 0, hot, 1 mA is the spec.
That sounds excessive. I'm seeing this:
http://www.nxp.com/documents/data_sheet/2N7002F.pdf

IDSS drain leakage current VDS = 48 V; VGS = 0 V
                 min    typ     max               
Tj = 25 °C     -    0.01    1 uA
Tj = 150 °C   -     -       10 uA

Quote
If memory serves, from Mouser.
The Mouser stocked version is a tenth of a cent cheaper than the reel of logic level FETs I just bought. I'll consider it lucky I was looking for minimum current of 250mA.  :phew:
« Last Edit: March 02, 2016, 09:46:07 pm by KL27x »
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #47 on: March 02, 2016, 09:38:41 pm »
From this datasheet - https://www.fairchildsemi.com/datasheets/2N/2N7000.pdf

I should correct my earlier post to .5 mA hot for the 2N7002.

Regards, Dana.
« Last Edit: March 02, 2016, 09:40:57 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #48 on: March 02, 2016, 09:48:04 pm »
Ok. Actually, the Mouser stocked Diodes incorporated SOT 23 2n7002 is also showing half a milliamp.

Interesting thing I learned from the Fairchilds datasheet
SOT23 = TO-236AB   ?! ... naturally.
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #49 on: March 02, 2016, 10:15:14 pm »
What about the value of the SPIEN fuse?

Anyway, the question remains... does it still behave this way on other GPIO pins?  Which ones have you tried?
« Last Edit: March 02, 2016, 10:25:11 pm by NivagSwerdna »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #50 on: March 02, 2016, 10:48:23 pm »
NiVagSwerdna, you think the way I do!

There is no code too simple for me to screw up. Any simple change or addition I make to a code, I am surprised if it works on the first try. I spend more time finding my logical errors than writing new code. If my code doesn't work, I am now completely satisfied that it's essentially correct, except for such error I just have to find, lol.

Just last week I fixed an eerily relevant problem where I was calling a subroutine from ISR that was also used in the main code loop, unwittingly sharing a temporary variable between the two. This didn't cause any noticeable problem until over a year later, when I changed some timings on the ISR for an unrelated issue... then a GPIO pin would briefly toggle itself on, on the order of a millisecond, every few seconds. |O
« Last Edit: March 02, 2016, 10:55:33 pm by KL27x »
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #51 on: March 02, 2016, 11:20:19 pm »
redacted  ;)
« Last Edit: March 03, 2016, 11:28:34 pm by NivagSwerdna »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #52 on: March 02, 2016, 11:22:05 pm »
"Just last week I fixed an eerily relevant problem where I was..."

That proves that you are a good human programmer, :), because only fools would assume that his code is bug free while debugging it.

The issue at hand is very easy to debug, as the bugs are painfully obvious.
================================
https://dannyelectronics.wordpress.com/
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #53 on: March 03, 2016, 05:39:23 am »
"Just last week I fixed an eerily relevant problem where I was..."

That proves that you are a good human programmer, :), because only fools would assume that his code is bug free while debugging it.

The issue at hand is very easy to debug, as the bugs are painfully obvious.
The issue at hand turned out to need no debugging as it was a hardware problem.
But by all means do share your pain if you feel like it :)
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #54 on: March 03, 2016, 05:42:49 am »
[...]
SOT23 = TO-236AB   ?! ... naturally.
It is a constant irritation that the same things are multiply standardized - or at least encoded. And the only way to find out is byt exhaustive search because of course there are no comparison sheets or such. At least i never encountered any.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #55 on: March 03, 2016, 12:27:27 pm »
I replaced every 2N7002 with Si2308 logic level fets in the problem units and Bob seems to be my uncle. Everything now works without any further changes. Leds turn on and off as expected. Triacs trigger when they are supposed to and everyone is happy.
Note to self: get a reel of Si2308's and delegate the 7002s to other things...

So as far as i am concerned, case closed and thanks for everyone who had constructive comments.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #56 on: March 03, 2016, 06:26:35 pm »
Glad you fixed the problem!
« Last Edit: March 03, 2016, 07:06:44 pm by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #57 on: March 03, 2016, 07:06:31 pm »
Yeah, whatever. Though i don't really know why you assume i don't understand that hardware needs to be debugged and why you further assume that i have _not_ debugged the problem to the extent needed. Because i have. Turns out it is not a software problem so there.
Hardware problem solved by elimination. Sorry if this is not enough for you but it is enough for me and it is my project.
The only thing i recall mentioning that i haven't gotten to is characterize the 2N7002. It is not high on my list of priorities so i may never get to it what with other things eating my time. If you are not satisfied with that then sorry, but i can live with it.
I am a bit surprised about your belligerent attitude because i fail to see what i did to deserve it. But that is up to you to decide i guess.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #58 on: March 03, 2016, 07:07:19 pm »
Ooops, I deleted my thread too late. Impulse. Please disregard. Or should I put it back?

My intention is not to ruffle feathers.

Quote
i don't really know why you assume i don't understand that hardware needs to be debugged and why you further assume that i have _not_ debugged the problem to the extent needed
I don't assume you don't. But I don't assume you do, either. Why would anyone assume you do, from this thread, alone?
Quote
Bob seems to be my uncle.
"Seems" shouldn't have to be in this sentence!
Quote
I am a bit surprised about your belligerent attitude because i fail to see what i did to deserve it.
??

My previous post was unfortunately not saved in my clipboard. But as you say, whatever. I'll accept belligerent, as long as the content of the post is also conveyed. Which is to say, if I don't assume anything and go by what you have written, what you have strictly written is slightly lacking in the scientific process. And the conclusion (behavior between 0 and 40mV) so very curious as to merit a more bulletproof verification, maybe. The datasheet suggests the difference there should be between that of jack and @#$#, and jack left town. (Army of Darkness!)

40mV is a perfectly acceptable CMOS digital low output. The output FETs of the CMOS micro pins have a significant RDS, themselves. (What load do you have on there that might be pulling the pin up to 43mV? Who knows? I thought it was just the FET on this pin, which is only capacitive?) Any rate, a logic level FET that changes RDS from megaohms to kiloohms between 0 and 40mV Vgs is a curiosity. At below standardized CMOS logic low, this thing acts like a 50K resistor.

Perhaps you have done a sufficient proof, already, but you did not write it. Perhaps you know you didn't do this, and you don't care. Either way that would be fine. I am posting this because you came back to declare the proof is done... it "seems," without an explanation beyond, "I swapped these crappy FETs with these good FETs and my circuit is now working as I intended. The 2n7002 is crappy. And the problem was not my code."

Extraordinary claims require extraordinary verification. I'm not the only one thinking it. I'm just the idiot with no filter. I'm ordering some resistors from Mouser, and what do you think the chances of me replicating your results are going to be if I add 2n7002 NFET to my cart?
« Last Edit: March 04, 2016, 01:02:57 am by KL27x »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #59 on: March 04, 2016, 01:02:12 am »
I tried a few 2n7000: at about 1v, the current goes below 0.1ua, fairly consistently.
================================
https://dannyelectronics.wordpress.com/
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #60 on: March 04, 2016, 01:04:46 am »
Besides that, I just googled CMOS output voltage levels, and I had to correct my previous post. The max is apparently defined at 50mV, which is a surprise to me and puts a new twist on this. At first, I didn't think anything of 43mV. 43mV is small. But compared to 50mV max, it is a lot.

If his output pin is low, and it's only connected to a FET gate, then should it even measure 43mV? CMOS output is through a FET, itself, which is a purely resistive voltage drop. And with no load, would it even be that high? Where is this 43mV of drop coming from?

So if an output pin is rated for 25mA, let's say, it has to be able to sink 25mA and still maintain 0.05V, max. At a microamp (to cover gate leakage, lol), it should be much less. At 43mV, if the Atmega actually meets spec, this suggests the pin is sinking at least (if not more than) 4/5th of its max output rating simply holding a signal FET gate down. (Or that his pin maybe isn't doing exactly what he thinks it is. Which sounds more plausible?)

So I have a PIC project already wired up on my bench. And I just measured voltage on a PIC output pin digital low with no load. Supply voltage 5V. Pin measures 0.000V. Nada. (And of course I also verified it gives ~5V when the pin goes high to validate my test setup!)

For giggles, if that 43mV were coming from an intermittent high output or an internal pullup resistor, 0.043V/5V is a duty cycle of 0.86% at 5V (or 1.3% at 3.3V), if I'm not mistaken. Enough to give an LED a decent glow. Due to the capacitance of the gate and the rise/fall times of the pin output FETs, the actual duty cycle of the pin might be considerably smaller than 1%, if the frequency is high. This is a situation that might occur... if the ISR is using that pin, for instance. A UART ISR, for example. Just one possibility to consider.
« Last Edit: March 04, 2016, 04:00:50 am by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #61 on: March 04, 2016, 06:20:07 am »
Ooops, I deleted my thread too late. Impulse. Please disregard. Or should I put it back?

My intention is not to ruffle feathers.
OK, i will so assume then.
Quote

My previous post was unfortunately not saved in my clipboard. But as you say, whatever. I'll accept belligerent, as long as the content of the post is also conveyed. Which is to say, if I don't assume anything and go by what you have written, what you have strictly written is slightly lacking in the scientific process. And the conclusion (behavior between 0 and 40mV) so very curious as to merit a more bulletproof verification, maybe. The datasheet suggests the difference there should be between that of jack and @#$#, and jack left town. (Army of Darkness!)
Well, i wasn't aiming for scientific, i was aiming for fixed. Now it is fixed. But why not, we can continue the study to do the science part as well. Only it has to wait until i make delivery which is the priority here.
Quote

40mV is a perfectly acceptable CMOS digital low output. The output FETs of the CMOS micro pins have a significant RDS, themselves. (What load do you have on there that might be pulling the pin up to 43mV? Who knows? I thought it was just the FET on this pin, which is only capacitive?) Any rate, a logic level FET that changes RDS from megaohms to kiloohms between 0 and 40mV Vgs is a curiosity. At below standardized CMOS logic low, this thing acts like a 50K resistor.
In all cases the GPIO pin load is only the fet gate. Nothing else.
Quote

Perhaps you have done a sufficient proof, already, but you did not write it. Perhaps you know you didn't do this, and you don't care. Either way that would be fine. I am posting this because you came back to declare the proof is done... it "seems," without an explanation beyond, "I swapped these crappy FETs with these good FETs and my circuit is now working as I intended. The 2n7002 is crappy. And the problem was not my code."
Sorry about being imprecise. I did not mean proof in any math or scientific sense. Rather in the British "proof of the pudding is in the eating" sense. Also, around these parts there is another saying: "if the terrain and the map disagree, the terrain is right". So for me the proof was in replacing a suspect component and seeing the problem go away. After that we can start the science part.
Quote

Extraordinary claims require extraordinary verification. I'm not the only one thinking it. I'm just the idiot with no filter. I'm ordering some resistors from Mouser, and what do you think the chances of me replicating your results are going to be if I add 2n7002 NFET to my cart?
Fair enough. You only have to ask nicely and i'll do anything. So, a promise from my part: during the weekend i'll find time to characterize the 3 fets; 2N7002, BS170 and Si2308. Unfortunately i don't have the specific original fets available as those were mutilated during removal. But i do have a lot of them from the same tape reel i.e. most likely the same mfg batch. I'll use thiose and take it on faith that they behave the same.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #62 on: March 04, 2016, 06:36:26 am »
Besides that, I just googled CMOS output voltage levels, and I had to correct my previous post. The max is apparently defined at 50mV, which is a surprise to me and puts a new twist on this. At first, I didn't think anything of 43mV. 43mV is small. But compared to 50mV max, it is a lot.

If his output pin is low, and it's only connected to a FET gate, then should it even measure 43mV? CMOS output is through a FET, itself, which is a purely resistive voltage drop. And with no load, would it even be that high? Where is this 43mV of drop coming from?
The GPIO pins have more electronics than just a simple fet totem pole connected to them. But of course nowhere is a detailed schematic available [edit: <-- which makes it hard to say what the voltage should be in the first place]. Atmel data sheet specifies DC electrical characteristics as Vol@5Vcc as 0.9V max @85C. So 43 mV is way below stated maximum permissible. 2N7002 data indicates that the fet starts conducting somewhere just below 2V (NXP data sheet) or somewhat over 2V (Fairchild data sheet).
Quote

So if an output pin is rated for 25mA, let's say, it has to be able to sink 25mA and still maintain 0.05V, max. At a microamp (to cover gate leakage, lol), it should be much less. At 43mV, if the Atmega actually meets spec, this suggests the pin is sinking at least (if not more than) 4/5th of its max output rating simply holding a signal FET gate down. (Or that his pin maybe isn't doing exactly what he thinks it is. Which sounds more plausible?)

So I have a PIC project already wired up on my bench. And I just measured voltage on a PIC output pin digital low with no load. Supply voltage 5V. Pin measures 0.000V. Nada. (And of course I also verified it gives ~5V when the pin goes high to validate my test setup!)

For giggles, if that 43mV were coming from an intermittent high output or an internal pullup resistor, 0.043V/5V is a duty cycle of 0.86% at 5V (or 1.3% at 3.3V), if I'm not mistaken. Enough to give an LED a decent glow. Due to the capacitance of the gate and the rise/fall times of the pin output FETs, the actual duty cycle of the pin might be considerably smaller than 1%, if the frequency is high. This is a situation that might occur... if the ISR is using that pin, for instance. A UART ISR, for example. Just one possibility to consider.
At least Atmel makes no promises that the pin would go anywhere really close to 0 voltage. And that should not be necessary either because typically logic low level is specified somewhere between .5 to 1V depending on the family. So at ~43mV that part should be quite OK. As it is for the other fets, just not for 7002.
« Last Edit: March 04, 2016, 06:40:59 am by Kremmen »
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #63 on: March 04, 2016, 07:30:21 am »
Quote
The GPIO pins have more electronics than just a simple fet totem pole connected to them.
Sure they do. But they ALSO have two FETs, source on the rails and drains on the pin. And when they're on, all other sources of voltage drop could/should be bypassed. Such as with my PIC output pin.

Quote
Atmel data sheet specifies DC electrical characteristics as Vol@5Vcc as 0.9V max
Ok, this sounds more like what I envisioned, practically speaking. But it's still no matter. The 50mV max spec just opened my eyes to what I initially dealt with as a red herring (because there was already the obvious evidence there that suggested what was really going on). It doesn't matter how high RDSon of the output pin NFET is, because zero current flow = zero voltage drop. So 43mV represents voltage drop which is consistent with just 4.7% (rather than 80+%) of the max output current. So what? This is still 1.2 mA (if your output pin is rated for 25mA), which is still way too high for gate leakage, by about 10^6.

It is easily determined if you have a signal on the pin if you do the diode test I suggested with a faulty board.

It is easily determined what your unloaded GPIO outputs should be expected to measure by testing another one of them that isn't by default a TX/RX pin. Or go all the way and switch the pin in your circuit, as Nivagswerdna had suggested.

It would easily be determined if your FETs are as strange as you think, if you wired one up to a potentiometer on the gate with the same LED. And I wonder if you will see any glow at 50mV Vgs?

Some of these things you can test in less than 60 seconds. You could squash my theory in no time. Yet you continue to pontificate. Perhaps you already did some of these things? Or perhaps you have shrugged off some quirk you have already noticed which is suggestive. Perhaps you still hold out hope that there is an alternate explanation where I am wrong? Do you hate me this much? Or is your hole too deep? You can put down the shovel.

I'm going to predict that the other two FETs you used which "work" do so because their gate capacitance is significantly bigger. They spend less time above threshold, or maybe none at all, as a result, despite the average voltage being unchanged. I have not looked at their datasheets, so it will be curious to see if this isn't the case.

« Last Edit: March 04, 2016, 08:42:40 am by KL27x »
 

Offline KremmenTopic starter

  • Super Contributor
  • ***
  • Posts: 1289
  • Country: fi
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #64 on: March 04, 2016, 08:43:58 am »
Quote
Some of these things you can test in less than 60 seconds. You could squash my theory in no time. Yet you continue to pontificate. Perhaps you already did some of these things? Or perhaps you have shrugged off some quirk you have already noticed which is suggestive. Perhaps you still hold out hope that there is an alternate explanation where I am wrong? Do you hate me this much?
Sorry, i do not consider myself to be in a debate with you. I'd say the pontification happens on your side because for me the priority is in the practical fix which is now achieved.
Hate you? I have no feelings toward you either way. You appear a bit quick to take offense but that matters not at all to me as long as this thread stays reasonably civil. If not, i'll just walk.

On the actual subject; the practical issue is that i have a delivery to make. All hardware related to that is already fixed (as in not changeable) - PCBs have been mfg'd and so on. So it is useless to suggest changes there as that won't happen.

I am free to work the circuit in the lab as much as i please but that will take place afterwards, once the stuff is delivered. Once again i say the original issue was not primarily a research project but a purely practical problem. No extra points for thorough dissemination, only for making it work. Now it works so i can move on to other things. I also remind that i am not the forum lab assistant so just hold the comments of me not doing this or that on command.

I have relatively little interest in various hypotheses why this or why that related to this case. Probability suggests that none of the components were actually broken and that they behave as they normally do. I am prepared to verify this somewhat using known good specimens but that's about it. There is nothing any one of us can do to change the components in any way and i won't bother creating workarounds for such an essentially trivial issue. Change a component to something that works, make a note to self and move on.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #65 on: March 04, 2016, 08:50:56 am »
delete
« Last Edit: March 04, 2016, 08:52:40 am by KL27x »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #66 on: March 04, 2016, 08:52:21 am »
Ok, then. Good night.

For anyone who actually cares:
Si2308  Tgc  6nC
2N7002 Tgc  223 pF
BS170   Tgc  ? on the first datsheet I pulled.  But current capability 2.5x higher suggests higher gate charge.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #67 on: March 04, 2016, 12:04:04 pm »
Quote
For giggles, if that 43mV were coming from an intermittent high output

A plausible explanation - a very low duty cycle output + isolation resistor + gate capacitance means that it can turn on an led briefly if the gate capacitance is low but unable to turn on the led if the gate capacitance is high.

Quote
You could squash my theory in no time.

Agreed. debugging this thing is no brainer.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #68 on: March 04, 2016, 02:21:08 pm »
A 2n7002 reached 0.1ua at 1.34v Vgs.

So unless knockoff parts are at play here, this is not a DC problem.
================================
https://dannyelectronics.wordpress.com/
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #69 on: March 05, 2016, 03:49:28 am »
I don't know all that much about the silicon. But I would not even attribute this to a "poorly made knockoff." I would consider this FET to be possibly valuable for research. I am certainly going to dig around on the matter before I shrug and toss FETs into bin to "delegate to other things." It might be valuable info to the manufacturer. Perhaps it would even be a scientific lottery ticket of sorts. It might be what puts your name down in history.

I'd certainly want to scope it. Is full saturation at the regular level? Is this huge switching region starting sub decivolt somewhat linear? This could be useful for a variety of things, I can imagine.

Again, I have no clue about the actual silicon, but inherently it seems to be improbable that anything interesting can happen very much below the VFD of a diode junction? Nominally approaching ~0.3V, at least (for a germanium FET?), before anything good starts to happen? This is why I said if OP is really seeing this, he doesn't have a problem, but instead something very interesting!

I was so confident because of my shallow understanding of how FETs work, not because of my shallow experience with embedded programming. Not because I had a similar problem a week earlier, and now I see every problem as ISR. Maybe someone will show how I am wrong, but I think it would be highly unlikely for a FET to behave this way. The rest of the proof, calculating impossibility of current in output pin and demonstrating duty cycle is extra tooth pulling to show what I already believed should be obvious?

Quote
A plausible explanation
So far as I can tell, this is the only plausible explanation since the start, for which I am genuinely surprised I didn't get an immediate "duh, thanks, of course, it's so obvious |O" 2 pages back.

*Edit... ohhh, check my post count. :)
« Last Edit: March 05, 2016, 11:25:16 am by KL27x »
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 2495
  • Country: gb
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #70 on: March 05, 2016, 06:37:24 pm »
this is not a DC problem.
:-+
Would be interesting to see a trace of gate voltage in steady state and in 0->1 and 1->0 transitions
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #71 on: March 05, 2016, 08:06:54 pm »
It would be my prediction that nothing your equipment can measure will happen until Vgs is at least above 0.5V, just like any other silicon FET.

To think a FET turns on at 40mV is similar to believing a red LED will glow at 100mV. This is why I said OP was chasing unicorns. If I can catch one of these, it will be my only project until I figure out how it will make me rich.

Quote
0.1ua at 1.34v Vgs.
I am not sure how you are measuring this. But I have imagined you could even just do ohm test with a DMM. I think it would be valid, red probe on drain and black probe on ground/source. It would be testing at VDS of ~3V, or w/e your DMM puts out for its resistance check. Perhaps this could extend your measurable test range.
« Last Edit: March 05, 2016, 09:07:09 pm by KL27x »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #72 on: March 05, 2016, 09:40:06 pm »
Quote
To think a FET turns on at 40mV is similar to believing a red LED will glow at 100mV.

Possible with depletion fets - fairly rare for mosfets.

Quote
I am not sure how you are measuring this.

using the current range, under 5V supply. So Vds is very close to 5v.
================================
https://dannyelectronics.wordpress.com/
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #73 on: March 05, 2016, 10:24:45 pm »
Oh, ok. I had to google depletion mode. It looks like it would be the same thing in opposite. I mean, 43 mV would for sure completely leave it on, but you would start getting into the grey area at negative voltage between 0 and threshold. 

It has been years since I tried to understand how a FET works, and now that I have just looked at basic information, I don't see where the body diode comes into play, at all, so my own reasoning is possibly completely off, and I got lucky in this instance. The only super basic (i.e. which I can understand, anyway) theoretical information I find suggests that gate charge and resistance are proportional in some way, but it of course doesn't explain the scaling and/or limits. The knee or tipping point, where thing start to happen fast, is still blank in my own understanding. I can guess there's a discrete distance factor between the dielectric barrier/charges across the gate that requires certain minimum force/charge in order to even reach across. And then things would be progress exponentially after that, as the field is perhaps roughly spherical.

The other thing I'm left with is my gut. I think we should have and be using such devices, if they could be made.

So I'm left curious if this FET behavior, RDS of Megaohms to kilo ohms between Vgs of 0 and 43mV is actually as unlikely as I believe. Practically, of course is different. But in theory I have yet to see any reason it could simply not be.

If your lab psu goes down to only 0.1uA, it looks like you can't get close enough to 40mV range to see what's happening, there. I suppose a DMM resistance test wouldn't be any better. At 10Mohm measuring limit, I suppose you end up with the same order of units... about down to a tenth of a uA range, if I am doing the math correctly.
« Last Edit: March 05, 2016, 10:39:42 pm by KL27x »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #74 on: March 05, 2016, 10:47:47 pm »
Oh, lookie. So it's definitely possible:

http://electronicdesign.com/analog/zero-threshold-fet-devices-run-unbiased-consume-microwatts

At least one way is to combine an enhancement mode with a depletion mode FET. That's technically two FETs, but it is still shedding a little more light.

The second sentence of the article also suggests that a regular FET doesn't go below 0.7V (which just happens to be drop of a silicon diode junction.... I have long suspected this could be more than a coincidence, but I have never made a rational connection).
« Last Edit: March 05, 2016, 11:33:29 pm by KL27x »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #75 on: March 05, 2016, 11:46:24 pm »
Ok, I have now completed my own missing jigsaw pieces.

Working on my earlier idea that the discrete distance of the barrier at the diode junction represents this minimum voltage of effectiveness:

Imagine a piece of thick cardboard is the barrier. And use two magnets on either side to represent the charge. There's a minimum strength of magnet where the attraction will be strong enough to effectively reach across this cardboard and be significant.

Now replace the cardboard with a sheet of paper. The minimum strength of the magnets will be less.

Silicon = carboard diode junction

Paper = germanium diode junction

And similar effect is happening in the gate of a FET; hence this lower voltage limit is set by material of diode junction. 0.7V not coincidence.

 :palm: Duh, basically gate is a diode. A diode junction has a discrete width. And minimum switching charge is due to attraction being dependent on inverse of distance squared. In order to have FET that switches at lower voltage would require a new material which makes a smaller gap. That's perhaps not completely correct, but it works good enough to me and it's not so complicated.

« Last Edit: March 06, 2016, 12:08:53 am by KL27x »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #76 on: March 06, 2016, 12:10:24 am »
In the case of a mosfet, it is more like a capacitor: the voltage applied on the gate opens / closes the channel of conduction between the drain and source.

In the case of a jfet, it can also be thought of as a capacitor - so long as the pn junction is reverse biased. That's why you should never forward bias the gate of a jfet.
================================
https://dannyelectronics.wordpress.com/
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #77 on: March 06, 2016, 12:13:49 am »
I think the possibility of new physics here is the most exciting part. Move over LHC...

...or...
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #78 on: March 06, 2016, 12:33:30 am »
Quote
In the case of a mosfet, it is more like a capacitor: the voltage applied on the gate opens / closes the channel of conduction between the drain and source.
Yes. I'm looking specifically at the dielectric barrier between this capacitor and what I forget the name for, let's call the channel. This meeting point is one of the diode boundaries I'm discussing.* And I'm trying to understand why the minimum voltage of this junction is 0.7V (or maybe it's not!), by necessity, before significant conduction can be achieved.

So the thickness of this barrier determines how far apart are the, say the positively charged plate of that gate capacitor and the semiconductor channel. And this is (I think) at least a very significant reason for the minimum voltage. (Although full saturation can be adjusted to however high you want via size/shape/distance/doping). This is (I think) possibly related to the VFD of an LED*. This is (I think) the reason for the minimum threshold for a FET. If you could metaphysically superimpose the two plates, you could reduce distance to nothing, and force of attraction between positive and negative charges would be infinite. But there is a discrete distance of the barrier, itself, and of the materials carrying those charges.

Stepping back one step.... the attraction is necessary to hold the electrons in the channel... so farther apart your positive gate cap plate from the channel the higher the charge before you can start packing the channel with conductors. And this attraction being dependent on inverse of distance squared, the closer you can put these charges and still keep them separate, the lower the threshold voltage where channel saturation may begin. Furthermore, the construction of these semiconductors and thickness of the dielectrics that can be "grown" on these dies are dependent on many things including the materials used. Which is why I brought up germanium and silicon diode junctions in my earlier post analogy. So apologies if I skipped a few steps.

Looking at the explanations for how a FET works, at least the basic searches I did, does not include this information how if/why there might be a minimum threshold. Yet article such as I linked suggests 0.7V min. Experience with FETs says it's same.

I suspect if I were to research how a diode works, and why it has a certain VFD, perhaps there are more clues.

*I know the diode boundary in a regular diode is different than a gate. Maybe I should leave that out. And perhaps I'm misusing the terminology of what a diode junction technically means (my understanding of the Art of Electronics is certainly not complete). I mean the boundary between two semiconductors, in this case between the gate capacitor and the semiconducting channel. I keep connecting the two because of the 0.7V thing, but perhaps a diode has 0.7V drop for a completely different reason and it's coincidence that this number is the same.

Maybe I'm just stating common knowledge. Or academic minutia which no one should bother to remember, or maybe even to learn in the first place.

Or maybe I'm inventing new physics, as another member so kindly suggests. If someone can help me to understand why (or even if ) FET needs about 0.7V min to switch? And if this is the case, is it a coincidence that this is the VFD of a silicon diode? I already asked with no one responding. So I have tried to figure this out myself.

Maybe this is a question for Jim Williams.



« Last Edit: March 06, 2016, 02:08:12 am by KL27x »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #79 on: March 06, 2016, 02:36:01 am »
"why (or even if ) FET needs about 0.7V min to switch in"

It doesn't: FETs can turn on over a wide range of voltage, from negative to positive. So you are really seeking an answer to a question that's invalid.
================================
https://dannyelectronics.wordpress.com/
 

Offline dadler

  • Supporter
  • ****
  • Posts: 851
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #80 on: March 06, 2016, 02:49:06 am »
Or maybe I'm inventing new physics, as another member so kindly suggests. If someone can help me to understand why (or even if ) FET needs about 0.7V min to switch? And if this is the case, is it a coincidence that this is the VFD of a silicon diode? I already asked with no one responding. So I have tried to figure this out myself.

Maybe this is a question for Jim Williams.

I was referring to the OP, not you  ;)
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #81 on: March 06, 2016, 03:12:22 am »
^Oh, thanks for clarifying. For the record, I am not prone to taking anything personally. I have been schooled by so many people on various forums, I can't remember half of them. I hope someone can do so, here, but at least end up explaining how this really goes.

Quote
It doesn't: FETs can turn on over a wide range of voltage, from negative to positive. So you are really seeking an answer to a question that's invalid.
Ok, this is the part I'm still not comfortable with the answer, due to my own observation of FET behavior and then reading this

http://electronicdesign.com/analog/zero-threshold-fet-devices-run-unbiased-consume-microwatts

... see the second sentence, in particular. And then also why the reason for having to combine two different FETS after carefully measuring their gate capacitance and going to a whole lot of trouble to get "a single" FET that switches at millivolt gate potential.

For some reason, I felt this was the case (see my previous post here, which I made before even finding this article):
Quote
but inherently it seems to be improbable that anything interesting can happen very much below the VFD [0.6-7V for silicon] of a diode junction?
I felt so strongly on this, I made a case as if this was fact. I later came up with other independent evidence that supported my case (and OP confirmed by backing out of a gentlemen's bet, lol), but I still do not know this initial assumption for fact, at all. Dannyf doesn't feel this is correct. I have a sort of hypothesis, but it is relying on too much air and wishful thinking.

I have just realized I haven't read the Art of Electronics in many years and it's not even on my shelf. I'm going to dig it out of the garage before I speculate too far on false assumptions.

*I'm flying well outside my comfort zone, here, and I'm fully prepared for egg-to-face. :)


« Last Edit: March 06, 2016, 04:21:25 am by KL27x »
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #82 on: March 06, 2016, 05:21:24 am »
Still have some reading to do.

But it is easy enough to verify DannyF is correct, and FETs come in threshold rated at various levels, with the lowest NFET listed by Mouser as 0.3V.* But it turns out Mouser is listing the the extreme spreads of the parts, and the maximum value of these same part looks to be anywhere from 0.8-1V, with max value of threshold of 1V being somewhat the most common. Lowest typical/average value I have seen actually listed so far is 0.55V. All these FETs have max Vgs of +-8V, which suggests they have ability to make dielectric in the pn junction thinner than in higher voltage FETs, facilitating this lower Vgs th. The high degree of manufacturing variance is perhaps reflecting fact that FETs have relatively large and/or complex PN junctions, compared to say a simple diode.

So while there's still no (single) NFET I can find that would conduct at all, at anything below 300mV, they go pretty low. As per my hunch, no lower than about 0.3V. And this does not seem to correlate in any precise way to the voltage drop of a silicon diode as oft cited, anyway, at .6-.7V. OTOH, Vfd of actual silicon diodes vary a lot, too, often listed as below 0.3V to over 1.2V, and also depending on current of course. A diode is just a single, simple PN junction, and the lowest max voltage and tiny current-rated Shottky with the minimum voltage drop available might be an example of a minimum possible voltage saturating PN junction currently possible to economically manufacture, today?

Anyhow, it appears (to me) that most semiconductors can't operate at any much under 0.3V. Other than some oddballs like the combo matched pair FET. Until some new materials process is created or some other discovery is made.

And indeed an NFET that has Vgs th of under 50mV would appear to be a unicorn (even simply judging from what's currently available, since I still have no proof that I understand the first thing I'm talking about.)

Regarding "crap" parts or manufacturer, I might wonder if a good European manufacturer could even do on purpose what it is I think the other guy can apparently achieve on accident. By cutting corners.

*One FET is listed at Vgs th of 0.2V. It's the hybrid FET from the article.:

http://www.mouser.com/ds/2/8/ALD212900-225961.pdf
« Last Edit: March 06, 2016, 10:41:14 am by KL27x »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #83 on: March 06, 2016, 02:06:43 pm »
Quote
while there's still no (single) NFET I can find that would conduct at all, at anything below 300mV

Pretty much all jfet works under negative Vgs.

Depletion mosfets are rare but not non-existent: type "depletion mosfet" on digikey and you will find quite a few of them.
================================
https://dannyelectronics.wordpress.com/
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #84 on: March 06, 2016, 02:11:23 pm »
Some people seem to be under the impression that a depletion-mode FET is a fundamentally different thing, and that when considering the function of enhancement-mode FETs they should be ignoring the former. This is not the case - the two are identical, except that the Id(Vgs) curve is shifted to the left or right by the doping configuration. "Enhancement" and "depletion" are somewhat artificial distinctions meaning "threshold is positive" or "threshold is negative" (keep in mind the exact point called the 'threshold' is somewhat arbitrary); FETs can be had that are in between the two as well, where Vgs=0 causes small but non-negligible current, not quite "fully on" but not quite "fully off" either. (Ask Advanced Linear Devices for those.)
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #85 on: March 06, 2016, 04:19:20 pm »
^Yes, this is my thought, exactly. So what if the depletion mode switches negative. It does so at minimum potential of 0.3mV, just like enhancement mode FET. Add a negative sign if you like.

I mentioned the case of these ALD combo enhancement-depletion, matched pair, zero-switching FETs and even linked the datasheet. This seems to have been invented in 1997.

As for JFET, I will save this for a future study, if Danny persists to object. I have no practical experience with. But quick google says JFET VGS(off) varies from -0.3V to -10V. There's that magic number, again. JFET is made from a PN diode junction like any other semiconductor. The only difference is shape and wiring of this junction. Of course, the maximum value of saturation can be as high as you want to make it. What I'm saying is there's a practical minimum. This partly being due to the fact that force of attraction between charges is proportional to V/d^2. Below this voltage, you will not find a silicon PN junction to develop any detectable/functional depletion zone.

edit: The way I imagine it, take your PN sandwich. You can add electrons to one half and/or remove them from the other half, creating a voltage/potential. Until this voltage reaches critical mass, those extra charged particles you added/removed are just going to be dispersed throughout their half of the sandwich, randomly. Nothing has happened, yet. You just primed the pump.

When "critical mass" is achieved is when the potential is large enough for these charged particles to effect each other. They will start to pile up against this PN boundary across from each other, creating a depletion zone (if I'm using the terminology correctly). This is where things start to get interesting. And I contend that "critical mass" can be made as high as you like, but can only be practically reduced to ~0.3V.
« Last Edit: March 06, 2016, 05:13:00 pm by KL27x »
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #86 on: March 06, 2016, 04:23:46 pm »
I think well before 1997, but I'm not sure. I distinctly remember working on a device designed in the early 80s that had a signal FET listed as "enhancement-depletion" mode, but I wasn't able to find any real data on it, it was an obscure little bugger. Made sense in the circuit it was in that it had a roughly 0V threshold, though.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline KL27x

  • Super Contributor
  • ***
  • Posts: 4099
  • Country: us
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #87 on: March 06, 2016, 04:30:01 pm »
If you say this, I believe you over my other "source." I'm just going by a journal article. And just because ALD started MARKETING it in 1997, and this journal is CLAIMING it is new, it doesn't mean it wasn't around for decades. Possibly ALD invented a way to improve it and/or to make it cheaper, is all. My mistake.

http://electronicdesign.com/analog/zero-threshold-fet-devices-run-unbiased-consume-microwatts
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: WTF!? Atmega328P vs 2N7002F - fails to turn off!
« Reply #88 on: March 06, 2016, 05:13:01 pm »
Nah - ALD did invent something new. Specifically the "EPAD" (Electrically Programmable Analog Device) technology, described here - they have a neat way to trim the characteristics electronically to ensure good yield, which is pretty cool. I suspect this device from the 80s, which was in a very expensive voltage standard anyway, was the sort of thing that's "made" by binning a large number of devices until you find the 0.1% that behave the way you want :)
« Last Edit: March 06, 2016, 05:17:24 pm by c4757p »
No longer active here - try the IRC channel if you just can't be without me :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf