Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@

- Feature A added
- FIX: nasty bug #1729 fixed
- ADD: Raspberry Pi LG-07 lift control implementation
- Created lift_driver.py with GPIO control for FLTCON remote
- Added hardware test script (test_hardware.py)
- Added command-line application (app.py)
- Added configuration file (config.yaml)
- Added Raspberry Pi setup script (setup-pi.sh)
- Added Pi-specific requirements (requirements-pi.txt)
- Added comprehensive hardware setup documentation
- add your changes here!
71 changes: 71 additions & 0 deletions find_pi.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# PowerShell script to find Raspberry Pi on network
# Run this from PowerShell: .\find_pi.ps1

param(
[string]$Network = "172.20.10",
[int]$StartIP = 2,
[int]$EndIP = 14
)

Write-Host "🔍 Scanning for Raspberry Pi on network $Network.0/28..." -ForegroundColor Cyan
Write-Host "Testing IPs from $Network.$StartIP to $Network.$EndIP" -ForegroundColor Yellow
Write-Host ""

$found = $false

for ($i = $StartIP; $i -le $EndIP; $i++) {
$ip = "$Network.$i"
Write-Host "Testing $ip..." -NoNewline

try {
$ping = Test-Connection -ComputerName $ip -Count 1 -Quiet -TimeoutSeconds 1
if ($ping) {
Write-Host " ✓ ALIVE" -ForegroundColor Green

# Try to get hostname
try {
$hostname = [System.Net.Dns]::GetHostEntry($ip).HostName
Write-Host " Hostname: $hostname" -ForegroundColor Green

# Check if it looks like a Raspberry Pi
if ($hostname -like "*raspberry*" -or $hostname -eq "pi") {
Write-Host " 🎉 Found Raspberry Pi at $ip ($hostname)" -ForegroundColor Green -BackgroundColor Black
$found = $true
}
} catch {
Write-Host " Could not resolve hostname" -ForegroundColor Yellow
}

# Try SSH connection test
try {
$sshTest = Test-NetConnection -ComputerName $ip -Port 22 -WarningAction SilentlyContinue
if ($sshTest.TcpTestSucceeded) {
Write-Host " 🔐 SSH port open" -ForegroundColor Green
} else {
Write-Host " ❌ SSH port closed" -ForegroundColor Red
}
} catch {
Write-Host " Could not test SSH" -ForegroundColor Yellow
}

} else {
Write-Host " ❌ No response" -ForegroundColor Red
}
} catch {
Write-Host " ❌ Error testing $ip" -ForegroundColor Red
}
}

Write-Host ""
if (-not $found) {
Write-Host "❌ No Raspberry Pi found in the scanned range." -ForegroundColor Red
Write-Host ""
Write-Host "Troubleshooting steps:" -ForegroundColor Yellow
Write-Host "1. Make sure Raspberry Pi is powered on" -ForegroundColor White
Write-Host "2. Check Ethernet cable is connected" -ForegroundColor White
Write-Host "3. Try different IP ranges if your network is different" -ForegroundColor White
Write-Host "4. Check router admin panel for connected devices" -ForegroundColor White
Write-Host "5. Try connecting Pi directly to computer via Ethernet" -ForegroundColor White
} else {
Write-Host "✅ Raspberry Pi found! Use the IP address above for SSH/scp commands." -ForegroundColor Green
}
6 changes: 6 additions & 0 deletions requirements-pi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Raspberry Pi specific requirements for LG-07 lift control
# Install with: pip install -r requirements-pi.txt

RPi.GPIO>=0.7.0
# Note: RPi.GPIO is only available on Raspberry Pi
# On other systems, use the test_basic.py script with mocked GPIO
55 changes: 55 additions & 0 deletions setup-pi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Setup script for Raspberry Pi LG-07 Lift Control
# Run this script on your Raspberry Pi to set up the environment

set -e # Exit on any error

echo "🛠️ Setting up LG-07 Lift Control on Raspberry Pi"
echo "================================================="

# Check if running on Raspberry Pi
if ! grep -q "Raspberry Pi" /proc/cpuinfo; then
echo "❌ This script must be run on a Raspberry Pi"
exit 1
fi

echo "✅ Running on Raspberry Pi"

# Update package list
echo "📦 Updating package list..."
sudo apt update

# Install Python and pip if not present
echo "🐍 Installing Python and pip..."
sudo apt install -y python3 python3-pip python3-dev

