I'm new with electronic / microcontrollers and try to save current as much as possible in my first project.
µC sleeps until a button is pressed, then first OUTPUT is set HIGH and then read values from 3 potis and do some further things.
If I connect the potis like the first picture, each poti (10k) consume 0,6 mA * 3 = 1,8 mA even if µC sleeps.
If I connect the potis like in the second picture, no current is consumed from potis until the µC wakes up, but I don't know if it's save - what's "Best Practice" in this case.
That's fine to do... Though you might want to control the pots independently of that relay.
Each 10k pot* at 5v, will draw 0.5mA, not 0.6.
If you are using a non-latching relay, you've lost the battery life war - even a small relay will use 20mA+, unless you've got a latching relay (which would mean you're only pulsing the power to it, so your pots will have to be on a different line than controls the relay).
*"Pot", short for "potentiometer". "poti" is not used as abbreviation (at least in english) for potentiometer.
Poti is used in Germany.
TS' name kloeppi76 (or klöppi76) suggests a German speaking background.
I agree that saving power this way doesn't seem to be much of a benefit if the relay is fed through the same supply.
Perhaps kloeppi76 would have better results looking for a more efficient way to switch a load.
MAS3:
Poti is used in Germany.
TS' name kloeppi76 (or klöppi76) suggests a German speaking background.
That's right and my English is poor - so poor that I can't translate your answers correctly and Google is doing a bad translation job.
Because I'm not sure that I did translate right or did describe the project right, a short description
µC sleeps the most time, OUT1 (Relais1) and OUT2 (Relais2) are LOW
Once or twice a week someone pushes the button
µC wake up and
set OUT1 (Relais1) to high for max. 15 sec
read values of pot 1-3
set OUT2 (Relais2) to high for max. 1 sec
set OUT1 and OUT2 to LOW again
µC go sleeping again for a long time
So my thought was if I connect the pots to permanent 5V and permanent GND then the circuit consume 1,5 mA because of the pots and the µC is sleeping.
If I would connect then pots to OUT1 and permanent GND then the pots would only consume power if necessarry, because all analogReads of pots take place after OUT1 is set to HIGH
Here's the code
#include <avr/sleep.h>
#include <avr/interrupt.h>
const int dRBell = 0;
const int dWLiftHandset = 1;
const int dWRedial = 2;
const int aRPin3 = 3;
const int aRPin4 = 2;
const int aRPin5 = 0;
int Ringing = 0;
void setup() {
// Negative Logik - externer PullUp
pinMode(dRBell, INPUT); //
// digitalWrite(dRBell, HIGH);
pinMode(aRPin3, INPUT);
pinMode(aRPin4, INPUT);
pinMode(aRPin5, INPUT);
pinMode(dWRedial, OUTPUT);
digitalWrite(dWRedial, LOW);
pinMode(dWLiftHandset, OUTPUT);
for (int k = 0; k < 6; k = k + 1) {
if (k % 2 == 0) {
digitalWrite(dWLiftHandset, HIGH);
}
else {
digitalWrite(dWLiftHandset, LOW);
}
delay(250);
}
}
void sleep() {
GIMSK |= _BV(PCIE); // Enable Pin Change Interrupts
PCMSK |= _BV(PCINT0); // Use PB0 as interrupt pin
ADCSRA &= ~_BV(ADEN); // ADC off
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // replaces above statement
sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
sei(); // Enable interrupts
sleep_cpu(); // sleep
cli(); // Disable interrupts
PCMSK &= ~_BV(PCINT0); // Turn off PB0 as interrupt pin
sleep_disable(); // Clear SE bit
ADCSRA |= _BV(ADEN); // ADC on
sei(); // Enable interrupts
}
ISR(PCINT0_vect) {
// This is called when the interrupt occurs, but I don't need to do anything in it
if (Ringing == 0)
{
Ringing = 1;
}
}
void loop() {
sleep();
if (Ringing == 1)
{
digitalWrite(dWLiftHandset, HIGH);
delay(analogRead(aRPin3)/1.023*1.0);
digitalWrite(dWRedial, HIGH);
delay(analogRead(aRPin4)/1.023*1.0);
digitalWrite(dWRedial, LOW);
delay(3000+analogRead(aRPin5)/1.023*12);
digitalWrite(dWLiftHandset, LOW);
Ringing = 0;
}
}
I know that 1,5 mA is a bagatelle but if it's save to connect the pots the second way, why should I not conserve this current
Aaah! That extremely low duty cycle lets you get away with the relay without destroying battery life too bad, such that it's worth looking at 1.5mA that would be on full time (and your solution will work fine - though I'd be inclined to use a different IO pin if I had one to spare, not that you have to) I was assuming the relay would be on for a significant portion of the time. That's why we were all talking about relay power use.
You know you can't use a normal board for this, right? The other components on the board suck power hardcore - I think 50mA or so for the uno. Mostly it goes to the regulator and power LED. For battery life, you use a pro mini, and remove the power LED and voltage regulator, or make a barebones arduino (someone who's big on these forums, I think Nick Gammon, has a really nice page on power usage with numbers measured for 328's and boards with various changes made. )
And yeah - I wasn't meaning to be rude about the poti thing, just pointing it out to you. Your english is better than plenty of native english speakers who post questions here
DrAzzy:
... (and your solution will work fine - though I'd be inclined to use a different IO pin if I had one to spare, not that you have to)
...
You know you can't use a normal board for this, right?
...
I don't have an unused pin because I want to transfer the Arduino Nano Project to an empty ATtiny85 with disabled Reset.
DrAzzy:
...Your english is better than plenty of native english speakers who post questions here
Splitting hairs again ?
You have been breaking your head while reading those schematics then ?
Did you see the oh so important (to Americans) disclaimer, right before that list ?
wikipedia disclaimer:
The table below lists designators commonly used, and does not necessarily comply with the standard
T is very often used as designator for transistors, certainly over here in Europe.
World's largest electronics magazine uses T too and it wouldn't surprise me if schematic tools also offer this as the corresponding designator.
I can't tell about that because i'm not using lots of these tools / programs and can't be bothered by such futility.
T for transistor, TR for transformer is/has been in common use. If its labeling a circuit diagram the
symbol tells you what it is, there is no ambiguity.
Splitting hairs again ?
You have been breaking your head while reading those schematics then ?
The schematic is clear. It's a TO92 package transistor. If I wanted to split hairs I would have pointed out that the transistor appears to be wired backwards with the emitter and collector swapped
and that it doesn't say WHICH transistor. The measurements posted by the OP suggest otherwise
since I doubt he could measure that with the transistor reversed, but the two datasheets above show a
different pinout. The diode says 1n4148, NOT D1. So clearly there is inconsistency in the representation of the components, which, I might add, I didn't comment on, until now. Our job, as experts, in addition to providing advice on getting the circuit working, is to provide advice on proper convention. If an OP is posting a schematic like that, clearly he is unaware of the proper convention for schematic representation. (why is there no schematic symbol for the transistor? Why is the diode part number given but the transistor part number omitted ? Why is the diode shown with a proper diode shcematic symbol but the transistor shown as simply a TO92 package ? Why are the pots shown as they are instead of resistive elements with a wiper ? (as they are usually shown) As experts we are obligated to point out these inconsistencies. I'm surprised that you did not notice that the transistor was wired backwards (or could be, depending on which part number and manufacturer it is)
there is no ambiguity.
I simply said the designator was wrong. I never said there was any ambiguity.
NOTE: The attached 2N2222 datasheet shows a pinout that matches the one used by the OP, so it is unknown which pinout he has because the MFG and P/N were omitted, which speaks to my original comment. It might be correct, it might not. We don't know. We can't know until the OP posts the part number and manufacturer of the transistor he is using.
I'm not obliged to anything.
I will try to answer questions i understand and sometimes ones i do not understand (i'll ask for more information).
And i will try to not pollute threads by going way off topic.
So next reply here from me will be on topic, if i'll reply at all.
So you think that if an OP posts a schematic with a transistor that might be wired backwards you should just ignore it because his question pertains to sleep mode ? Really ? How logical is that ?
That's like a gas station attendent not mentioning that one of the tires is very low on air because the driver only stopped to ask directions.
Note that my "OFF TOPIC" comment was preceded by "FYI" (FOR YOUR INFORMATION)
FYI, the schematic component designator for a transistor is "Q1" , NOT "T1".
Which implies it is neither directed at the posted question or necessarily important, but rather
a footnote, (as in, 'just so you know')
I did read the German Wiki for "Use transistor as switch" what's called in German "Emitterschaltung".
There is descriped, that E is connected to GND and C is connectted to relais
and it can really be that I did change the C and E of the transistor - see my first post
The transistor is wired correctly for that datasheet.
That appears to be a small signal transistor , (as opposed to a general purpose transistor such as the 2n2222 or 2n3904 which both have higher collector current ratings but lower hfe. Is that what you want for relay driver ? (I would use a general purpose transistor for that since you are not amplifying a signal). How did you choose THAT transistor ? You choice does not match your application. Anyone else concur ?
I have to agree with raschemmel. Being a pedant is a good thing in technical fields.
FYI, that isn't a schematic, it is sort of a mixed pictorial/schematic. It looks like a bunch of meters, not potentiometers.
My signature line has some helpful links on schematic drawing.
I've noticed more and more magazines and books taking great liberties with the way they draw schematics and designate components. The point of a schematic is clarity, or we'd all just use pictorial diagrams.
Being a pedant is a good thing in technical fields.
I think might even go so far as to say that it would be an oversight not to point that out, as it is our job , as experts, to see things the OP can't see. I thought the same thing about the "schematic" and commented to that effect in an earlier post. I was pretty sure those were meter symbols but whatever they were, they
were not pot symbols.