Pages: [1]   Go Down
Author Topic: Arduino inputs when uC powered up  (Read 432 times)
0 Members and 1 Guest are viewing this topic.
Brisbane, Queensland
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Hello
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello all,

I have an idea about how I want to approach my project; but what I need to know is how the Arduino functions.

Say if I have several DPDT momentary switches, can I use one of the switch poles to apply power to the arduino, then have the other pole going to a digital input?

Does the input need to change states whilst the micro is powered up, or can it be already in a state when the Arduino is booted and code is executed?

The inputs will have a pulldown resistor connected so that the inputs are not left floating.

So essentially, each switch will apply power to the arduino, the arduino will poll the inputs to determine which switch was pressed, then execute a function depending on which input was triggered.

The reason for this method is a desire to save power for something that will be used infrequently.

Thanks for any advice you can give

Regards

Ash
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8475
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It doesn't matter when the input goes high/low, you get what you get when you read it.

But if it's always going to be active when you power up what's the point ?

EDIT:
Quote
the arduino will poll the inputs to determine which switch was pressed,
Never mind I get it. Yes that should work.

______
Rob
« Last Edit: November 21, 2012, 07:44:43 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ash,

If I'm reading your description right, you intend to take power off the source that's running the Arduino through the switches for this.  If you want to simplify things, the Arduino has inbuilt pull-up resistors on the digital pins, so you can set these and all the switches would need to be connected to is the GND side of that power.  This won't save you any power, but it will reduce the component count (by eliminating those resistors).

A description of how to use this is here.

The reason for this method is a desire to save power for something that will be used infrequently.
Depending on how many of these inputs there are, there could be scope for putting the microcontroller in a sleep mode and monitor those inputs for waking it.  A description of this is in this Playground page.

Cheers ! Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Brisbane, Queensland
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Hello
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks all for your replies.

Thanks Rob for clarifying the operational schema.

Geoff, I understand about using the built in input pull ups, but my concern was that the pull ups won't be active until they are declared in the setup() part.  But I guess it wouldn't matter because the switch that's active will be the only one that is low, and the rest of the inputs should be high, correct?

I did look into sleep mode but I understand that with the built in components like the 5v reg the sleep mode doesn't save that much power.  There are solutions to that obviously, but I see the most power efficient way of working as there being zero current draw when the device is not being used.

Thanks again

Ash
Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ash

The code will read the present state of the input at the time you read - it doesn't rely on watching for a change (unless you want it to) so if a switch is already set on power up it will be fine.  The time from power on to getting to the first pin state read will be measured in milliseconds.  If this is a push-button switch I'm expecting that will be fine as they don't change that quickly.

You're right to point out the linear regulator but that can be bypassed by feeding 5V from a switch mode supply, battery etc into the 5V pin directly.

Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8475
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But I guess it wouldn't matter because the switch that's active will be the only one that is low, and the rest of the inputs should be high, correct?
Yep.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Brisbane, Queensland
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Hello
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again guys, you have both been a great help with my project.

Ash  smiley-cool
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ash

The code will read the present state of the input at the time you read - it doesn't rely on watching for a change (unless you want it to) so if a switch is already set on power up it will be fine.  The time from power on to getting to the first pin state read will be measured in milliseconds.  If this is a push-button switch I'm expecting that will be fine as they don't change that quickly.

You're right to point out the linear regulator but that can be bypassed by feeding 5V from a switch mode supply, battery etc into the 5V pin directly.

Geoff

Will it be just milliseconds? Or does it not have to wait for the bootloader to 'time-out' after waiting a fixed amount of time to see if there is an active upload request coming from the IDE?

Bootloader behaviour on how long it waits has changed over the years depending on the specific bootloader version installed on the chip. Seems to me the some older bootloader designs always waited a fixed period (some seconds? checking for a upload request) no matter if the bootloader started via a hardware reset or a power-up state. Seems that (some?) new bootloaders do the IDE upload check only after a reset condition, but if it was a power up condition it does a 'no wait' and will immediately jump to the users code (assuming there was one burned to flash from a prior upload to jump to).

Just asking, as the now pretty long legacy of Arduino hardware and software can create some rather confusing situations for users depending on the age of their boards.

Lefty
Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Lefty

I totally get what you're saying.  Certainly I meant from the time his user code starts running to the first time it will be possible to read his switch pin states.

Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Cape Town South Africa
Offline Offline
Edison Member
*
Karma: 19
Posts: 1217
A newbie with loads of posts, and still so much to learn !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I used to use the Holtek HT12 encoder chips in remote controls for years, and just supplied power to the chip when any button is pressed, and it transmits virtually instantaneously.
Then I got introduced to Arduino, and thought I could do the same, but it takes several seconds ( the way I had it set up in my ignorance ) for the chip to boot up and transmit,  so I opted for the sleep mode and an interrupt on the buttons. ( I have the chip on a separate PCB and power the transmitter and LED from the press to talk pin, so that only the 328 chip is drawing any current in sleep.

I am using 3 AA batteries so there is no regulator to draw current

I basically copied the sleep code Crossroads posted, and get the quiescent current down to 350 microamps.  Some of the  guys get it down much lower, but at some point the shelf life of the battery runs out.

The batteries last a season ( Sports scoreboards )  before changing
Logged

With my mobile phone I can call people and talk to them -  how smart can you get ?

Pages: [1]   Go Up
Jump to: