PDA

View Full Version : Auto shutdown



Brooks
05-31-2016, 12:13 PM
I'm concerned about killing expensive LiPos. And I know that Raspberry Pi (RPi) systems should not be killed, but should be properly shut down.

Knowing that the RPi issue will require coordination between the boards, I'm going to leave that issue alone until I solve the communications problem. But knowing I have a processor in the Abortix-M board, and I can program, I've decided to have the Arbotix un-power the entire hexapod if it hasn't been asked to move for maybe a couple of minutes.

I'm going to add two push-buttons alongside the power switch: Start and Stop. The Stop button will be read by the Arbotix and used, along with a "no changes" timer, to decide whether power-down the system. And maybe beep as it goes...

In series with the existing power switch I'm going to add a power MOSFET whose gate input will be driven by the Arbotix and can also be made active by the Start button.

To start, turn the switch on and press the Start button briefly. To stop, let the hexapod time out or press the Stop button.

Both the electronics and the firmware are fairly simple. Let me know if you want more details.

-- Brooks

_ADAM_
05-31-2016, 12:35 PM
Are you using Dynamixels on the Arbotix? If so, you can get the current voltage from the control table and take the appropriate action(start beeping, execute a shutdown, etc). This assumes you are sharing the battery between the Dynamixels and Pi.

If using separate batteries (which I may do on one of my bots), you can use something like the Phidgets voltage sensor for the Pi's battery.

My code is going to regularly poll the voltage, then when it reaches a pre-defined threshold, it will execute a shutdown routine - put the bot in a resting pose, disable torque, shutdown the pi, etc.

Brooks
05-31-2016, 03:40 PM
I hadn't thought of monitoring the battery voltage! I like the idea. I am using Dynamixels.

I'm going to go beyond minimal power consumption to zero power consumption.

I was originally thinking of using a servo to toggle the power switch off! :wink:

jwatte
05-31-2016, 05:13 PM
I know that Raspberry Pi (RPi) systems should not be killed, but should be properly shut down.

Actually, I hard-power-off my Pis all the time, and they generally do OK. Sometimes, a git repository will be corrupted, especially when using BTRFS. Not had any problems with NILFS2. Haven't run EXT4 enough on it to know how solid it is. A cron job that calls "/bin/sync" once a minute probably helps.

I've built voltage detection and soft-power-off into almost every circuit I've made in the last few years, because that's the only way I'm going to not kill my LiPos ... A P-channel MOSFET on the positive input, with a 5 kOhm pull-up from the gate to the positive, and a signal N-channel pulling its gate to ground through a LED, makes for a fine switch.
A button parallels the N-channel MOSFET to turn on the thing.
I drive the gate of the N-channel with a GPIO pin of some sort, and a soft pull-down on its gate.
When the CPU boots, it sets the GPIO high, to keep power on. Thus, I press the "on" button until the system is on (which for most systems with microcontrollers is a few milliseconds.)
You can also make it "latch" on with a weak pull-up resistor to the N-channel gate from the switched on-power.

The microcontroller measures the voltage of the battery, through a voltage divider. When it finds < 3.1V/cell, it pulls the GPIO low, which will turn off power.

I should probably make a schematic. This is a very convenient circuit!

_ADAM_
05-31-2016, 05:52 PM
Related to this topic -

How are you all providing battery power to your Pis? Are you connecting to the 5V GPIO pin?

jwatte
05-31-2016, 05:59 PM
Yes, I connect LiPo to a DC/DC buck converter (4.5A) and that generates 5A that I wire to both the 5V pins.

Btw, here's the schematic for the Canonical Power Switch Circuit:


https://watte.net/canonical-power-switch.png


(Of course, "canonical" is a joke -- everybody has different requirements, like perhaps overvoltage/transient protection, or a PTC resettable fuse, or current sensing, or whatever...)

KevinO
05-31-2016, 06:51 PM
Related to this topic -

How are you all providing battery power to your Pis? Are you connecting to the 5V GPIO pin?


I used a Castle Creations BEC. It has a programmable output voltage and could handle up to 24v as an input. It was able to produce 5 amps so it easily powered the Pi, Prime Sense sensor and camera without issue. It was twenty bucks but was super small and worked flawlessly.

http://www.castlecreations.com/products/ccbec.html

KurtEck
05-31-2016, 07:13 PM
Related to this topic -

How are you all providing battery power to your Pis? Are you connecting to the 5V GPIO pin?
Depends: Normally I do like Kevin and use an external BEC. But the HROS1, was setup to connect the RPI up to +5v from pins on the Arbotix Pro. However the VR on the Arbotix Pro produces up to 1.5amps. So when I am hooking up to Odroid, I again have used BEC connected up to power connector.

