Go Down

Topic: A question about transistors and an Arduino Uno. Probably a daft one! (Read 2764 times) previous topic - next topic

Jiggy-Ninja

Having said that, there's absolutely no reason why completely cutting the power can't work if done correctly. The application might be a little bit more limited, as you need an external device or manual switch to wake it, but I can see possible usage where something just needs to complete a given task and then power itself down when done.
Adafruit TV-B-Gone has a nice way of doing it. The code does what it needs to (send the IR commands to turn off TVs), then goes into PWR_DOWN mode with no wake up sources enabled. How does it wake up then, you ask?

The button is connected to RESET. The reset signal is a (JARGON ALERT!) nonmaskable interrupt on probably the vast majority of microcontrollers, AVRs included. It cannot be turned off in code like other interrupts can. It overrides everything.

Quote
BTW. The following are the sleep mode supply current (from Vin) I've measured on my UNO and (NANO) boards.

Full power :  25 mA  (25 mA)
SLEEP_MODE_IDLE  18 mA : (17 mA)
SLEEP_MODE_PWR_DOWN : 9.2 mA (8.2 mA)

So about 37% (UNO) of full load power (and 33% for NANO) for the maximum power saving mode on a complete board. So fair power savings, but nothing close to completely cutting power.
That is not an argument in favor of self-switching power. That's an argument in favor of not using a development board as part of the final assembly. They're good for development (hence the name), but all the extra crap that makes development easy is wasteful when you're running on battery. Get an ISP shield (about $15 I think) and there's not excuse for a barebones system being "too complicated". Download one of the cores that supports setting fuses for the internal oscillator and you don't even need to bother with an external crystal.

Or get cheap Pro Mini clones from ebay with an FTDI board. All the convenience of programming with the bootloader, and almost no wasted power.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

That is not an argument in favor of self-switching power. That's an argument in favor of not using a development board as part of the final assembly.
Yes I know, but there are plenty of hobbyists on these forums that are going to use development boards most of the time. It also illustrates the advantage that cutting the power externally can power down entire susb-systems, not just the Arduino itself.

Basically I'm just saying don't completely rule it out, it can have it's place. :)

Jiggy-Ninja

Basically I'm just saying don't completely rule it out, it can have it's place. :)
In a few limited circumstances maybe, but to me it usually reads like someone asking "how do I check for button presses when I'm delay()ing all over the place" and people answer by teaching them how to use attachInterrupt instead of teaching how to not use delay()! Delay() sucks. Switching power this way sucks too, and doesn't even provide the best results.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Jiggy-Ninja

Incidentally, why are your current measurements so much lower than Nick's?
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

not use delay()! Delay() sucks. Switching power this way sucks too, and doesn't even provide the best results.
Not really a fair analogy in my opinion. Two totally different things.

Incidentally, why are your current measurements so much lower than Nick's?
Not really sure. I see Nick measured about 50 mA versus my 25 mA on the UNO. Could be that mine is a clone using the ch340 usb chip. It also has the 328p micro controller in the smaller surface mount format. I'm not sure if that makes any difference, though it could be a newer revision of the chip. I also had the inbuilt LED off, so a few more mA saved there.

I had lot of voltage overhead (12V supply) so I tested it with a largish 56 ohm series resistor, the results should be fairly accurate. I did only use a multimeter DC voltage measurement to deduce average current, but that usually works well enough.

Jiggy-Ninja

Not really a fair analogy in my opinion. Two totally different things.
I think it's completely fair. In both cases you have someone doing something stupid (using a dev board on battery or using delay for sequence timing) and trying to fix it with something dumb (self-switched power or interrupt driven interface).
Quote
Not really sure. I see Nick measured about 50 mA versus my 25 mA on the UNO. Could be that mine is a clone using the ch340 usb chip. It also has the 328p micro controller in the smaller surface mount format. I'm not sure if that makes any difference, though it could be a newer revision of the chip. I also had the inbuilt LED off, so a few more mA saved there.
Could be that. According to this datasheet I found CH340 takes 150 uA in USB suspend. It's probably in suspend mode when USB is unplugged. Nick's probably had a version with an ATmega16U2. The code for that doesn't look like it's using any sleep modes, so it's probably on full blast all the time no matter what's going on with the USB port. Ironically, your clone is superior to a genuine product by this metric.

That means the rest of the 9.2 mA of current you're reading with PWR_DOWN mode is due to the crappy regulators taking an astronomical amount of quiescent current.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

I think it's completely fair. In both cases you have someone doing something stupid
That's a bit of a circular argument there Jiggy. On one hand you are using your analogy to show that it's stupid, and then you claim the analogy is fair because they are both stupid.

In any case, the OP wanted to know if it could be done and proposed a completely non workable circuit. My posts simply show him how to make a working circuit. Like I said, I've never actually had cause to do this on an Arduino, but I've done it with other devices (actually systems) in the past. The circuits I've shown are based on working circuits I've designed in the past, but scaled down a bit in power so that someone could apply them to the Arduino if they wished.

Jiggy-Ninja

That's a bit of a circular argument there Jiggy. On one hand you are using your analogy to show that it's stupid, and then you claim the analogy is fair because they are both stupid.
No, it's not a circular argument.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

