larryd:
We see no current limiting resistors any where.
Fixed the schematic, tnx
Paul_KD7HB:
How long does the light bulb have to be off before your eyes will notice it? Once you know that, then you will have the answer to your question.
Paul
And how i can know this ?
i had a look on the internet but here is no datasheet or code of this bulb
And how i can know this ?
i had a look on the internet but here is no datasheet or code of this bulb
Does the light in your room use incandescent light bulbs? If so, turn the switch off and see how much time elapses before you notice the bulb had dimmed. Perhaps 1/4 second? Try that for your program and work from there.
Paul_KD7HB:
Does the light in your room use incandescent light bulbs? If so, turn the switch off and see how much time elapses before you notice the bulb had dimmed. Perhaps 1/4 second? Try that for your program and work from there.
Paul
For my eye it seems like it dimmed instantly
but let's say a random value of about 100ms fall time , what i'm gonna do with it ?
And now I think about it, you might have already fried the opto's... When pin 13 is floating you just have 2 leds in series without current limiting resistors. And the combined ax forward voltage of both is lower then 3,3V (2x 1,3V = 2,6V) so current WILL flow freely.
Throw both opto's in the bin, grab a new one, connect the LED with a resistor between pin 13 and GND. And on the output, connect the emitter to GND, collector to the mosfet gate and add a resistor of +-1k between mosfet gate and 12V to turn it off. And of course mosfet source to 12V and drain to the load.
septillion:
And now I think about it, you might have already fried the opto's... When pin 13 is floating you just have 2 leds in series without current limiting resistors. And the combined ax forward voltage of both is lower then 3,3V (2x 1,3V = 2,6V) so current WILL flow freely.
Throw both opto's in the bin, grab a new one, connect the LED with a resistor between pin 13 and GND. And on the output, connect the emitter to GND, collector to the mosfet gate and add a resistor of +-1k between mosfet gate and 12V to turn it off. And of course mosfet source to 12V and drain to the load.
if (ledu_status == 2) { //TURNING ON ~~~~~~~~~
if (ledu_dim != 40) {
ledu_dim = ledu_dim + 1;
analogWrite(usaOutPin, ledu_dim);
}
else {
ledu_status = 3;
}
}
if (ledu_status == 1) { //TURING OFF ~~~~~~~~~~
if (ledu_dim != 0) {
ledu_dim = ledu_dim - 1;
analogWrite(usaOutPin, ledu_dim);
}
else {
ledu_status = 0;
}
}
septillion:
And now I think about it, you might have already fried the opto's... When pin 13 is floating you just have 2 leds in series without current limiting resistors. And the combined ax forward voltage of both is lower then 3,3V (2x 1,3V = 2,6V) so current WILL flow freely.
Throw both opto's in the bin, grab a new one, connect the LED with a resistor between pin 13 and GND. And on the output, connect the emitter to GND, collector to the mosfet gate and add a resistor of +-1k between mosfet gate and 12V to turn it off. And of course mosfet source to 12V and drain to the load.
they had the resistor, i just forget to draw it
i checked the pin 13 with my multimeter and it works like it should !
NEWS:
If i'm adding a 50k resistor between 3.2v and photocouper the led turn off after 3 seconds that when it should (400ms fall time from my eye)
removing the resistor the leds won't turn off anymore and the photocouplers ar getting way too hot to keep the circuit pluged
septillion:
We're not Snippers R Us aka all code in a compilable manner.
Then you're still forgetting it because it's still not there...
There is a 220ohm resistor between the arduino and the circuit and it always been there, i only forget to draw it in the first photo, after the first post i edited the photo and added the resistor in the schematic too
Mmm... A 50k resistor in the optocoupler line makes them dark at all times. That you see the light on for a few seconds is most likely due to the gate capacitance of the MOSFET.
Two optos in series with 3.3V on one side and GND on the other will also cause problems, and not only when your pin is in INPUT mode. Current flows through the two LEDs, no resistor in that path means effectively a short.
A more serious problem when doing PWM with optocouplers is that the optos are quite slow: they take 3 us to switch. This may be a problem.
If you must use this P-channel, high-end switch: replace the second opto with a pull-down resistor. One opto is enough to switch the gate between 12V and GND.
Better: get a logic level N-channel MOSFET such as the PMV16UN which can handle the current just fine, and which switches fully on at 3.3V gate. Beware, these things are tiny: SOT-23 packings, the size of a grain of rice. Then you can wire it as low-side switch. Small resistor to the pin (current limiting), 10k or so pull-down.
wvmarle:
Mmm... A 50k resistor in the optocoupler line makes them dark at all times. That you see the light on for a few seconds is most likely due to the gate capacitance of the MOSFET.
Two optos in series with 3.3V on one side and GND on the other will also cause problems, and not only when your pin is in INPUT mode. Current flows through the two LEDs, no resistor in that path means effectively a short.
A more serious problem when doing PWM with optocouplers is that the optos are quite slow: they take 3 us to switch. This may be a problem.
If you must use this P-channel, high-end switch: replace the second opto with a pull-down resistor. One opto is enough to switch the gate between 12V and GND.
Better: get a logic level N-channel MOSFET such as the PMV16UN which can handle the current just fine, and which switches fully on at 3.3V gate. Beware, these things are tiny: SOT-23 packings, the size of a grain of rice. Then you can wire it as low-side switch. Small resistor to the pin (current limiting), 10k or so pull-down.
"no resistor in that path" What path ? there is a 220 resistor in any path of the led photocoupler
"then you can wire it as low-side switch." The surrounding(situation) doesn't let me use the low side...
prologikus:
There is a 220ohm resistor between the arduino and the circuit and it always been there, i only forget to draw it in the first photo, after the first post i edited the photo and added the resistor in the schematic too
Yes, but that will NOT stop/limit the current in any way between the 3,3V and GND through the two opto's In THAT path there is no limiting.
septillion:
Yes, but that will NOT stop/limit the current in any way between the 3,3V and GND through the two opto's In THAT path there is no limiting.
Ye but imagine that if my Pin is LOW that become the ground of the first opto
And if the pin is HIGH the first opto won't be turned on because it have no ground
(i think)
This circuit in inspired by this video:
Thanks for your answers so far, take at look at this video if you can.
You think wrong Because the way through the second opto is easier so the opto's will do that
prologikus:
This circuit in inspired by this video:
Ahh, yeah, Julian But did you actually watch it? He didn't add those two leds in line just for fun Add those as well and switch to the 5V (which would make more sense on a 5V micro).
But that design is pretty complex for what you want. Just find a (logic level) N-channel mosfet and you're done.
septillion:
You think wrong Because the way through the second opto is easier so the opto's will do that
Ahh, yeah, Julian But did you actually watch it? He didn't add those two leds in line just for fun Add those as well and switch to the 5V (which would make more sense on a 5V micro).
But that design is pretty complex for what you want. Just find a (logic level) N-channel mosfet and you're done.
I can't use low side, only high side
Can you explain how i can do julian circuit working with my 3.2V? He said with that circuit you can control p channel mosfets too
prologikus:
"no resistor in that path" What path ? there is a 220 resistor in any path of the led photocoupler
Where is the resistor in the path 3.3V - optocoupler - optocoupler - GND?
You need 3.3V - optocoupler - resistor - (link to IO pin without resistor) - optocoupler - resistor - GND.
But even when you have that, strange things may still happen when your Arduino switches on with pins in INPUT mode, and both optos are (partly) on.
The schematic on the left is how you should wire the current limiting resistors. The schematic on the right is a vastly improved version, only one optocoupler. Load is off when pin is LOW or INPUT.