# Install RPi.GPIO
echo "🔌 Installing RPi.GPIO..."
sudo apt install -y python3-rpi.gpio

# Install the package in development mode
echo "📚 Installing progressive-automations-python..."
cd "$(dirname "$0")"
pip3 install -e .

# Install additional dependencies if any
if [ -f "requirements-pi.txt" ]; then
echo "📋 Installing Raspberry Pi specific requirements..."
pip3 install -r requirements-pi.txt
fi

# Make scripts executable
echo "🔧 Making scripts executable..."
chmod +x src/progressive_automations_python/pi/lg07_lift/test_hardware.py
chmod +x src/progressive_automations_python/pi/lg07_lift/app.py

echo ""
echo "🎉 Setup completed successfully!"
echo ""
echo "Next steps:"
echo "1. Connect your relays to GPIO pins 17 (UP) and 27 (DOWN)"
echo "2. Connect relays to FLTCON UP/DOWN buttons"
echo "3. Test with: python3 src/progressive_automations_python/pi/lg07_lift/test_hardware.py"
echo "4. Or run: python3 src/progressive_automations_python/pi/lg07_lift/app.py up"
echo ""
echo "⚠️ Safety note: Test with short movements first and ensure emergency stop works!"
132 changes: 132 additions & 0 deletions src/progressive_automations_python/pi/lg07_lift/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# LG-07 Lift Control - Raspberry Pi Setup

This directory contains the Raspberry Pi implementation for controlling an LG-07 lifting column via FLTCON remote.

## Hardware Requirements

- Raspberry Pi (any model with GPIO pins)
- Relay board/module (2 relays minimum)
- FLTCON remote control unit
- LG-07 lifting column
- Jumper wires for connections

## Hardware Connections

### GPIO Pin Assignments (BCM numbering)
- **GPIO 17 (Pin 11)**: UP relay control
- **GPIO 27 (Pin 13)**: DOWN relay control
- **GND (Pin 6)**: Common ground for relays

### Relay Connections
1. Connect relay board to Raspberry Pi GPIO pins
2. Connect relay outputs to FLTCON remote buttons:
- Relay 1 (GPIO 17) → FLTCON UP button
- Relay 2 (GPIO 27) → FLTCON DOWN button
3. Ensure relays are configured as **ACTIVE-LOW** (closed when GPIO is LOW)

## Software Setup

### Option 1: Automated Setup (Recommended)
```bash
# Copy project to Raspberry Pi
scp -r progressive-automations-python pi@raspberrypi.local:~/

# SSH to Raspberry Pi
ssh pi@raspberrypi.local

# Run setup script
cd progressive-automations-python
chmod +x setup-pi.sh
./setup-pi.sh
```

### Option 2: Manual Setup
```bash
# Update system
sudo apt update
sudo apt install -y python3 python3-pip python3-rpi.gpio

# Install package
pip3 install -e .

# Install Pi-specific requirements
pip3 install -r requirements-pi.txt
```

## Testing

### Hardware Test (Recommended First Step)
```bash
cd progressive-automations-python
python3 src/progressive_automations_python/pi/lg07_lift/test_hardware.py
```

This will run an automated test sequence:
1. Small UP movement (0.5s)
2. Small DOWN movement (0.5s)
3. Quick UP nudge (0.2s)
4. Quick DOWN nudge (0.2s)
5. Emergency stop test

### Manual Testing
```bash
# Move up for 1 second
python3 src/progressive_automations_python/pi/lg07_lift/app.py up

# Move down for 2 seconds
python3 src/progressive_automations_python/pi/lg07_lift/app.py down --time 2.0

# Quick nudge up
python3 src/progressive_automations_python/pi/lg07_lift/app.py nudge up --time 0.3
```

### Interactive Manual Test
```bash
python3 src/progressive_automations_python/pi/lg07_lift/test_hardware.py
# Choose option 2 for manual testing
```

## Safety Precautions

⚠️ **Important Safety Notes:**

1. **Test with short movements first** - Start with 0.2-0.5 second movements
2. **Have emergency stop ready** - Ctrl+C will trigger emergency stop
3. **Monitor the lift** - Ensure it moves in expected direction
4. **Check relay polarity** - Verify relays activate when GPIO goes LOW
5. **Secure connections** - Loose wires can cause intermittent operation

## Troubleshooting

