-
Notifications
You must be signed in to change notification settings - Fork 0
Hardware-testing #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
132
src/progressive_automations_python/pi/lg07_lift/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||||||
| ) | ||||||
|
|
||||||
| 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 | ||||||
|
||||||
| from test_hardware import test_sequence | |
| from progressive_automations_python.pi.lg07_lift.test_hardware import test_sequence |
22 changes: 22 additions & 0 deletions
22
src/progressive_automations_python/pi/lg07_lift/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
__init__.pyfile for thelg07_liftpackage. Python needs this file to recognizeprogressive_automations_python.pi.lg07_liftas a package, which is required for the imports to work correctly.Create an empty
__init__.pyfile atsrc/progressive_automations_python/pi/lg07_lift/__init__.py.