According to this datasheet I found CH340 takes 150 uA in USB suspend. It's probably in suspend mode when USB is unplugged.
Yeah that sounds about right. I had no usb connection and the CH340 must have in suspend mode.

Quote
That means the rest of the 9.2 mA of current you're reading with PWR_DOWN mode is due to the crappy regulators taking an astronomical amount of quiescent current.
Just looking over the UNO schematics, the quiescent current on most of the stuff is pretty reasonable, around the 100 to 300 uA range. Adding everything up it appears that it's actually just the LEDs that make up the bulk of that current!

The UNO has a dual opamp that the NANO doesn't have, but again that's only another 200 uA. The UNO also has a resistance voltage divider in the V_in / V_usb changeover circuit, which would account for about 0.5 mA at the input voltage I used.  And finally the UNO has the inbuilt LED buffered through an opamp, so it does often glow a bit even when the input (pin 13) is just floating. Together these thing probably account for the very slightly greater current on the UNO.

Now on the schematic the NANO specifies the much higher bias current 78M05 (around 5 mA), however just looking at my nano clone I see that it actually has the same NCP1117-50 as the UNO. So again it looks like most of that 8.2 mA  is just the "on LED" power.


Smajdalf

In a few limited circumstances maybe, but to me it usually reads like someone asking "how do I check for button presses when I'm delay()ing all over the place" and people answer by teaching them how to use attachInterrupt instead of teaching how to not use delay()! Delay() sucks. Switching power this way sucks too, and doesn't even provide the best results.
I do hope you are not using the #$%%& inefficient Arduino C-based thing. You can NEVER get close to program properly written in Assembler.

But for us, not so obsessed with "the right ways" delay() is fast way for the program to do what should be done.
Anyway, using sleep is very similar to using delay(). If you learn how to interrupt delay() you may use sleep just in the same way.
Mostly young and some old people believe they know everything and only their point of view is the right one. I suspect you fall in one of those categories. Try to mature.
On 8-bit (i.e. Uno) use "byte" instead of "int" if possible - it is faster and saves resources!

Jiggy-Ninja

But for us, not so obsessed with "the right ways" delay() is fast way for the program to do what should be done.
delay() is only good if you need your program to do exactly one thing, and nothing else. Most people's projects are not that simple.

My current ambitious project is to motorize a TV wall mount and control it with an IR remote. Moving the mount to a preset value would require the master to simultaneously coordinate the motions of 3 servo controllers, watch for errors on another bus line, and continue watching the IR Receiver for other commands that might require it to stop or change motion.

Switching between all those different tasks while also using delay() is impossible.
Quote
Anyway, using sleep is very similar to using delay(). If you learn how to interrupt delay() you may use sleep just in the same way.
Actually it's the exact opposite. delay() hinders the use of sleep precisely because there is no way to break out of it until the interval is over. The microcontroller is stuck awake until delay() is done. The only way I've come up with to effectively use sleep is a rigorous non-blocking, event driven code style. If you have a way to sleep the microcontroller using delay() without reimplementing the function some how, I'd love to see it.
Quote
Mostly young and some old people believe they know everything and only their point of view is the right one. I suspect you fall in one of those categories. Try to mature.
I am not a crotchety old man, nor a know-it-all teenager. I simply see that there are so many times where people have a problem with "my sketch isn't responsive to button presses" or "I'm having problems merging these two sketches", and whenever I look in there I see long delays.

Delay is by far the single most abused function that I have seen on this forum. For the vast majority of things people want to make, delay() just holds them back from realizing an Arduino's full potential.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

Jiggy-Ninja

Now on the schematic the NANO specifies the much higher bias current 78M05 (around 5 mA), however just looking at my nano clone I see that it actually has the same NCP1117-50 as the UNO. So again it looks like most of that 8.2 mA  is just the "on LED" power.
The NCP1117 is pretty bad too.



Just because a regulator is low dropout doesn't mean anything about the quiescent current.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

The NCP1117 is pretty bad too.
Interesting. I've used that one before and from memory it was a lot lower than that. I'll double check part I used previously.

EDIT. Yeah it was the adjustable voltage version (NCP1117-STA) I used previously. I_adj about 100 uA

Jiggy-Ninja

Interesting. I've used that one before and from memory it was a lot lower than that. I'll double check part I used previously.

EDIT. Yeah it was the adjustable voltage version (NCP1117-STA) I used previously. I_adj about 100 uA
The adjustable version has a minimum 5 mA load required to properly bias the voltage reference. At the very bottom of page 3 is Minimum Required Load Current for Regulation, Adjustable Output Devices. Typical 0.8 mA, maximum 5 mA. None of the graphs in the datasheet characterized how that value changes with respect to different conditions, so designing based on the maximum value is safest.
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

stuart0

The adjustable version has a minimum 5 mA load required to properly bias the voltage reference.
Yes I know that. However that load current doesn't have to be quiescent/bias current (though the resistive divider to the adj terminal). It can be regular load current as long as you've got something (LED for example) to provide that minimum.

Obviously you still need to keep the bias current large compared to delta_I_adj. But bias currents around 500 uA range are feasible with the reg in many circumstances.

Go Up