- Startup and Shutdown - Day to Day Operation
- Hardware Overview - To get familiar with the parts and terminology
- Hardware Setup - How everything is put together
- Software Overview - Under the hood a little
- Using the Web Application - Connecting, controlling and making changes to settings
- Troubleshooting - Common things that might go wrong
- Resources - Notes and other things
Startup and Shutdown Procedure (top)
- Obtain the sculpture address of the Operator's control panel from IT.
- Navigate to the website using Chrome of Firefox.
- Log in with the Operator's Credentials
- Go through the soap changing ritual
- Use remote to turn on Pump
- Click
START
- Logout
- Log in with the Operator's Credentials
- Click
STOP
at any point and wait for the sculpture to close - Use the remote to stop the pump.
- Pump soap from dish.
- Pump water into dish.
- Use the remote to start the pump.
- Run to flush soap
- Use the remote to stop the pump.
- Logout
Hardware Overview (top)
- 2x 12V 29A DC power supply by Mean Well (LRS-350-12)
- Raspberry Pi4B Single Board Computer
- Pololu Dual G2 High-Power Motor Driver 18v22 for Raspberry Pi
- 2x 131:1 Metal Gearmotor 37Dx73L mm 12V with 64 CPR Encoder (Helical Pinion)
- Pump Motor
- Custom PCB with terminal blocks for connecting motors and PWM variable speed motor driver
- Black Acrylic Base
- Various standoffs and screws
Note: Motor enclosure dimensions 4.5" diameter, 5.25" length, hole 1.5"x9/32" 1.5" from the back.
- 7' cable for each
- Grey if possible
Hardware Setup (top)
NOTE: Before wiring up the installation, complete these steps and proceed to the Using the Web Application to test that everything is wired properly and running smoothly
Before starting, make sure that all connection to VAC 120 mains power are disconnected.
- Mount
Power Supply
to Base - Mount
Raspberry Pi
standoffs to base
- Insert pre-formatted
SD Card
intoRaspberry Pi
- Mount
Raspberry Pi
to standoffs and fasten using standoffs for theMotor Driver Shield
.
- Fit Motor
Driver Shield
onRaspberry Pi
GPIO header pins and fasten with screws.
- Fit the Custom PCB on the
Driver Shield
taking care to align ALL header pins with ALL header holes. Press firmly in place.
- Visually inspect the space between the PCB and the components beneath it. There should be zero contact with anything beneath, especially if it is metal.
NOTE: Before you begin wiring Be sure to strip, tin, and trim wires (if necessary) so that they can be cleanly inserted and secured into the terminal blocks
- Strip insulation off the ends
- Twist the conductors to make a tight bundle
- Tin conductors with solder
- Trim conductors to ~2mm
- Open terminal block completely with screw driver by screwing CCW (should hear/feel a slight click when end is reached)
- Insert tinned and trimmed wire ends into the terminal block. (Leave no conductor material exposed)
- Close the block with screw driver by screwing CW until tight
- Give a gentle tug to ensure the connection is secure
- The
Pump Motor
now runs on a completely separate circuit. For the SFMOMA installation, a 12V 10A power supply was mounted in the ceiling and controlled using a remote controlled relay on the 120VAC connection.
MOTOR ENCODERS (Grey 4-conductor)
----------------------------------------------
Wire Color Function Terminal Block
----------------------------------------------
Black Encoder GND PCB +
Red Encoder +5V PCB -
Yellow Encoder 1 PCB A
White Encoder 2 PCB B
- Connect
Green (-)
andBlue (+)
wires from theDriver Shield
to the corresponding 2-connectionTerminal Block
. Screw tight with precision flat head screw driver and tug gently to ensure they're secure.
- Connect the wires for the
Motor 1 Encoder
as shown below.
- Connect the wires for the
Motor 2 Encoder
as shown below.
NOTE:
- Ensure that the top PCB is seated properly in the header socket below by gently pressing down along the top edge. Do this after making any adjustments to the wiring or (re)positioning of the board
- Visually inspect the space between the PCB and the components beneath it. There should be zero contact with anything beneath, especially if it is metal.
- Visually inspect each terminal block connection to ensure that there are no exposed conductors, frayed wires, anything that might cause a short.
- Check terminal block connections using needle nose pliers, give each wire a gentle tug to ensure that is firmly secure
MOTOR POWER (for each motor)
----------------------------------------------
Wire Color Function Terminal Block
----------------------------------------------
Red Motor +V Motor Driver +
Black Motor GND Motor Driver -
- Connect ~120 VAC power to the
Power Supply
using the following chart:
~120 VAC Wire Color Code:
==============================================
Color Function Terminal Block
----------------------------------------------
Black Line L
White Neutral N
Green Ground GND (symbol)
- Double check that ALL connections are correct!
- Connect the power supply to mains power when ready to proceed to testing and configuration.
Software Overview (top)
- Debian Linux RaspiOS -
Linux 7s7z1s2z 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l GNU/Linux
- Wireguard VPN Client
- Main 7s7z1s2z
server.py
script- Configuration files
MotorControl
python class defined inmotor_control.py
Encoders
class defined inencoders_serial.py
- Tornado Web Application
- Assets located in
static/
andtemplate/
directories
- Assets located in
- Install and uninstall bash scripts.
systemd
unit descriptor for7s7z1s2z.service
systemd
unit descriptor for7s7z1s2z_shutdown.service
- There is an automated configuration script setup using Ansible in the event that setting up replacement or test environments is necessary. Documentation on that forthcoming.
- Although hardware, the Arduino Nano is running software that is used to count and decode the rotary encoders to provide position data via Serial to the Raspberry Pi.
- Python3.7
- packages:
python3-pigpio
,python3-tornado
,python3-serial
,python3-serial-asyncio
- drivers: https://github.com/pololu/dual-g2-high-power-motor-driver-rpi
- Web Application is located at
https://7s7z1s2z.local
when accessing from the same network. Does not need the internet to run, but internet is required for remote management. - Wireguard VPN permits secure remote access as long as the Raspberry Pi is connected to the internet.
- Password Login is Enabled for
ssh
usermembrane
ssh
login by key is also possible locally and remotelysystemd
is used to manage the startup and shutdown of the software running the sculpture via7s7z1s2z.service
.7s7z1s2z_shutdown.service
is meant to provide a clean stop in the event that a system shutdown command is issued.
- Used to create an encrypted tunnel for remote access. Requires that my Virtual Private Server is up and that the Wireguard VPN Server is running.
- VPN IP Address:
10.42.0.100
- Custom
wg_setup.sh
scripts used bywg_setup@.service
to manage VPN interface. Configuration and environment files are located in/etc/wireguard/
- Executed by
7s7z1s2z.service
at boot. - Creates and instance of
MotorController
andTornado Web Application
server. - The HTTP(S) server is managed by Tornado's IOLoop.
- The
MotorController
instance runs in a separate thread. Full asynchronous managementasyncio
is a place where the code and be optimized in the future.
Provides all the resources necessary to control the main gear head motors and the pump motor
- dependencies: Custom
Encoders
class fromencoders_serial.py
, anddual_g2_hpmd_rpi
module provided by Pololu. - Runs in a thread separate from the main
server.py
thread. - Asynchronously handles WebSocket messages
This class handles communication between the RPi and the Arduino over Serial in an asynchronous manner. Values can be accessed safely by synchronous code.
- Subclasses threading.Thread
- Has its own asyncio event loop
- Reads and writes serial to the Arduino Nano to obtain and clear encoder counts.
Software that uses interrupts to count encoders and serial to communicate the count and clear the count on any data received
- Uses external interrupts
INT0
andINT1
on pins D2 and D3 respectively. These detect changes on the A pin of each encoder. - ISRs manually enabled and defined rather than using
attachInterrupt()
- Serial is sent and buffers checked every 10ms.
- The output format is
<encoder1Count>|<encoder2Count>\r\n
- Any character received by the Arduino will clear the counts. Only a single
\n
character should be necessary to clear.
- The output format is
- Requires authentication!
- There are separate accounts setup for Operation and Calibration
- Operators should not be allowed to access Calibration unless properly trained.
- Requires the javascript be enabled
- Uses self-signed SSL certificates to achieve a secure encrypted HTTPS connection, which may cause mobile devices to reject attempts to create a web socket connection.
- Uses WebSockets to pass data between the browser and the application
- Displays current status, updated every second
- Displays WebSocket connection status
- Interface for changing the state of the sculpture, updating parameters/settings with session store/recall/apply, and load/write defaults.
- Components:
static/favicon.ico
- cute icon for the browser tabtemplates/login.html
- login pagetemplates/calibration.html
- calibration control panel pagetemplates/operation.html
- operator's control panel pagestatic/jquery-3.5.1.min.js
- simplified javascript access/control of DOM elementsstatic/style.css
- CSS styling of elementsstatic/calibration.js
- WebSocket handing for calibration.htmlstatic/operation.js
- WebSocket handing for operation.htmlstatic/Fira_Mono/
- font
- Sets routes for about resources.
- Defines which actions to be handled and how.
- Creates and manages the
MotorController
instance.
install.sh
- use for fresh installuninstall.sh
- removes all install components
Using the Web Application (top)
- Ethernet connection can be used to access the device locally. Simply connect an ethernet cable between the Raspberry Pi 4 and your device (laptop/desktop required). This method is recommended when setting up for the first time.
- Ethernet should be used to connect to the museum network. Ensure that the ethernet connection is on the same subnet as the WiFi network OR is given an IP address that is accessible from the museum WiFi (non-public/staff only).
- WiFi can be configured to connect to the museum WiFi network. In which case, stuff wishing to access the device must be connected to the same network.
- Navigate to
https://7s7z1s2z.local
- You will likely see a warning from your browser that the certificate is invalid. Make an exception to access the page using the options provided by your browser.
- Login is required. Sessions expire after 1 day.
- Failed login returns to the login page, no status is displayed.
- Successful login loads the
Control Panel
.
START
will open the sculpture and run the open/close routine until stopped. It can be pressed at any moment.STOP
will close the sculpture and pause it. It can be pressed at any moment.!!EMERGENCY STOP!!
is to be pressed in the event the motor movement will cause injury or harm to visitors or the sculpture itself. If pressed, contact Phillip Stearns. Assessment of why it was necessary to use this feature will have to be done to determine whether it's safe to continue.
Current Settings & Status
- This section relies on websockets to poll and update the values seen here. They are a reflection of the current parameters governing the behaviors of the installation.Change Settings
section relies on websockets to push values entered here to the installation.logout
ends the session and requires the user to log back in again. Sessions are valid only for 24 hours. Logging out at the end of each session is highly recommended to ensure security for the safety of the sculpture and visitors.Websocket status:
indicates whether the sculpture is connected to the7s7z1s2z Control Panel
web page.Current Status
andChange Settings
require the status to beConnected
Displays the current status of the sculpture and the settings currently running.
Machine State
andLast Machine State
:STOPPED
- Indicates that the!! EMERGENCY STOP !!
has been pushed.STARTUP
- Indicates whether the control program has just been started.OPENING
- Sculpture is in the process of opening.HOLDING OPEN
- Sculpture is open and holding open.CLOSING
- Sculpture is in the process of closing.HOLDING CLOSE
- Sculpture is closed and holding closed.PAUSED
- Sculpture movement has been suspended by the user.- Notes: Machine State is the CURRENT state and Last State was the state the sculpture was in when the user pressed
PAUSE
orSTOP
. States progress in order with OPENING following the completion of HOLDING CLOSED.
Motor Power
: Value applied to the Driver Shield, min/max range -480/480. (float)Motor Position
: Encoder event count. 8400/rev (int)Motor Speed
: Encoder Events / Loop DelayMotor Flipped
: Whether the motor direction is reversed (boolean)Motor Offset
: Offset Motor Position by N counts (int)Current Time
: seconds since linux epoch (float)State End Time
: time when the current machineState should complete (float)Durations
: time in seconds for how long each machine state should take to complete. (float)Startup Duration
: How long the pump is given a chance to coat the cables in liquid soap.Open Duration
: amount of time it takes to move from CLOSED to OPEN.Open Hold Duration
: amount of time to hold the sculpture open (HOLDING OPEN).Close Duration
: amount of time it takes to move from OPEN to CLOSED.Close Hold Duration
: amount of time to hold the sculpture closed (HOLDING CLOSED).
Target Open
: Open position expressed as encoder event counts (int)Target Close
: Closed position expressed as encoder event counts (int)Target
: The position the motors are aiming for. This changes based on the progression through each machine state.Progress
: 0.0 = closed, 1.0 = openSigmoid Function
: The currently selected motion smoothing function.Loop Delay
: Interval between triggering of the mainMotorController
motionControl
method. (float)
-
Go To:
- Clicking buttons immediately change the state of the sculpture. Totally safe to do whenever.OPEN
: opens the sculpture. keeps running without pause. (can be used to start the installation)CLOSE
: closes the sculpture keeps running without pause.OPEN & HOLD
: opens the sculpture then pauses.CLOSE & HOLD
: closes the sculpture then pauses.PAUSE
: pauses progress in any state.RESUME
: resumes progress of thePAUSED
orSTOPPED
(can be used to start the installation).
-
!! EMERGENCY STOP !!
- Issues a command to the MotorController to set motor power to 0.0 and the pump power to 0.0 (hard pause)
- Can be exited by clicking
RESUME
only. - NOTE: This feature was put in place in the event that the motors begin to spin erratically. It may not work under certain circumstances and power may need to be disconnected. It's recommended to have the sculpture on a dedicated breaker or switch that is easily accessible.
Changes to the settings below cannot be performed when the installation is moving. Best practice is to click either OPEN & HOLD
or CLOSE & HOLD
and wait for the "Machine State" to reach PAUSED
.
Note: It is possible to edit the parameters below without applying.
-
Motor Flipped
- checkbox to flip the direction of each motor (boolean) -
Motor Offset
- number input to set the offset values for each motor (int)- Use
set
buttons to push the values to the sculpture (Apply Settings
no longer works here) - Use
apply offsets
when the offsets achieve the desired balance between sides
- Use
-
Durations
- number inputs to set the durations for each state (int). Cannot be negative!!! -
Targets
- number inputs to set the OPEN and CLOSE positions (int) -
Sigmoid Function
- select input to choose a motion smoothing algorithm. Controls the easing of the motor out of closed and into open positions. -
Power Multiplier
- Power is determined by distance from target. Multiplier scales the effect of being off target. 1 peans there is a 1:1 distance to power relationship. Increase if motors hesitate -
Power Easing
- gradually applies power changes based on this percentage. 1.0 for no easing. lowest recommended easing value is 0.125. If the powers are over shooting, reduce value. If the motors are pulsing, increased value. -
Power Limit
- hard limits the power sent to the motors. Increase only if motors are struggling. 480 is the max. -
Loop Delay
- controls the timing of theMotionController
motionControl
loop. Adjust to smaller value if motion stutters in a rapid pulse or is jerky/jittery. Adjust upwards to free up system resources. Ideally this should not need to be changed. -
Click
Apply Settings
to push the above settings to the sculpture
Apply Settings
:- Pushes values in
Change Settings
fields to theMotorController
, which should translate over to theCurrent Status
- Pushes values in
Save Applied/Current Settings
:- Temporarily saves the current settings running on the
MotorController
to be recalled later in the same session.
- Temporarily saves the current settings running on the
Load Last Saved Settings
:- Loads the previously saved settings from the current session into the
Change Settings
fields. ClickApply Settings
to push to theMotorController
. Think of the above two steps as a multi-step undo.
- Loads the previously saved settings from the current session into the
Load Default Settings
:- Loads the
Default Settings
from disk into theChange Settings
fields. ClickApply Settings
to push to theMotorController
.
- Loads the
Write Applied/Current Settings to Default
:- Writes the current applied settings running on the
Motor Controller
to disk. The sculpture will use these settings when it is restarted. - NOTE: Make sure that motor offsets have been applied and are zeroed out in the "Current Settings & Status" column.
- Writes the current applied settings running on the
Troubleshooting (top)
- Stop the installation immediately.
- If the remote is not available to power off, then do so from the control panel.
- Contact Phillip Stearns immediately.
- Likely causes:
- Encoder wires have become disconnected
- Check the motor connector
- Check the PCB terminal block connections
- Someone/thing has pulled hard on the counter weight, causing the motor to break its position lock.
- Power off everything, reset to zero, power on.
- Encoder wires have become disconnected
- The Pump is on a remote controlled outlet.
- Visually confirm that the outlet switch indicates that it has power and is on (red light) and is responding to button presses.
- Check that the power supply (installed in the ceiling) is powering up and outputs 12V DC with the motor disconnected from the supply.
- Connect the motor to the 12V DC terminals.
- If arcing occurs but no pump movement
- there may be a short somewhere
- the pump may be clogged and preventing the motor from turning
- the motor may have failed
- If arcing occurs but no pump movement
- Check the terminals of the pump motor
- If 12V DC can be measured at the terminals but no movement is observed
- Check the pump for blockage
- The motor may have failed
- If 12V DC can be measured at the terminals but no movement is observed
Additional Resources (top)
Previous version of this piece used an arduino mega. Code was written in C++ for Arduino using the standard IDE. This version of the piece will use a raspberry pi to control the motors.
- Install pigpiod:
sudo apt install python3-pigpio python-pigpio
- Enable
pigpiod
daemon:sudo systemctl enable pigpiod
- Start the
pigpiod
service:sudo systemctl start pigpiod
- Clone the Pololu driver repo:
git clone https://github.com/pololu/dual-g2-high-power-motor-driver-rpi
- Change into the cloned repo directory:
cd dual-g2-high-power-motor-driver-rpi
- Run the install script: `sudo python setup.py install