Question about interrupts - Page 1
Forum section: electronics / projects

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2023, 03:04:38 am
content: I'm working on a project that's a "hand held" cosplay prop which will run off a battery pack of some kind. The project has 6 servo's. Most of the time the servo's will be stationary and have enough resistance even unpowered to hold their position in this project.Since I have an extra IO pin in my micro controller, someone suggested using an interrupt to cut power to the servo's when they aren't in use. The thought here is that this would improve the battery life. I have a couple questions about this:Will this cause any issues for the servos if I'm randomly cutting power to them?Do the servo's have any "warmup time"? I.e. can I power them and expect them to start moving essentially right away?I only have one open pin so I'd have to put all 6 servo's behind the one interrupt. Any issues with this?Any suggestions on what to use for this component? I don't even know what I would google to find one.Here's my current schematic just in case.

author: moffy
author_rank: Super Contributor
timestamp: April 06, 2023, 04:43:24 am
content: Just a note your wiring diagram shows the 5V of the servos going to GND and the GND of the servos going to 5V, also 2 GNDs of the micro are unconnected.What you are possibly meaning is that a certain period of time after the last button is pushed, monitored by a timer in the micro, the micro goes to sleep. You then , if any of the buttons are pressed have to wake the micro up from sleep, and the micro also has to register which buttons were pushed. This usually involves the buttons triggering an interrupt, but one that is also able to 'wake up' the micro. You would really need pull up resistors on all the push buttons, as the pins might go high impedance during sleep. It is the detail that will determine whether it works or not.

author: jpanhalt
author_rank: Super Contributor
timestamp: April 06, 2023, 05:46:46 am
content: Assuming you are talking about hobby servos, they often show a brief jerk when power is first applied. I am not sure what would happen if you applied signal without Vcc. A lot is IC's can be "back powered" through an I/O pin, so you may nee to interrupt both ground and VCC.What do you plan to use to interrupt power? A P-mosfet? I don't think you want to power servos directly from an MCU output. Many voltage regulator and power management chips have and enable input (often active low). You could also use them to cut VCC to the servos.

author: mikerj
author_rank: Super Contributor
timestamp: April 06, 2023, 09:19:00 am
content: Not sure why you'd need to use an interrupt, other than perhaps to wake the micro from a sleep state. You could certainly power down the servos (e.g. using a suitable power MOSFET) but you would also need to either switch the servo PWM lines to tristate or logic 0 to prevent excess current into the servo when unpowered. As jpanhalt says some RC servos tend to twitch when power is first applied, you'd have to try this to see if yours suffer from this and if so whether it's acceptable.

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2023, 05:17:37 pm
content: Quote from: moffy on April 06, 2023, 04:43:24 amOh oops on the backwards wiring. Wasn't paying attention enough I guess.There is one ground pin on the micro connected to GND. They don't all need to be do they? I assumed they were all internally tied and that connecting one was enough. Actually now that I think about it why are there multiple?

author: Siwastaja
author_rank: Super Contributor
timestamp: April 06, 2023, 05:37:01 pm
content: You have a terminology mixup. What you suggest ("interrupting power supply") has absolutely nothing to do with a thing called interrupts ("interrupting the CPU execution of main thread in order to do something different and then continue execution where it left").I think the best way to proceed is to measure the current draw of your servomotors while fed with constant position input and calculate the effect on battery life; no need to do anything if good enough.

author: jpanhalt
author_rank: Super Contributor
timestamp: April 06, 2023, 07:25:01 pm
content: Quote from: Youkai on April 06, 2023, 05:17:37 pmApparently, SF has a few devices that meet the description on your schematic. Often all grounds do not absolutely need to be connected, but connecting all is usually recommended to maintain low impedance. See this manual (e.g., page 11) from SF:https://datasheets.raspberrypi.com/rp2040/hardware-design-with-rp2040.pdf#minimal-design-example

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2023, 08:10:29 pm
content: Quote from: jpanhalt on April 06, 2023, 07:25:01 pmInteresting. That's good to know. I'll update the schematic to show them all grounded.

author: Youkai
author_rank: Regular Contributor
timestamp: April 06, 2023, 08:18:11 pm
content: Quote from: Siwastaja on April 06, 2023, 05:37:01 pmI see. Maybe I misundrestood what the other person was saying. There will be a physical switch in the line between the battery and the circuit so that you can plug the battery in without having it "on". This would be interrupting the power supply. It's not in my schematic but I was planning to do it.What I assumed the person meant though was a transistor (or whatever is appropriate) on the 5v rail from the left buck such that I could cut power to the servo's when they aren't actively moving. I would need to make sure the DotStar connected to the rail before the transistor. This way the micro could run and wait for inputs and the LED's could still be on and glow but the servo's wouldn't be sucking power the 90% of the time they aren't actually doing anything. The servo's would still be sent positioning commands from the micro on the data line; even when they have no power. I'm not sure if that would cause an issue.

author: jpanhalt
author_rank: Super Contributor
timestamp: April 06, 2023, 08:35:16 pm
content: So you plan to turn the whole system off cold, then restart. Try it and see what happens. How will you ensure that the MCU will start in the last "good" position when it is shut cold off, i.e., you pull the cord, rather than turn itself off? Doable, but do you have a plan for it? And then, there are the servos, Have you address that?

author: macboy
author_rank: Super Contributor
timestamp: April 07, 2023, 01:06:57 am
content: With many servos, if you simply stop the signal, then the control circuit stops driving the motor, and this can save a lot of power. It is my experience, as mentioned already, that most servos will glitch or jerk when power is applied. You probably don't want that.

author: james_s
author_rank: Super Contributor
timestamp: April 07, 2023, 03:27:38 am
content: As I think others have covered, an interrupt is a hardware feature in a microcontroller that when triggered (for example by an input pin changing state or an internal timer overflowing) cause the microcontroller to stop whatever it's doing and jump to a different block of code, then go back and resume the original task. I suspect the person you talked to was suggesting using an interrupt to wake up the micro when a button is pressed.What I would do is take one of the specific type of servos you intend to use and run some tests on it. See what happens when you disconnect power while the position signal is still present, then see what happens when you disconnect the position signal while the servo is still powered and how it behaves when power is applied. There are many internal differences in servos and not all of them behave the same way.

author: Youkai
author_rank: Regular Contributor
timestamp: April 07, 2023, 03:31:09 am
content: Ok thanks for the input everyone. I'll probably start by getting it all wired up and my battery and seeing how long it lasts. It's somewhat of a moot point if it will run for >1hr with no modifications.

author: james_s
author_rank: Super Contributor
timestamp: April 07, 2023, 06:19:46 pm
content: Getting 6 servos to run for an hour should be no problem at all. Lots of guys fly RC gliders for longer periods than that, and they typically have pretty modest batteries.