### Lift doesn't move
- Check relay connections to FLTCON buttons
- Verify FLTCON has power and is paired with LG-07
- Test relays independently (they should click when activated)

### Wrong direction
- Swap relay connections between UP/DOWN buttons
- Check GPIO pin assignments in `lift_driver.py`

### GPIO errors
- Ensure you're running as a user with GPIO access (usually `pi`)
- Check that RPi.GPIO is installed: `python3 -c "import RPi.GPIO"`

### Import errors
- Run `pip3 install -e .` from project root
- Check Python path includes the src directory

## Configuration

Edit `config.yaml` to customize:
- GPIO pin assignments
- Default timing values
- Safety settings

## Next Steps

Once basic control works, consider adding:
- Position feedback sensors
- Web interface for remote control
- Automated movement sequences
- Safety limit switches
- Logging and monitoring
77 changes: 77 additions & 0 deletions src/progressive_automations_python/pi/lg07_lift/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
"""
Basic application for controlling LG-07 lift via FLTCON on Raspberry Pi.

This provides a simple command-line interface for lift control.
For production use, consider adding:
- Web API (Flask/FastAPI)
- Configuration file support
- Position feedback
- Safety limits
- Logging
"""

import sys
import signal
import argparse
from progressive_automations_python.pi.lg07_lift.lift_driver import (
press_up, press_down, nudge, emergency_stop, cleanup
)
Comment on lines +17 to +19
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing __init__.py file for the lg07_lift package. Python needs this file to recognize progressive_automations_python.pi.lg07_lift as a package, which is required for the imports to work correctly.

Create an empty __init__.py file at src/progressive_automations_python/pi/lg07_lift/__init__.py.

Copilot uses AI. Check for mistakes.

def signal_handler(signum, frame):
"""Handle Ctrl+C gracefully."""
print("\n⏹️ Received signal, stopping lift and cleaning up...")
emergency_stop()
cleanup()
sys.exit(0)

def main():
"""Main application entry point."""
# Set up signal handlers for clean shutdown
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)

parser = argparse.ArgumentParser(description='LG-07 Lift Control')
parser.add_argument('command', choices=['up', 'down', 'nudge'],
help='Movement command')
parser.add_argument('direction', nargs='?', choices=['up', 'down'],
help='Direction for nudge command')
parser.add_argument('-t', '--time', type=float, default=1.0,
help='Movement time in seconds (default: 1.0)')
parser.add_argument('--test', action='store_true',
help='Run hardware test instead of single command')

args = parser.parse_args()

try:
if args.test:
# Run the hardware test
print("🧪 Running hardware test...")
from test_hardware import test_sequence
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relative import will fail because test_hardware is not in the Python path when app.py is run as a module. The import should use an absolute import path:

from progressive_automations_python.pi.lg07_lift.test_hardware import test_sequence
Suggested change
from test_hardware import test_sequence
from progressive_automations_python.pi.lg07_lift.test_hardware import test_sequence

Copilot uses AI. Check for mistakes.
test_sequence()
elif args.command == 'up':
print(f"⬆️ Moving UP for {args.time} seconds...")
press_up(args.time)
print("✅ UP movement completed")
elif args.command == 'down':
print(f"⬇️ Moving DOWN for {args.time} seconds...")
press_down(args.time)
print("✅ DOWN movement completed")
elif args.command == 'nudge':
if not args.direction:
print("❌ Direction required for nudge command")
sys.exit(1)
print(f"⬆️ Nudging {args.direction.upper()} for {args.time} seconds...")
nudge(args.direction, args.time)
print("✅ Nudge completed")

except Exception as e:
print(f"❌ Error: {e}")
emergency_stop()
sys.exit(1)

finally:
cleanup()

if __name__ == "__main__":
main()
22 changes: 22 additions & 0 deletions src/progressive_automations_python/pi/lg07_lift/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Configuration for LG-07 Lift Control
# GPIO pin assignments (BCM numbering)
gpio:
pin_up: 17 # GPIO pin for UP relay
pin_down: 27 # GPIO pin for DOWN relay

# Timing settings (seconds)
timing:
default_press_time: 1.0 # Default movement time
nudge_time: 0.2 # Default nudge time
min_press_time: 0.1 # Minimum allowed press time
max_press_time: 10.0 # Maximum allowed press time

# Safety settings
safety:
enable_emergency_stop: true
auto_cleanup: true

# Debug settings
debug:
enable_logging: false
log_level: INFO
Loading
Loading