Having trouble in GPIO output, 220 V to 5 V signal
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I'm not an electric guy, I'm just trying to build a small circuit to sense 220 V with my Microcontroller (RPi). But I'm getting either 5 V or 1.3 V on a GPIO wire.
I can't understand the problem. I want 0 V or 5 V on GPIO.
sensor ac gpio 5v
add a comment |Â
up vote
3
down vote
favorite
I'm not an electric guy, I'm just trying to build a small circuit to sense 220 V with my Microcontroller (RPi). But I'm getting either 5 V or 1.3 V on a GPIO wire.
I can't understand the problem. I want 0 V or 5 V on GPIO.
sensor ac gpio 5v
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
1
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm not an electric guy, I'm just trying to build a small circuit to sense 220 V with my Microcontroller (RPi). But I'm getting either 5 V or 1.3 V on a GPIO wire.
I can't understand the problem. I want 0 V or 5 V on GPIO.
sensor ac gpio 5v
I'm not an electric guy, I'm just trying to build a small circuit to sense 220 V with my Microcontroller (RPi). But I'm getting either 5 V or 1.3 V on a GPIO wire.
I can't understand the problem. I want 0 V or 5 V on GPIO.
sensor ac gpio 5v
sensor ac gpio 5v
edited Sep 19 at 11:35
Michel Keijzers
4,78162150
4,78162150
asked Sep 19 at 10:14
Ghazanfar Javed
161
161
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
1
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12
add a comment |Â
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
1
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
1
1
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
9
down vote
Here is using your basic idea, but a circuit that will actually work:
Note the addition of D2. That's important to keep the LED from frying. Yes, D1 does block current in the reverse direction, but it will also have some inevitable leakage. The leakage current should be small (see the datasheet), but that could be enough to build up enough voltage across the LED, also in reverse then, to exceed the LED's reverse voltage spec. D2 provides a safe shunt path for whatever leakage current there may be thru D1 during the negative half-cycle of V1.
Unlike another answer, I recommend keeping D1. With D2 across the LED, D1 can actually leak up to being a short without harm to the LED or D2. You could therefore leave it off. However, it serves a useful purpose in reducing the power dissipation. The diode drops are small compared to 220 V, so you basically have 220 V across a 200 kΩ resistor. That comes out to ¼ W. With D1 in there, that is reduced by half, since current is only flowing during half the V1 voltage cycle. Now you can safely use a ¼ W resistor and still allow for some insulation, packaging, limited air flow, etc, around it. Or you could lower R1 to get more LED current, and thereby require less current transfer ratio of the opto.
On the digital side, all you need is a pullup resistor. But, you need to check the current capability all along the way. The peak voltage of a 220 V sine is 311 V. Let's say 309 V across R1 due to the voltage drop of the LED. That results in 1.5 mA. Of course you don't just want a short blip at the peak of the positive power cycles, so let's say anything over 1.0 mA into the LED should assert the output.
The R2 pullup resistor requires 500 µA for the GPIO line to be held low. That means this circuit would work with a opto-coupler with a CTR (current transfer ratio) of at least ½. Optos with a minimum CTR of 1 are easy to find, especially when fast response is not required, like in this case. You therefore have a fairly comfortable margin of 2x with a 1:1 opto-coupler. That all sounds good.
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
add a comment |Â
up vote
3
down vote
Try it like this:
There are two main differences:
There's a diode in antiparallel to the optoisolator's LED. This is better reverse polarity protection than the series diode you used.
The output of the optoisolator pulls the GPIO to ground. This gets you a clear high/low. It will provide a low to the GPIO when AC is present. Because of R2 and C3, it will immediately go low when AC is applied, but will take a bit of time to go high once the AC is gone.
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
add a comment |Â
up vote
0
down vote
Remove what you have on the output side of U3 at the moment. Connect pin 3 of U3 to ground and pull up pin 4 to VCC with something like a 100k resistor. Add a capacitor between pin 4 and VCC if the output needs smoothing.
You are trying to use npn transistors as high side switches. This is not something you should try to do as a novice.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
Here is using your basic idea, but a circuit that will actually work:
Note the addition of D2. That's important to keep the LED from frying. Yes, D1 does block current in the reverse direction, but it will also have some inevitable leakage. The leakage current should be small (see the datasheet), but that could be enough to build up enough voltage across the LED, also in reverse then, to exceed the LED's reverse voltage spec. D2 provides a safe shunt path for whatever leakage current there may be thru D1 during the negative half-cycle of V1.
Unlike another answer, I recommend keeping D1. With D2 across the LED, D1 can actually leak up to being a short without harm to the LED or D2. You could therefore leave it off. However, it serves a useful purpose in reducing the power dissipation. The diode drops are small compared to 220 V, so you basically have 220 V across a 200 kΩ resistor. That comes out to ¼ W. With D1 in there, that is reduced by half, since current is only flowing during half the V1 voltage cycle. Now you can safely use a ¼ W resistor and still allow for some insulation, packaging, limited air flow, etc, around it. Or you could lower R1 to get more LED current, and thereby require less current transfer ratio of the opto.
On the digital side, all you need is a pullup resistor. But, you need to check the current capability all along the way. The peak voltage of a 220 V sine is 311 V. Let's say 309 V across R1 due to the voltage drop of the LED. That results in 1.5 mA. Of course you don't just want a short blip at the peak of the positive power cycles, so let's say anything over 1.0 mA into the LED should assert the output.
The R2 pullup resistor requires 500 µA for the GPIO line to be held low. That means this circuit would work with a opto-coupler with a CTR (current transfer ratio) of at least ½. Optos with a minimum CTR of 1 are easy to find, especially when fast response is not required, like in this case. You therefore have a fairly comfortable margin of 2x with a 1:1 opto-coupler. That all sounds good.
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
add a comment |Â
up vote
9
down vote
Here is using your basic idea, but a circuit that will actually work:
Note the addition of D2. That's important to keep the LED from frying. Yes, D1 does block current in the reverse direction, but it will also have some inevitable leakage. The leakage current should be small (see the datasheet), but that could be enough to build up enough voltage across the LED, also in reverse then, to exceed the LED's reverse voltage spec. D2 provides a safe shunt path for whatever leakage current there may be thru D1 during the negative half-cycle of V1.
Unlike another answer, I recommend keeping D1. With D2 across the LED, D1 can actually leak up to being a short without harm to the LED or D2. You could therefore leave it off. However, it serves a useful purpose in reducing the power dissipation. The diode drops are small compared to 220 V, so you basically have 220 V across a 200 kΩ resistor. That comes out to ¼ W. With D1 in there, that is reduced by half, since current is only flowing during half the V1 voltage cycle. Now you can safely use a ¼ W resistor and still allow for some insulation, packaging, limited air flow, etc, around it. Or you could lower R1 to get more LED current, and thereby require less current transfer ratio of the opto.
On the digital side, all you need is a pullup resistor. But, you need to check the current capability all along the way. The peak voltage of a 220 V sine is 311 V. Let's say 309 V across R1 due to the voltage drop of the LED. That results in 1.5 mA. Of course you don't just want a short blip at the peak of the positive power cycles, so let's say anything over 1.0 mA into the LED should assert the output.
The R2 pullup resistor requires 500 µA for the GPIO line to be held low. That means this circuit would work with a opto-coupler with a CTR (current transfer ratio) of at least ½. Optos with a minimum CTR of 1 are easy to find, especially when fast response is not required, like in this case. You therefore have a fairly comfortable margin of 2x with a 1:1 opto-coupler. That all sounds good.
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
add a comment |Â
up vote
9
down vote
up vote
9
down vote
Here is using your basic idea, but a circuit that will actually work:
Note the addition of D2. That's important to keep the LED from frying. Yes, D1 does block current in the reverse direction, but it will also have some inevitable leakage. The leakage current should be small (see the datasheet), but that could be enough to build up enough voltage across the LED, also in reverse then, to exceed the LED's reverse voltage spec. D2 provides a safe shunt path for whatever leakage current there may be thru D1 during the negative half-cycle of V1.
Unlike another answer, I recommend keeping D1. With D2 across the LED, D1 can actually leak up to being a short without harm to the LED or D2. You could therefore leave it off. However, it serves a useful purpose in reducing the power dissipation. The diode drops are small compared to 220 V, so you basically have 220 V across a 200 kΩ resistor. That comes out to ¼ W. With D1 in there, that is reduced by half, since current is only flowing during half the V1 voltage cycle. Now you can safely use a ¼ W resistor and still allow for some insulation, packaging, limited air flow, etc, around it. Or you could lower R1 to get more LED current, and thereby require less current transfer ratio of the opto.
On the digital side, all you need is a pullup resistor. But, you need to check the current capability all along the way. The peak voltage of a 220 V sine is 311 V. Let's say 309 V across R1 due to the voltage drop of the LED. That results in 1.5 mA. Of course you don't just want a short blip at the peak of the positive power cycles, so let's say anything over 1.0 mA into the LED should assert the output.
The R2 pullup resistor requires 500 µA for the GPIO line to be held low. That means this circuit would work with a opto-coupler with a CTR (current transfer ratio) of at least ½. Optos with a minimum CTR of 1 are easy to find, especially when fast response is not required, like in this case. You therefore have a fairly comfortable margin of 2x with a 1:1 opto-coupler. That all sounds good.
Here is using your basic idea, but a circuit that will actually work:
Note the addition of D2. That's important to keep the LED from frying. Yes, D1 does block current in the reverse direction, but it will also have some inevitable leakage. The leakage current should be small (see the datasheet), but that could be enough to build up enough voltage across the LED, also in reverse then, to exceed the LED's reverse voltage spec. D2 provides a safe shunt path for whatever leakage current there may be thru D1 during the negative half-cycle of V1.
Unlike another answer, I recommend keeping D1. With D2 across the LED, D1 can actually leak up to being a short without harm to the LED or D2. You could therefore leave it off. However, it serves a useful purpose in reducing the power dissipation. The diode drops are small compared to 220 V, so you basically have 220 V across a 200 kΩ resistor. That comes out to ¼ W. With D1 in there, that is reduced by half, since current is only flowing during half the V1 voltage cycle. Now you can safely use a ¼ W resistor and still allow for some insulation, packaging, limited air flow, etc, around it. Or you could lower R1 to get more LED current, and thereby require less current transfer ratio of the opto.
On the digital side, all you need is a pullup resistor. But, you need to check the current capability all along the way. The peak voltage of a 220 V sine is 311 V. Let's say 309 V across R1 due to the voltage drop of the LED. That results in 1.5 mA. Of course you don't just want a short blip at the peak of the positive power cycles, so let's say anything over 1.0 mA into the LED should assert the output.
The R2 pullup resistor requires 500 µA for the GPIO line to be held low. That means this circuit would work with a opto-coupler with a CTR (current transfer ratio) of at least ½. Optos with a minimum CTR of 1 are easy to find, especially when fast response is not required, like in this case. You therefore have a fairly comfortable margin of 2x with a 1:1 opto-coupler. That all sounds good.
answered Sep 19 at 11:32
Olin Lathrop
278k28331783
278k28331783
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
add a comment |Â
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
Note that this circuit assumes that the OP is going to poll the GPIO pin many times per AC cycle and deal in software with the fact that the pin goes high in the negative half-cycle. The original circuit had a capacitor to remember the state so he could just read the pin once whenever his program gets to a point where it wants to know whether the power is on.
â Henning Makholm
Sep 19 at 14:04
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
@Hen: No, it does not require polling many times per cycle. I expect you'd set up a trigger on it going low. That then restarts a timer. AC is considered present as long as the timer has not expired. In other words, basic debounce logic. A little extra hardware could provide this feature, but that hardly seems worth it considering how trivial it is to implement in firmware. A side advantage in some cases is that the AC frequency can be measured. I've had cases where distinguishing between 50 and 60 Hz was useful.
â Olin Lathrop
Sep 19 at 14:09
3
3
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
OK, fair enough -- some form of software handling is needed. My point was not that smoothing should be added to the hardware, just to warn the OP that he will need different software with this circuit than he probably expected to get away with for his own.
â Henning Makholm
Sep 19 at 14:15
add a comment |Â
up vote
3
down vote
Try it like this:
There are two main differences:
There's a diode in antiparallel to the optoisolator's LED. This is better reverse polarity protection than the series diode you used.
The output of the optoisolator pulls the GPIO to ground. This gets you a clear high/low. It will provide a low to the GPIO when AC is present. Because of R2 and C3, it will immediately go low when AC is applied, but will take a bit of time to go high once the AC is gone.
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
add a comment |Â
up vote
3
down vote
Try it like this:
There are two main differences:
There's a diode in antiparallel to the optoisolator's LED. This is better reverse polarity protection than the series diode you used.
The output of the optoisolator pulls the GPIO to ground. This gets you a clear high/low. It will provide a low to the GPIO when AC is present. Because of R2 and C3, it will immediately go low when AC is applied, but will take a bit of time to go high once the AC is gone.
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Try it like this:
There are two main differences:
There's a diode in antiparallel to the optoisolator's LED. This is better reverse polarity protection than the series diode you used.
The output of the optoisolator pulls the GPIO to ground. This gets you a clear high/low. It will provide a low to the GPIO when AC is present. Because of R2 and C3, it will immediately go low when AC is applied, but will take a bit of time to go high once the AC is gone.
Try it like this:
There are two main differences:
There's a diode in antiparallel to the optoisolator's LED. This is better reverse polarity protection than the series diode you used.
The output of the optoisolator pulls the GPIO to ground. This gets you a clear high/low. It will provide a low to the GPIO when AC is present. Because of R2 and C3, it will immediately go low when AC is applied, but will take a bit of time to go high once the AC is gone.
edited Sep 19 at 11:40
answered Sep 19 at 10:46
JRE
18.9k43563
18.9k43563
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
add a comment |Â
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
1
1
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
is the built in circuit editor broken?
â PlasmaHH
Sep 19 at 13:42
1
1
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
@PlasmaHH: Nope. I just can't use it on my phone.
â JRE
Sep 19 at 13:46
add a comment |Â
up vote
0
down vote
Remove what you have on the output side of U3 at the moment. Connect pin 3 of U3 to ground and pull up pin 4 to VCC with something like a 100k resistor. Add a capacitor between pin 4 and VCC if the output needs smoothing.
You are trying to use npn transistors as high side switches. This is not something you should try to do as a novice.
add a comment |Â
up vote
0
down vote
Remove what you have on the output side of U3 at the moment. Connect pin 3 of U3 to ground and pull up pin 4 to VCC with something like a 100k resistor. Add a capacitor between pin 4 and VCC if the output needs smoothing.
You are trying to use npn transistors as high side switches. This is not something you should try to do as a novice.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Remove what you have on the output side of U3 at the moment. Connect pin 3 of U3 to ground and pull up pin 4 to VCC with something like a 100k resistor. Add a capacitor between pin 4 and VCC if the output needs smoothing.
You are trying to use npn transistors as high side switches. This is not something you should try to do as a novice.
Remove what you have on the output side of U3 at the moment. Connect pin 3 of U3 to ground and pull up pin 4 to VCC with something like a 100k resistor. Add a capacitor between pin 4 and VCC if the output needs smoothing.
You are trying to use npn transistors as high side switches. This is not something you should try to do as a novice.
answered Sep 19 at 10:38
RoyC
4,93431431
4,93431431
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2felectronics.stackexchange.com%2fquestions%2f396825%2fhaving-trouble-in-gpio-output-220-v-to-5-v-signal%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
The leakage current out of your GPIO pin in input mode has to be conducted to 0 V by the pull-down resistor. It's often something like 3..10 uA, so the voltage drop it causes across the 370K may well cause your 1.3 V. Change it to 10K and try again.
â TonyM
Sep 19 at 10:27
1
Also, the time constant of the C3-R7 combination is rather large. Are you sure you want it to take tens of seconds before the circuit notices that the AC power has gone away?
â Henning Makholm
Sep 19 at 13:54
In order to turn on a transistor, the base-emitter voltage must be greater than 0.7V (the exact voltage depends on the device). In your circuit the emitter is floating; and so is the base when the opto-isolator is not turned on. Olin's circuit does the job without needing an extra transistor, but if you do want to use an NPN transistor as a switch then you need to look up how to use it. Google "NPN transistor switch".
â Graham
Sep 19 at 15:12