EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: denemetor on June 25, 2016, 02:38:12 am
-
Hi all,
I have recently started playing with Arduino and am hoping to learn a little bit about electronics. I have no formal background in electronics so if I sound clueless to you, that is probably why.
To learn about transistors and relays, I have decided to build a simple thermostat. I'm using a temperature sensor and an ADC chip to read the values from the sensor. That part of the circuit is complete. When ambient temperature drops below the set point, I would like to be able to energize the coil of the relay and turn on the heating element. For this purpose, I am using the parts below:
- 2N7000 transistor - Datasheet (.pdf) (https://www.fairchildsemi.com/datasheets/2N/2N7000.pdf)
- 1N4007 diode - Datasheet (.pdf) (https://www.fairchildsemi.com/datasheets/1N/1N4007.pdf)
- JZC-11F relay - Datasheet (.pdf) (https://www.sparkfun.com/datasheets/Components/General/JZC-11F-05VDC-1Z%20EN.pdf)
I haven't selected this parts purposefully. They are just what I have at the moment.
Here is the sketch of the circuit:
(http://i.imgur.com/CeS3Sbp.jpg)
The problem is that this setup does not work. When I alter the state of the pin of the Arduino, I don't hear the relay clicking. I have tried the relay just by applying 5V to coil and it works. I have also confirmed that the transistor works fine simply by connecting to a LED. Any suggestions? What am I doing wrong? Thanks for your time.
-
I would say check that you dont have source and drain flipped, and that your arduino is outputting greater than 3V, (the gate threshold voltage)
-
There is always some voltage drop between drain and source, see datasheet page 2. See also the Rds (on) which is a bit high for this mosfet, at around 2 ohms
The relay seems to be with 12v coil but has pick-up at 9v... it says minimum 5v 10mA to work but I'm not sure, you say it works if you use 5v directly. The voltage drop through the mosfet may be enough to lower the voltage the relay sees thereby not triggering it.
And yeah, see gate threshold voltage, you need at least 2v but safe voltages would be above 3v.
-
OK that relay is not suited, it needs atleast 9V to latch on, then can be sustained all the way down to 0.6V so your 5V source can never pull it on,
The point about a 5V 10mA load is refering to what you connect across the contacts of the coil, there needs to be a certain amount of "wetting current" to ensure the contacts don't degrade
-
Thanks for your answers.
I have checked that the source and drain are connected correctly. I have also confirmed that the Arduino pin output (digital high) is 5V by measuring it myself. I have tried 9.8V to trigger the relay instead of 5V but it still does not work.
-
What is the voltage at the gate and drain of the 2N7000 for each of the two states of your device?
I'm also suspicious about the relay's rated 9 V pickup voltage, but you said it activates with only 5 volts, so it must be something else.
-
Maybe you installed the diode the other way around :) ?
Measure the voltages on the MOSFET Gate + Drain when the Arduino is outputting 0 and 1 and post the results here.
-
Here are the voltages on the gate and drain with two different supply voltages to the relay.
| Pin state - | 5V supply - | 9V supply |
| Low | 4.53 | 8.39 |
| High | 0.00 | 3.57 |
-
Here are the voltages on the gate and drain with two different supply voltages to the relay.
I don't really understand which voltage is which O.o
Perhaps fill in this table:
| Pin state | | 5V supply - Gate | | | 9V supply - Gate | | | 5V supply - Drain | | | 9V supply - Drain | |
| Low | = | = | = | = |
| High | = | = | = | = |
-
I'm using a temperature sensor and an ADC chip to read the values from the sensor.
Just a side note that the Arduino has ADC pins to read analog signals. You may need to scale the sensor's output to utilize the full range of the ADC.
-
My bad, sorry. I thought you were asking the voltage between drain and gate.
| Pin state | | 5V supply - Gate | | | 9V supply - Gate | | | 5V supply - Drain | | | 9V supply - Drain | |
| Low | 0.14 | 0.19 | 4.67 | 8.53 |
| High | 5.01 | 5.16 | 4.98 | 8.70 |
Just a side note that the Arduino has ADC pins to read analog signals. You may need to scale the sensor's output to utilize the full range of the ADC.
Thanks. Arduino's ADC is 10 bit, which is more than enough for me but I wanted to play with 3201-C (12 bit) just to see how it is connected to a circuit (SPI serial interface).
-
so in otherwords the mosfet is doing nothing, check the datasheet that you have it wired correctly,
-
When I remove the relay and placed a LED it starts blinking and the drain voltage changes between 2.4V and 5V. Does this mean that the MOSFET is wired correctly?
-
My bad, sorry. I thought you were asking the voltage between drain and gate.
OK, seems like the MOSFET is damaged / wired incorrectly. But in that case, replacing the relay with an LED shouldn't work either.
Can you replace just the relay with the LED + resistor, leave the diode in place, and re-populate the table ? See if the LED lights up.
If the LED works the next step would be to put the relay in parallel with the LED + resistor.
How were you hooking up the LED when it lit up, what resistor were you using, what supply voltage and was the diode there ?
-
not really, better to use a resistor e.g. 100-1000 ohm (quarter watt resistor), LED's can turn on with extremely tiny currents, and in a dark workshop most people can see LED's illuminated at 1-2 uA.
Equally i would see about measuring the resistance of your relay coil, just to make sure its not open circuit or something silly,
-
Thanks. Arduino's ADC is 10 bit, which is more than enough for me but I wanted to play with 3201-C (12 bit) just to see how it is connected to a circuit (SPI serial interface).
Sounds good. :-+
-
The 2n7000 is not well-suited to this application. With 5V to the Gate it will just barely be turning on, still in the linear operation region, and its Drain-Source resistance will be high. Even when fully On the resistance could be as high as 5 ohms. This might work OK driving an LED from a 5 volt supply (and might not even need a current-limiting resistor for the LED!) but trying to drive a 12 volt relay from a 5 volt supply, through a partially on 2n7000, is not going to work. It might work with the 9 volt supply but the measurements seem to show that it is not working even then.
Let's be sure we know what we are measuring here. The voltage on the mosfet Drain pin should be measured with reference to the Source pin. This voltage should be near the relay coil supply voltage when the mosfet is OFF and should drop quite a bit when the mosfet is ON -- if the relay coil has continuity, etc. The measurements with the 9V supply seem to show that this isn't happening.
So something is wrong somewhere. It's possible that the 2n7000 is not working properly for some reason. (fake? blown? not connected properly?) It is possible that the parallel diode is backwards, shorting out the relay coil. It is possible that the 2n7000 is just one of those that doesn't turn on well at 5 volts to the gate, and is operating in the linear region enough to turn the LED on (with no dropping resistor!) but can't pass enough current, even with the 9v supply, to actuate the relay.
Can we see a photograph of the setup (presumably on a breadboard?)
-
My bad, sorry. I thought you were asking the voltage between drain and gate.
| Pin state | | 5V supply - Gate | | | 9V supply - Gate | | | 5V supply - Drain | | | 9V supply - Drain | |
| Low | 0.14 | 0.19 | 4.67 | 8.53 |
| High | 5.01 | 5.16 | 4.98 | 8.70 |
Just a side note that the Arduino has ADC pins to read analog signals. You may need to scale the sensor's output to utilize the full range of the ADC.
Thanks. Arduino's ADC is 10 bit, which is more than enough for me but I wanted to play with 3201-C (12 bit) just to see how it is connected to a circuit (SPI serial interface).
Note that when the Pin State is HIGH, the mosfet Drain voltage is _higher_ than when the Pin State is LOW. This is exactly opposite of what it should be. When the mosfet is ON (gate drive pin state HIGH) the Drain-Source voltage should be _lower_, in fact it should be quite a bit lower than when the mosfet is OFF (gate drive pin state LOW).
So something is very wrong somewhere.
-
Can you replace just the relay with the LED + resistor, leave the diode in place, and re-populate the table ? See if the LED lights up.
Supply: 5V, LED + 330 ohm resistor, no diode, no relay:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 1.6V, gate 0V, LED: on.
Supply: 5V, LED + 330 ohm resistor is in parallel with the diode, no relay:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 1.6V, gate: 0V, LED: on.
Supply 5V, LED + 330 ohm resistor is in parallel with the relay, no diode:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 3.2V, gate: 0.1V, LED: off.
Equally i would see about measuring the resistance of your relay coil, just to make sure its not open circuit or something silly,
Resistance of the relay coil: 55 ohm.
I am really confused. I have double checked the datasheet for the MOSFET and it is wired correctly.
@alsetalokin4017, I'll upload a photo of the setup in half an hour. Let me try to supply 9V to the gate.
-
Just to make sure, here is the pinout :
http://www.muzique.com/news/images/2N7000.gif (http://www.muzique.com/news/images/2N7000.gif)
It does seem that the MOSFET is damaged, the LED is on when the gate is low, exactly opposite to how it's suppose to be.
Supplying 9v to the gate won't do much different, the difference between 5v and 9v is very tiny for this MOSFET.
Are you sure you've got a 2n7000 ? What is the marking, do you have another N-CH mosfet to swap with it ?
-
Here's a link to the breadboard photo. http://i.imgur.com/13hJ5m0.jpg (http://i.imgur.com/13hJ5m0.jpg)
Just to make sure, here is the pinout :
http://www.muzique.com/news/images/2N7000.gif (http://www.muzique.com/news/images/2N7000.gif)
It does seem that the MOSFET is damaged, the LED is on when the gate is low, exactly opposite to how it's suppose to be.
Supplying 9v to the gate won't do much different, the difference between 5v and 9v is very tiny for this MOSFET.
Are you sure you've got a 2n7000 ? What is the marking, do you have another N-CH mosfet to swap with it ?
Maybe I somehow damaged the MOSFET. It is the only one I have at the moment but I will definitely try with some other transistors Monday morning. The exact marking on it is "2N7000 - E20".
-
Maybe I somehow damaged the MOSFET. It is the only one I have at the moment but I will definitely try with some other transistors Monday morning. The exact marking on it is "2N7000 - E20".
Since it appears you have a DMM, you can easily check if MOSFET works:
https://m.youtube.com/watch?v=gloikp9t2dA (https://m.youtube.com/watch?v=gloikp9t2dA)
-
Thanks for your answers.
I have checked that the source and drain are connected correctly. I have also confirmed that the Arduino pin output (digital high) is 5V by measuring it myself. I have tried 9.8V to trigger the relay instead of 5V but it still does not work.
have you checked if the relay can be turned on if directly connect to 9V (not controlled by MOSFET but by a DC voltage)?
-
Can you replace just the relay with the LED + resistor, leave the diode in place, and re-populate the table ? See if the LED lights up.
Supply: 5V, LED + 330 ohm resistor, no diode, no relay:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 1.6V, gate 0V, LED: on.
Supply: 5V, LED + 330 ohm resistor is in parallel with the diode, no relay:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 1.6V, gate: 0V, LED: on.
Supply 5V, LED + 330 ohm resistor is in parallel with the relay, no diode:
Pin state: high, drain: 5V, gate: 5V, LED: off.
Pin state: low, drain: 3.2V, gate: 0.1V, LED: off.
These data would seem to indicate that the component is acting like a PNP transistor, rather than an N-channel mosfet.
With any N-channel mosfet the LED should be ON when the Gate voltage is HIGH, and the LED should be OFF when the Gate voltage is LOW.
At this point -- always presuming your measurements are correct -- I think you may have a non-genuine or mislabelled 2n7000.
Equally i would see about measuring the resistance of your relay coil, just to make sure its not open circuit or something silly,
Resistance of the relay coil: 55 ohm.
I am really confused. I have double checked the datasheet for the MOSFET and it is wired correctly.
Yes, from what I can see on your breadboard photo, the item is correctly connected IF it is indeed actually a 2n7000.
@alsetalokin4017, I'll upload a photo of the setup in half an hour. Let me try to supply 9V to the gate.
According to the data sheet you posted for the 12 volt relay, the coil resistance should be 320 ohms.
Don't attempt to supply 9V to the transistor Gate while your Arduino Pin 7 is still connected !!
Could you also please post your Arduino code so we can check it for anything that could be wrong there. Although if you are getting Pin 7 to go from +5 to 0 and back again as expected it's hard to imagine anything wrong in the code that could be causing the problem. But post it anyhow, please.