Calibration
Calibrate servo positions for precise cloth folding
Complete calibration process walkthrough for precise panel positioning
Why Calibrate? Each servo has slightly different mechanical tolerances. Calibration ensures all panels move to exact positions for consistent folding.
Set Home Position
Step 1: Power On and Connect
- 1.Connect power supply to the robot
- 2.Connect Pico 2W to computer via USB
- 3.Open serial connection (mpremote, Thonny, or screen)
- 4.Press Ctrl+D to soft reboot
# Connect to REPL mpremote # You should see: === Fabrica Cloth Folding Robot === Initializing I2C... PCA9685 found at 0x40 Servos initialized Ready for commands >>>
Step 2: Move All Servos to Home (90°)
The home position is defined as all panels lying flat (90° servo angle).
# In the REPL, run: import servo_controller sc = servo_controller.ServoController() # Move all servos to 90 degrees (home position) sc.home_all() # Wait for servos to reach position import time time.sleep(1)
Step 3: Attach Servo Horns
With servos at 90°, attach the servo horns to panels:
- a)Place servo horn on servo shaft in the flat position
- b)Align horn so panel will be horizontal when at home
- c)Press horn firmly onto splined shaft
- d)Secure with included servo horn screw
- e)Repeat for all 4-8 servos
⚠️ Critical: Servo horns must be attached while servos are at exactly 90°. If misaligned, panels won't fold correctly.
Calibrate Movement Range
Understanding Servo Angles
Standard servo motors rotate approximately 180°. For Fabrica:
0° Position
Panel fully up
90° Position
Panel horizontal (home)
180° Position
Panel fully down
Test Movement Range
Test each servo individually to find safe operating range:
# Test Panel 1 (servo 0) # Start at home sc.move_servo(0, 90) time.sleep(1) # Test upward range sc.move_servo(0, 45) # Halfway up time.sleep(1) sc.move_servo(0, 0) # Fully up time.sleep(1) # Return to home sc.move_servo(0, 90) time.sleep(1) # Test downward range sc.move_servo(0, 135) # Halfway down time.sleep(1) sc.move_servo(0, 180) # Fully down time.sleep(1) # Return to home sc.move_servo(0, 90)
Watch for mechanical limits:
- • Stop if you hear servo straining
- • Check for collisions with adjacent panels
- • Verify hinges are not binding
- • Note the actual usable range (may be less than 0-180°)
Record Calibration Values
Document the safe range for each servo in the config file:
# Edit config.py on the Pico
SERVO_LIMITS = {
0: {"min": 10, "max": 170, "home": 90}, # Panel 1
1: {"min": 15, "max": 165, "home": 90}, # Panel 2
2: {"min": 10, "max": 175, "home": 90}, # Panel 3
3: {"min": 20, "max": 160, "home": 90}, # Panel 4
# Add more servos as needed
}
# These limits will prevent damage from over-rotationFine-Tuning
Adjust Speed and Acceleration
Control how fast panels move:
# In config.py, adjust these values: # Movement speed (degrees per second) SERVO_SPEED = 100 # 100° per second (moderate) # Try: 50 (slow), 100 (moderate), 200 (fast) # Acceleration ramp USE_ACCELERATION = True # Smooth start/stop ACCEL_TIME = 0.3 # Seconds to reach full speed # Simultaneous movement PARALLEL_PANELS = True # Move multiple panels at once # False = sequential (one at a time)
PWM Frequency Tuning (Advanced)
Most servos work at 50Hz, but some prefer different frequencies:
# In config.py: PWM_FREQUENCY = 50 # Standard: 50Hz # If servos jitter or buzz: # Try: 60Hz (some digital servos prefer this) # Try: 333Hz (analog servos, smoother) # Pulse width range (microseconds) PULSE_MIN = 500 # Typically 500-1000 PULSE_MAX = 2500 # Typically 2000-2500 # Adjust if servos don't reach full range
Test Coordinated Movement
Test moving multiple panels simultaneously:
# Move panels 1 and 2 together
sc.move_multiple([
(0, 45), # Panel 1 to 45°
(1, 135) # Panel 2 to 135°
])
time.sleep(2)
# Return to home
sc.home_all()
# Test all panels in sequence
for i in range(4): # For 4-panel build
sc.move_servo(i, 45)
time.sleep(0.5)
sc.move_servo(i, 135)
time.sleep(0.5)
sc.move_servo(i, 90)
time.sleep(0.3)Calibration Verification
Run Calibration Test Sequence
This built-in test verifies calibration:
# Run calibration test import sequence_manager sm = sequence_manager.SequenceManager() sm.run_calibration_test() # This will: # 1. Move each panel through full range # 2. Check for smooth movement # 3. Verify home position accuracy # 4. Test coordinated movements # 5. Report any issues
Expected Results:
✓ All panels move smoothly without jerking
✓ No mechanical binding or collisions
✓ Servos return to exact home position
✓ No unusual sounds or vibrations
Save Calibration
Once satisfied with calibration, save settings:
# Save current configuration sc.save_calibration() # Settings saved to: /calibration.json
Calibration Troubleshooting
❌ Servo Jitters at Home Position
- • Insufficient power supply current → Use 5A power supply
- • Mechanical friction → Lubricate hinges, check for binding
- • Wrong PWM frequency → Try 60Hz or 333Hz
❌ Panel Doesn't Return to Same Position
- • Servo horn loose → Tighten horn screw
- • Servo gear backlash → Use higher quality servos
- • Software timing issue → Increase delay between moves
❌ Limited Range of Motion
- • Adjust PULSE_MIN and PULSE_MAX values
- • Check mechanical stops (hinges, frame)
- • Verify servo is not damaged
Calibration Complete! ✨
Your robot is now calibrated and ready to learn folding sequences. Let's teach it how to fold your first garment!