However soon will be trying out my own HAT for RPI/ODroid/UP
6604
Boards shipped from OSHPark today, just ordered parts to populate today, so hopefully in week or so will be able to try out.
I ordered the 6amp VR, which I feed the +5v pins on the RPI connector. so hopefully enough power for boards plus their USB.

Also like ArbotixPro have Mosfet on board to cut power to servos. My psuedo Arbotix Pro code has code in place that detects the voltage and if it gets too low shuts power off to servos. Board has voltage divider on it so can query it for current voltage. Will add code to may Hexapod code that when it detects too low, will probably tell RPI to shutdown. Also at some point will have Teensy go into some real low power mode.

I totally understand the problem of killing Lipos as I have killed a few!, Which was why in the Raspberry Pi code, I added some code that when I turned off the Commander, the code would turn off the torque to the servos. But sometimes I forgot to turn off the switch, so I added code that would alternate through all of the servos turning the LED on and off. This uses power, but does catch my eye, to then hopefully turn off the power before it is too late.

_ADAM_
05-31-2016, 08:52 PM
I used a Castle Creations BEC. It has a programmable output voltage and could handle up to 24v as an input. It was able to produce 5 amps so it easily powered the Pi, Prime Sense sensor and camera without issue. It was twenty bucks but was super small and worked flawlessly.

http://www.castlecreations.com/products/ccbec.html

That's a sweet BEC, thanks for the tip.

_ADAM_
05-31-2016, 08:59 PM
What do you all think of the Pi-EzConnect Terminal Block Breakout HAT? Seems like it would really make the power and port access much better. It adds some size, but it's not really all that bulky. I'm really not a fan of sticking those little jumper connectors on pins. The screw terminals are infinitely better.

https://www.adafruit.com/product/2711

Also, there is the MoPi, which has a wide voltage input range and can be programmed to auto shutdown a Pi if the voltage gets low.

https://pi.gate.ac.uk/pages/mopi.html

I'm not really that interested in the MoPi, seems a bit complicated, but the EzConnect has me thinking...

jwatte
06-01-2016, 04:05 PM
The problem with "breakout" boards is that they add bulk. For these bots, shrinking everything into a single device is major space savings!

_ADAM_
06-01-2016, 05:06 PM
Depends, if there was going to be empty space above the board anyway, then it doesn't really matter. I'll prolly pick one up just to try it out. The terminals are enough to make me want it, but the built-in prototyping areas are a nice feature as well.

KurtEck
06-01-2016, 06:05 PM
The problem with "breakout" boards is that they add bulk. For these bots, shrinking everything into a single device is major space savings!
I totally agree. Right now on my PhantomX, I have a total stackup of boards, with ODroid with Adapter to fit PhantomX Hole patterns, with a Level shifter board, then another adapter to stack the Arobotix Pro above it, plus another adapter, to add the XV Lidar, and you still have a BEC hanging off the side, plus other dongles and their corresponding cables...


Depends, if there was going to be empty space above the board anyway, then it doesn't really matter. I'll prolly pick one up just to try it out. The terminals are enough to make me want it, but the built-in prototyping areas are a nice feature as well.
For me it depends on what all you wish to connect up to...

There are lots of interesting options out there, including several from PI 2 Design, like:
http://www.pi2design.com/store/p3/502IOT_-_Internet_of_Things_Shield.html

But if you do get one, it will be interesting to see how it works out.

_ADAM_
06-01-2016, 07:28 PM
The IoT shield looks interesting, thanks for the link. I actually ordered a Pi-EzConnect today.

KevinO
06-01-2016, 11:20 PM
I had to get very creative on board placement on the phantomX. In some places I had only a few mm clearance.

http://forums.trossenrobotics.com/gallery/files/8/6/6/6/righthex_thumb.jpg (http://forums.trossenrobotics.com/gallery/showimage.php?i=5143)

Brooks
06-02-2016, 05:20 AM
That's pretty crowded! I have the MK III, which seems to have a lot more open space.

KurtEck
06-02-2016, 07:33 AM
That's pretty crowded! I have the MK III, which seems to have a lot more open space.
The MK2 and MK3 are the same size, but the difference here, is that all of his electronics are inside the body, which makes a nice clean look. He has the battery on top as you can see in another of his photos:
6605
Also with the MK2 or MK3 they have an option for a third deck. Earlier I used this on the MK2, but so far resisting on MK3.

KevinO
06-02-2016, 10:55 AM
Kurt is right I wanted that clean look and easy access to the battery. Although as you can imagine getting to the ports after it was all buttoned up was a bit of a challenge. That was a lot of screws. As Kurt mentioned MK1, MK2 and MK3 all have the same dimensions. After I showed Golem with his multiple decks to Trossen they thought it was a good idea to have another deck. :)