What is the relationship between the signals RPI running and Rpishutdown on the controller?

@cleoqc

What is the relationship between the “RpiRunning” and “Rpi shutdown” pins on the controller boardard to
Are they active high or low?

My idea is if there’s a convenient pin that’s active low when the GoPiGo is active, I can tie it to the !ready line on the buck/booster board to force a complete shutdown of the bot, including the external power supply boost, when the robot is shut down for any reason.

2 Likes

gopigo3_power.py:

# This code is for power management on a Raspberry Pi with GoPiGo3.
#
# GPIO 22 will be configured as input with pulldown. If pulled high, the RPi will halt.
#
# GPIO 23 needs to remain low impedance (output) set to a HIGH state. If GPIO 23 gets
# left floating (high impedance) the GoPiGo3 assumes the RPi has shut down fully.
# SW should never write GPIO 23 to LOW or set it as an INPUT.


import RPi.GPIO as GPIO
import time
import os

GPIO.setmode(GPIO.BCM)
GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

GPIO.setup(23, GPIO.OUT)
GPIO.output(23, True)

while True:
    if GPIO.input(22):
        os.system("shutdown now -h")
    time.sleep(0.1)

NOTE: GPIO is set to BCM mode so

  • BCM 22 is the power switch (V=0 below)
  • BCM 23 is “RPi Running” (Set True, see V=1 below)
pi@Carl:~/Carl $ gpio readall
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 1 |  3 || 4  |   |      | 5v      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | IN   | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 1 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 1 | OUT  | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 1 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 1 | 21 || 22 | 1 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | OUT  | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
3 Likes

So, what does this mean in real terms?

2 Likes

RPi Shutdown is normally pull down low v=0 - “active” high v=1
RPi Running is “active” high v=1

You will need to pick an unused GPIO pin and chron a RPi.GPIO program to pull it low when the RPi is running:

Unused pins of 40 pin connector (9 GPIO available):

27: ID_SD (I2C ID use only)
28: ID_SC (I2C ID use only)
29: GPIO5
30: Gnd
31: GPIO6
32: GPIO12
33: GPIO13
34: Gnd
35: GPIO19
36: GPIO16
37: GPIO26
38: GPIO20
39: Gnd
40: GPIO21

enable_power_supply.py:

import RPi.GPIO as GPIO
MYENABLE = 21   # BCM 21 is Pin 40

GPIO.setmode(GPIO.BCM)
GPIO.setup(MYENABLE, GPIO.OUT)
GPIO.output(MYENABLE, False)
2 Likes

There are two potential problems with that:

  1. Cron jobs don’t have an “on shutdown” qualifier.  To implement that I’d have to create, (or modify), one of the shutdown services or scripts.

  2. I don’t want it to be purely dependant on software.  I want the primary dependency to be on the actual hardware.  I already have enough software to maintain as it is!

Also, there are already signalling pins that I can use - worst case I have to invert one with a MOS switch or a transistor configured open-collector.

Now all I have to do is find my box of transistors. . . .

2 Likes

Findings:

The signal RPI_RUNNING:

  • Is active high.

  • Asserts itself high when the green power LED stops flashing and comes on solid.
    (i.e.  The GoPiGo O/S is up, the GoPiGo libraries are loaded and active, and the GoPiGo robot systems are fully running; though there may be post-boot scripts and tasks to run.)

  • De-asserts itself when the red power LED goes completely off.  (Fully powered down)

With a way to invert this, I’ll have a status pin I can monitor to shutdown the external supplemental 5v supply.

3 Likes