Go Down

Topic: Arduino, two buttons powering and digital inputs in the same time (Read 1 time) previous topic - next topic

MisDev

I'm basing it on the optocoupler (4N35) you used in the schematic, I see no reason in trying to find one with an internal resistor.

septillion

If you want to blow the crap out of the opto's, then it's a fine circuit. ;) Aka, resistors!

But uhm, looks like a bazooka to kill a mosquito....

I did not ignore it, I said that I'm already using Schottky diodes, but even with them there is no guarantee that the voltage drop will be low (because it also depends on the temperature).
You did not draw them and you only said "does not solve all the problems". Counts in my book as not using them... But okay, the resister option is maybe easier.

My question was not about decreasing boot time or reflashing Arduino, that's why I didn't mention it. It's just not important, doesn't change anything in terms of circuit.
You asked if the circuit can work. But with a Pro Mini with original boorloader it does not so yeay, it is important. Like it's important to draw the whole circuit! As far as we know you might even have the whole damn thing connected to mains or try to draw 100A.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

matveev-ruslan

Vf for the diode is a miniumum of 0.8V and a maximum of 1.5V, both depending on the ambient temperature (see Datasheet, page 2)
As it has a If of 10mA you need a resistor of (12V-1V)/10mA=1k1Ω in series with the diode.
Btw there is no 12v anymore, note that optocouple is connected between VCC (which is about 5v after internal voltage regulator) and the ground...

MisDev

EDIT: I'm stupid

matveev-ruslan

The default position is that the Arduino is off, because GND isn't connected to ground.
Because of this there is no voltage to get from that pin, because of this the switches doesn't get any voltage to turn on the optocouplers to turn the Arduino on.
And thus The Arduino will never turn on.  :o
Okay, look at the circuit again. When we press the button, Arduino is powered through RAW pin, so optocouplers doesn't play any role in this process.

If you want to blow the crap out of the opto's, then it's a fine circuit. ;) Aka, resistors!
But uhm, looks like a bazooka to kill a mosquito....
Resistors are not there because I forgot about them ) I agree that it's a bit "too much", but in any case I was planning to use an optocoupler to control Arduino's own power, so now I'll just take dip16 opto.

But in general it looks very cool yeah? :D

MisDev

This would work, essentially the same thing, but removed redundant components, and added the current-limiting resistor


EDIT: forgot something, I'll make a new post..

matveev-ruslan

This would work, essentially the same thing, but removed redundant components, and added the current-limiting resistor

Nice thanks! Not sure what "Arduino_Pullup" means? By default pins are already "pulled up" to the internal +5v using Arduino's internal resistors, so optocouple in this case is "pulling them down" to the ground. What is this 800ohm resistor nominal? Is this something random or you've calculated it? From what I've seen in the internet about Arduino and 4n35 1K resistor is used.

matveev-ruslan

Third opto is used by Arduino to control it's own power:



There was a mistake, now it's corrected.

MisDev

U3 can't be on unless one of the switches is pressed.
did you rotate it by accident?

matveev-ruslan

U3 can't be on unless one of the switches is pressed.
did you rotate it by accident?
There was a mistake in the previous image, now it's corrected (maybe your question is related with the previous one). But the idea is that when Arduino is started up (after pressing one of the buttons), it outputs HIGH to the pin which is connected to U3's anode, when that happens, current will start to flow from battery "+", through U3 and then to the ground, when this happens it's doesn't matter anymore whenever the button is kept pressed or not, because now Arduino takes responsibility to power itself off.

MisDev

The Cathode on U3 isn't connected to ground on the battery, only GND on the Arduino.
Follow the path from D8 to ground on the battery.
Then follow the path from the emitter on U3 to ground on the battery.
Also the phototransistor on U3 more or less shorts the battery when a button is pressed.

matveev-ruslan

The Cathode on U3 isn't connected to ground on the battery, only GND on the Arduino.
Follow the path from D8 to ground on the battery.
Then follow the path from the emitter on U3 to ground on the battery.
Also the phototransistor on U3 more or less shorts the battery when a button is pressed.
Oh my bad I see, what about this one:


MisDev

Never testet it before. I know that it works with relays, but not sure about micro-conductors.

septillion

Again, resistors!

And be aware the 4N35 can only do 50mA. And the CTR is only specified as 100% minimum (40% - 50% at extreme temperatures). So probably you can get away with less then 50mA for the opto LED but you can't be sure... And 50mA is just enough to power a Arduino without the LEDs removed etc. And that's no including the transmitter you probably want to hook up as well...
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

matveev-ruslan

Again, resistors!

And be aware the 4N35 can only do 50mA. And the CTR is only specified as 100% minimum (40% - 50% at extreme temperatures). So probably you can get away with less then 50mA for the opto LED but you can't be sure... And 50mA is just enough to power a Arduino without the LEDs removed etc. And that's no including the transmitter you probably want to hook up as well...
Great success! Just tested it and everything works as expected. However instead of U3 opto I used solid state relay - PVT322 (just because I didn't have third 4N35). Could you please elaborate what you mean by "4N35 can only do 50ma"? Is it related with the diod or transistor in optocouple? What are the alternatives then?

I also have an idea to replace optos with solid state relays, unfortunately I can't find 3 / 4 - channel relay, but 2 - channel ssr are easy to find. So as a backup plan I'll use 2 - channel relay for the buttons and 1 - channel for the power.

BTW can I replace optos with transistors? :)

Go Up