Servos and power saving modes

Hi all,

I've given myself a project - to build electronic gear shifters for my bike with my Arduino uno.

So far, I've finished what I'd consider to be a proof of concept. Two push buttons for shifting up and down, a hardcoded array of positions and a servo that jumps between each of those positions as and when a button is pushed. I'm a complete beginner so I'm still surprised just to get this far.

Anyway, I'm now thinking of the practicalities of how it'll actually work and I could do with some help in actually bringing it to life. The plan is to run it on one of those USB power banks. This leaves me with a problem however.

Power consumption. I'd like to automatically power down when I'm not changing gear; running out of power and being stuck in a single gear wouldn't be ideal. I understand that you can effectively put the board to sleep, although this isn't massively beneficial on unos (wouldn't be averse to changing board but I'm not sure that would fix things anyway). Interestingly, my power bank cuts out if it the power drawn from it remains below a threshold for 30s, and that threshold is above the power consumed just to run the board and below the amount required to move the servo. So everything stays powered up until I go for 30s without shifting, which is pretty much perfect.

Unfortunately, this leaves me with a long list of other problems.

Waking the power supply back up again. There's a button on the power bank that wakes it back up again. I've thought about opening this up and wiring up both of my shifter buttons to this but unsure how to go about it. They are straight forward 2 pin push buttons - given that, when everything is live, there's 5V from the Arduino going through them, would this damage the power bank? I feel like I'd ideally want a push button that's capable of completing 2 entirely separate connections at once, not sure if that's a thing.

Responsiveness when waking up. Ideally, the power supply would turn on with one push of the button and immediately shift accordingly. At very least, I'd want to be able to get to the stage of pressing the button once to switch on, then again a second or so later to tell the Arduino to shift. Is that realistic?

Stopping the servo's random movements when the power comes on. At the moment, whenever the power supply is turned on, the servo wobbles about a bit before settling on the spot it's supposed to be in. That's obviously not practical if I'm riding along - is that something that all servos always do or is there more likely something up with my code?

Knowing where the servo is when the power supply comes back on. My understanding is that the Arduino will forget any variables that have been defined when it turns back on. So without feedback from the servo, it won't know what the current gear is and it won't know what gear to shift to when I push a button. Any chance there's a way around this? I've seen customised servos that have been wired up so that the internal potentiometer can be read, so I guess that's always an option.

As you can see, I'm basically just dumping everything in my brain onto this forum. As you can probably also see, I don't entirely know what I'm doing! So any helpful nudges in the right direction from anyone with a bit of knowledge would be greatly appreciated.

Thanks,

James

I understand that you can effectively put the board to sleep, although this isn't massively beneficial on unos (wouldn't be averse to changing board but I'm not sure that would fix things anyway).

Please explain this. If you desolder the power LED power saving is quite effective.

Responsiveness when waking up. Ideally, the power supply would turn on with one push of the button and immediately shift accordingly. At very least, I'd want to be able to get to the stage of pressing the button once to switch on, then again a second or so later to tell the Arduino to shift. Is that realistic?

No, because the Arduino will wait some time in the boot loader when powering up. You would have to strip away the boot loader or have the Arduino power constantly and using the power saving functions.

Knowing where the servo is when the power supply comes back on. My understanding is that the Arduino will forget any variables that have been defined when it turns back on. So without feedback from the servo, it won't know what the current gear is and it won't know what gear to shift to when I push a button. Any chance there's a way around this? I've seen customised servos that have been wired up so that the internal potentiometer can be read, so I guess that's always an option.

The Arduino has an internal EEPROM. You can simply store the gear into the EEPROM every time you change it. You can write each EEPROM cell about 100'000 times, so this shouldn't be a limitation for your case.

pylon:
Please explain this. If you desolder the power LED power saving is quite effective.

No, because the Arduino will wait some time in the boot loader when powering up. You would have to strip away the boot loader or have the Arduino power constantly and using the power saving functions.

The Arduino has an internal EEPROM. You can simply store the gear into the EEPROM every time you change it. You can write each EEPROM cell about 100'000 times, so this shouldn't be a limitation for your case.

Thanks for the input. Re my impression that power saving wasn't all that beneficial, I was purely going off what I'd read, but the desoldering sounds like a good suggestion.

So let's say the I wake the Arduino up from power saving mode - presumably that cuts the waiting time as it's not powering up from scratch. Does it remember the variables that were previously defined or would I still need to have to have stored them in the EEPROM? I'm feeling like this is the way to go now, I just need to adjust my code for sleeping/waking and to keep the power supply on.

Thanks again.

James

So let’s say the I wake the Arduino up from power saving mode - presumably that cuts the waiting time as it’s not powering up from scratch. Does it remember the variables that were previously defined or would I still need to have to have stored them in the EEPROM?

The contents of the RAM are saved during all sleeps, so no, you don’t have to store in EEPROM if you’re putting the Arduino to sleep.