31 Replies Latest reply on Apr 12, 2016 10:56 PM by clem57

    2N7000 as VCR

    tibmeister

      Ok, so going to start off by stating the issue I am facing, Q1 (2N7000) is getting hot enough to cook with.  Seriously, I'm measuring 50C on the sucker.  What I can't figure out is why.  Now I will state, I am far from an engineer, I am easily classified as a noob.

       

      Anyway, I have attached my schematic.  The sensor has a resistive heater that is driven by Q1 on the HA pin, and the trick is it has to cycle between +5VDC and +1.4VDC at regular intervals.  So since I am using an ATTiny85 (I love these little guys!) I'm looking at max Vout on the IO pin of +4.85VDC @ ~20mA.  So, I came up with using the LM324 as a small amp to bring my IO up to a full +5VDC and then as a buffer to ensure that even as I put load on Q1 Source I will maintain the desired voltage at the sensor's HA pin.  This may not be the best way to do this, but like I said, noob here.

       

      So, if my calculations are correct, G1 of the LM324 should represent about a 10% amplification of Vin.  So at most I'm pushing something in the neighborhood of +5.5VDC into V+ of the LM324 G2, which should be well within specs.  As far as Q1, since I'm using it as a voltage controlled resistor I'm not running Q1 into saturation, which I don't think is bad but I'm almost wondering if my heat issue is coming from the fact that on the drain of Q1 I have +12V and on the source I have +1.4-5VDC, so that's a lot of Vdrop which I'm sure turns into wattage and dissipated heat.

       

      I am struggling with this one and hoping someone could get my head straight on it.  Oh and yes, I have a lot of filtering caps and zener diodes for over-voltage protection.  It's cheap insurance in my mind having the zeners, and the caps, well it can't hurt to filter out any in-rush current .

        • Re: 2N7000 as VCR
          peteroakes

          The FET is going to follow the OPAMP output -~4V with a threshold of about 2V (the V difference between gate and source where it starts to turn on)

           

          If the FET was to be turned fully on then you have a resistor divider between the 220 and 33 resistor so the max that will be output is about 1.5V as the resistance of the FET is negligable so you will never get the full 5V no matter what you do, perhaps switching around the 33 and 220

           

          what is the resistance of the heater ??

           

          with regard to the buffer opamp, it will try to get its - input the same as the + so if you have 5V on the +, the output should try to go to about 7-9V depending on the load (AKA the 33ohm + Heater), the 220ohm will severely limit the current flow which is why it wont ever get to the desired voltage and the opamp will or should be going to the + rail (12V)

           

          if the fet is hard on then your current will be about 50mA without the heater connected but even if it is connected it will never exceed 68mA due to the 220 Ohm  (Remember I=V/R)

           

          If you tell me / the community what the heater needs then I can tell you what resistor values you need

           

          Last question, how are you planning on getting the 5V and 1.5V outputs, the current design will only give one volt setting. not two

           

          Ok, regarding the heat, 50mA at 12V is 576mW which if this was across the FET it would be at its limit but in the schematic you show, all the volts will be dropped across the 220ohm resistor so it will be or should be getting hot, not the FET.

           

          like I said, swap the 220 and 33 ohm resistors, it should work much better (This is without knowing your real load parameters), with this design you could also remove the 220 altogether and connect the top of the fet directly to 12V, I would still put a 220 or more instead of the 33 Ohm though.

           

          Hope this helps for now, provide the feedback and I can help more

          1 of 1 people found this helpful
          • Re: 2N7000 as VCR
            michaelkellett

            I'll add a couple of points to Peter's comments:

             

            1) this configuration of a FET is usually described as a  source follower, as Peter describes in his first paragraph.

             

            2) when you put a buffer (the FET in your case) on the output of an op amp and inside the feedback loop it will very often be unstable. The solution is often to put a resistor between the output of the buffer (FET source in your case) and the op amp -ve input, and a small capacitor from the op amp output to the op amp -ve input. Adding a resistor between the FET gate and the op amp will often make basic stability worse but may be needed to stop HF oscillation with some FETs and op amps. If you are laying out a pcb add all three extra parts, then all your options are open !

             

            3) download a cop of LT Spice  from Linear Technology's website -it's free and it's much quicker to resolve some of these issues in simulation.

             

            4) If you are pulse width modulating PB1 you will need a capacitor from the op amp end of R3 to ground - and be careful of noise.

             

            MK

              • Re: 2N7000 as VCR
                tibmeister

                Peter/Michael, you do not see the 220 on the drain, it doesn't exist... (Jedi hand wave)  I don't know how that little guy stayed on the schematic but it doesn't exist on the breadboard after it smoked out.  I realized my mistake and omitted it.

                 

                The heater is 33 ohm, so around 120 mA is what I'm looking at for that guy.  What I suspected was the FET pretty much had no resistance and when there was no sensor heater and no 33 ohm resistor I could bake brownies on the ATTiny85, even setting one on fire by not paying attention (silicon and marshmallows DO NOT MIX!).  So I added the 33 ohm to provide the same load that the heater would while I was probing everything and decided to leave it in there in case the heater ever decided to fail and create an open circuit there, I wouldn't start melting and smoking things again.  My suspicion is that without the resistance on the output I don't have any current limiting going on and the ATTiny pays the price because the opamps and FET don't offer any resistance.

                 

                The way I'm getting the two voltages is by driving PWM to the G1 V+ pin, 25% duty cycle for 1.4V out and 92% duty cycle for the 5V output.  So the amp is there because at most I could push from the ATTiny is 4.9V, which would not turn the FET on enough to allow for 5V to go through so I put the amp in there with about a 10% amplification to compensate.

                 

                The buffer is there becasue I noticed the FET would not stay stable and would sometimes go a little crazy, even hitting 6V on the Source, so I am using the buffer to make sure that my FET stays where I want it.  It's kinda like a comparator I guess.

                 

                I was wondering if a lot of my issue is HF noise on the PWM line being transmitted through to the FET and causing my issues, was thinking about a .1 uF ceramic on there to ground to filter those frequencies out, which the ATTiny85 lowest PWM frequency is 20 kHz.

                 

                I was thinking about the resistor from the source of the FET to V- on the opamp but wasn't sure what it would do and what resistance I should put in there.  The cap between Vout and V- of the opamp is brilliant, is that to act as a HF filter?  So would .22 uF or .1 uF be appropriate?

                 

                I do want to add, outside of the FET wanting to try and go nova everything in the circuit is working how I planned it would; the FET is able to switch between 1.4V and 5V, and all that jazz.  honestly I'm suprised I only got it on the third try, and the first try with the opamps.  I tried one with two mosfets, one in an inverted fashion and that did nothing, and I tried to drive the FET directly with PWM and ya know, that kinda just sucked.

                1 of 1 people found this helpful
                  • Re: 2N7000 as VCR
                    peteroakes

                    so if only a 33 ohm in circuit then there will be 363mA flowing, and that's about 4.4W of total power , now if your using PWM and limiting the output through the feedback of the opamp to 5V then your left with 7V @ 363mA dissipated in the FET, thats 2.5W, the device is only rated at 200mW so i'm surprised it is even surviving, double all these figures if you have the heater and the 33 ohm

                     

                    put the heater between the 5V and the fet drain, connect the source to gnd, and drive the FET directly from the uController

                     

                    It should turn on completely in this configuration and as such will not dissipate much heat and the max volts is still 5, then use PWM to simulate the 1.x volts you need

                     

                    In your current design, your using the FET in its linear region and trying to get rid of way too much heat

                    1 of 1 people found this helpful
                      • Re: 2N7000 as VCR
                        billpenner

                        Re: 2N7000 as VCR

                         

                        Absolutely. Make it as simple as possible. I too am surprised that the FET didn't let out it's magic pixie smoke  right away. Another idea might be to use an adjustable Switching Mode Power Supply (SMPS) and just control the voltage output with the Arduino and  resistive divider. Way less power wasted and simpler. I do have to say I love the little 2n7002. I have use many of them.

                        • Re: 2N7000 as VCR
                          tibmeister

                          I guess I could replace the 2N7000 with a FQP9N08, don't think that guy would have an issue!  On a serious note, I'm going to layout what my interpretation of the suggestion is and hope I'm on the mark.

                           

                          One thing I've been thinking, I want this to be battery powered and having 8 AA's in a case is a lot of weight, so I'm pondering getting rid of the LM7805 and replacing the 12VDC with 6VDC.  I have used the MCP1253 from Microchip in past items and I friggen love the guy but it's able to only handle 150 mA at the most so it may be a good drop-in replacement for the LM7805 to power the ATTiny85 with and run the sensor/heater off the battery directly.  I would have to definitely see what the amperage of the circuit as a whole is to make sure batteries will last for a while.

                           

                          Anyway I'm gonna focus on getting the thing working as is and figure out the portable items later and use my MCP1253 on it's breakout board after things are working at 12V.

                            • Re: 2N7000 as VCR
                              tibmeister

                              Ok, so here the Version 4 of the design with the new configurations and elements.  I'm gonna breadboard it tomorrow and see what happens.Version4.png

                                • Re: 2N7000 as VCR
                                  peteroakes

                                  Sensor Heater HA to +5V

                                  Sensor heater HB to Mosfet Drain (Top Side)

                                  NO 220Ohm resistor

                                   

                                  Assuming this is a valid configuration for the actual heater sensor

                                   

                                  what is the part number for the sensor so I can check or you can

                                    • Re: 2N7000 as VCR
                                      tibmeister

                                      I'm using the MQ series of sensors, the MQ-9 to be specific (https://www.pololu.com/file/download/MQ9.pdf?file_id=0J314).  I won't be able to connect the sensor to the +5V line directly because I'm limited to 120 mA on that line, but what if I put the opamp buffer/voltage follower back in with a zener diode on the V+ line so it can't go above +5V then make sure the two resistors are equal at 220k ohm.  Just a thought...

                                      • Re: 2N7000 as VCR
                                        tibmeister

                                        Still working on this, had some stuff to deal with but didn't want to make anyone think I was blowing them off.

                                          • Re: 2N7000 as VCR
                                            tibmeister

                                            Alright, here is the updated schematic.  Hope I got it right and don't let the smoke out this weekend...

                                            Version4-1.png

                                              • Re: 2N7000 as VCR
                                                michaelkellett

                                                Looking at your circuit I can't see how you get the 5V drive.

                                                The sensor data sheet is far from comprehensive but I think that you need proper voltage drive on the heater, driving through a resistor may not work very well. You have a 100R resistor in series with 6V so you will see about 1.42 V across the heater (nominal 31R at room temp). The heater won't get hot enough for the sensor to work.

                                                The idea is that you measure the resistance of the sensor with different heater voltages to sense different gases.

                                                If you are only going to drive the heater at 1.5V you would do better to use a 1.5V regulator with an enable line, if you use a switching buck regulator it will be much more efficient.

                                                 

                                                 

                                                MK

                                                  • Re: 2N7000 as VCR
                                                    peteroakes

                                                    michaelkellett is absolutely right about that 100R resistor. with no resistor you will get 6V but with a little PWM it would appear as 5. then with more PWM you can get the 1.5

                                                     

                                                    Now taking your design with and keeping the 100R, if you had a separate FET to a second output on the controller with a much smaller resistor this time (Put the resistors on the fet side of the heater. when one fet is on, you get the 1.5V across the heater, when the other FET is on, you get the full 5V. (Use a 5Ohm ish resistor to drop the 1V needed from the 6V supply... do the math to calculate the right value). with this approach, you dont need to worry about PWM

                                  • Re: 2N7000 as VCR
                                    D_Hersey

                                    Using a power fet as a heater is not that great of an idea in practice as a warm fet has lowered Zin with low gain Switching resistors is a better idea as they are made to be heaters a bipolar Q cheap and basic like a  2N30552N3055 makes a better choice positive(conductance tempco

                                    1 of 1 people found this helpful
                                    • Re: 2N7000 as VCR
                                      tibmeister

                                      Alright, taking everyone's comments and suggestions and applying them I cam up with the attached circuit that actually works the way I anticipate it!  The most difficult process is how to say who was right because everyone was in this case and little elements of each response is in this circuit.

                                       

                                      One thing I am going to do is use PIN0/ADC0 (Reset Pin/Pin 1 on die) as an analog input and hook it between the sensor's HB and the 2N7000 so I can monitor the voltage drop and adjust the PWM accordingly and when I can't maintain +5V then signal a low voltage alarm.  Since the circuit as a whole only draws 240mA I'm hoping that 4 AA batteries will power this little guy for some time.

                                       

                                      Now one thing I noticed when probing everything is that when my multi-meter is referenced to ground and I probe between the sensor's HB and the 2N7000 I get the voltage drop, not the voltage itself.  Not sure why I am seeing it like that and would love to understand that part of it.

                                       

                                      So now it's time to start testing this guy out and see how stable it is and get the code locked in.  Then time to make some choices and get it on a perf board, then I can start thinking about PCB fab prototyping.

                                       

                                      Version4-2.png

                                        • Re: 2N7000 as VCR
                                          peteroakes

                                          your using the FET as  switch, not a linear device, so think of it as a mechanical switch, it is either open or effectively a short (A few milliohms anyway) so you wont be able to use the ADC to measure the voltage reliably, what you could do is measure the supply voltage and then derive a pulse width to give you the 1.5 or 5 volts

                                          1 of 1 people found this helpful
                                            • Re: 2N7000 as VCR
                                              tibmeister

                                              Thought about that but I wouldn't be able to account for any variance in the supply voltage and make real-time adjustments.  One thing I did notice when probing between HB and the drain of the 2N7000 was that when I was on the high duty cycle I was reading about .0951V and on the lower duty cycle I was reading 4.25V.  It struck me that if I subtract those from the 6V supply then I am seeing the voltage of the sensor's heater, or rather the voltage differential between the supply and the heater.

                                              Are my observations correct?  If so then my plan is to measure for that voltage, keeping it around 1V on the high duty cycle to provide 5V to the heater, and 4.4V on the low duty cycle to provide 1.6V to the heater.  Man I hope I'm on the right track!

                                                • Re: 2N7000 as VCR
                                                  peteroakes

                                                  If your measuring with a DMM then it may not be accurate as (Depending on the DMM) it may not be correctly interpreting the PWM based voltage

                                                   

                                                  You can however correctly measure the supply voltage, you may need a resistor divider for the Heater and supply it it is relatively simple

                                                   

                                                  Using the internal Band Gap reference voltage instead of the supply (1.1V vs maybe 5 ish volts and also provides more accuracy) and hooking up one analog input to the supply via a divider, same for the Sensor Voltage you can adapt the PWM with some simple math. right now as your using the Supply to the ATTiny as the VREF is is going to drift around anyway, this will make the measurements more stable and therefor accurate. You can adjust any inaccuracies in the resistors using software

                                                  2 of 2 people found this helpful
                                                    • Re: 2N7000 as VCR
                                                      tibmeister

                                                      I will break out the oscope and check it out to see what is moving through the circuit.

                                                        • Re: 2N7000 as VCR
                                                          tibmeister

                                                          Ok, so here's the screen shots of the scope at the drain of the FET.  The first one is at 10% duty cycle and the second one is at 88% duty cycle.  I am at a loss to try and figure out how to monitor the voltage going to the heater, I can feel the heater temp going up and then back down, so that's something but I don't know if I'm in the correct temp range though.

                                                           

                                                          Now, as this seems that this is a working VCR that I am controlling through a uMC I now have to figure out how to select the "correct" answer because I think there's been such awesome contributions that all the answers led to the correct solution

                                                           

                                                          Drain-Low.png

                                                          Drain-High.png

                                                            • Re: 2N7000 as VCR
                                                              peteroakes

                                                              Not sure why there is 320mV offset when the fet is on but lets assume it is just the high (Relative) resistance of the fet and its the same for both, so we know the peak volts (6.08V) and it clearly shows the delta which is the volts across the heater (5.76V), this is not the average but the actual change from off to full on for the FET. so to get the desired voltage of 5V you need 5/5.76 * 100 duty cycle so about 87%, to get an average of about 1.4V you will need 1.4/5.76*100= 24%

                                                               

                                                              so all you really need to know is how many volts are applied tot he heater when the FET is on, then what percentage of that as a duty cycle is needed to make the average = what you need. Simple once you know , no need to measure, just calculate.

                                                               

                                                              Now if you change the FET or the 6V supply then you may need to re-calculate the constants but this keeps it simple.

                                                               

                                                              You could use a calibration sub routine to turn on the FET for an instance, measure the volts across the heater, then use that to calculate the duty cycle automatically but that's down to you and how complicated you need this to be

                                                               

                                                              Have fun and I hope you learned plenty so far. Sorry I did not just give you the answer but I bet you agree you learned a lot over the last week or two

                                                               

                                                              Peter

                                                                • Re: 2N7000 as VCR
                                                                  tibmeister

                                                                  Are you kidding, I've actually begun to understand this stuff much more than I thought I would and that alone is priceless.

                                                                   

                                                                  As for the offset, Rds(on) is 5.3 ohm and the current drain from source to drain is 70mA so that's pretty dang close to the voltage drop observed considering I'm not fully on at the gate.

                                                                   

                                                                  So you confirmed my other theory which is to use the desired voltage / Vcc then take that and multiply by 255, or 100% duty cycle to determine the analogWrite value I need and just on that hunch I came up with the same numbers! 

                                                                   

                                                                  So absolutely, I didn't come here to be spoon fed but rather to learn and that I can say I did in spades.

                                                                   

                                                                  So so now armed with the MOSFET VCR knowledge and finding the bug in my code I am armed to bear And with the understanding I've gathered I can repeat this and pass the knowledge on as well.

                                                                • Re: 2N7000 as VCR
                                                                  mudz

                                                                  Though, I didn't took part in the thread as this topic was new to me but I was following it right from the start, and I learnt a lot from this thread.
                                                                  On the part of marking answer correct, You can make a new comment answering your original questions asnwer for youself and mark it as correct answer. Also, don't forget to mention members name & their post numbers who helped you throughtout your journey. Better mention who helped you on what(if you have time). Doing so will be helpful for someone who is looking for the help on similar topic in future.
                                                                  Moreover, you can hit Helpful tab for each comment you think helped you.

                                                                   

                                                                  mudz

                                                      • Re: 2N7000 as VCR
                                                        tibmeister

                                                        First off, sorry about being away from this thread for a few weeks; life and a new job pulled me away along with my other project, damned power supplies!

                                                         

                                                        Anyhew, mudz, thanks for the input; I will go back through the thread and do just that if everyone's ok with that.  I've gotten used to everyone on Experts Exchange being a turd in regards to answers that I am gunshy.

                                                         

                                                        As for the circuit, electrically it works like a wet dream I just need to get the math correct.  Once I get that locked down I am going to replace the ATTiny85 with an ESP-12E and publish that data to both the onboard LCD and using MQTT to ingest using OpenHAB.  I plan to build several of these little guys and place them around the house and with the ESP-12E having more GPIO I am going to add a DHT-11 to the mix as well and maybe a light sensor.

                                                         

                                                        The end goal is to have a couple of these throughout the house and tie into OpenHAB which will have a controller that will replace my thermostat.  If there's CO detected and the heater is running, the heater will be shut off, the fan turned on and an alert sent.  If the heater isn't running, then just the fan and alert.  My own Nest at a fraction of the cost with added sensors is the end goal of all of this.

                                                         

                                                        Anyhew, in advance this was a great thread and I learned soo much that I can't thank everyone enough!  I will spend some time tonight going back through the thread and do as mudz suggested.