Skip to content

Latest commit

 

History

History
122 lines (92 loc) · 3.49 KB

File metadata and controls

122 lines (92 loc) · 3.49 KB

Arduino Deployment Guide

Quick Setup Checklist

1. Hardware Connections

  • Piezoelectric Sensor → Connect to Analog Pin A0
    • One lead to A0
    • Other lead to GND
    • (Optional: Add a pull-down resistor ~1MΩ between A0 and GND)
  • LED (optional) → Connect to Digital Pin 13
    • Anode (long leg) → Pin 13
    • Cathode (short leg) → GND via 220Ω resistor

2. Arduino IDE Setup

  1. Open Arduino IDE

  2. Create Sketch Folder

    • Create a new folder named arduino_slip_detection in your Arduino sketches directory
    • Typically: Documents/Arduino/arduino_slip_detection/
  3. Copy Files

    • Copy arduino_slip_detection.ino to the sketch folder
    • Copy arduino_model.h to the same sketch folder
  4. Verify File Structure

    arduino_slip_detection/
    ├── arduino_slip_detection.ino
    └── arduino_model.h
    
  5. Select Board

    • Tools → Board → Arduino Uno
  6. Select Port

    • Tools → Port → [Your Arduino COM Port]
  7. Upload

    • Click Upload button (or Ctrl+U)
    • Wait for "Done uploading" message

3. Testing

  1. Open Serial Monitor

    • Tools → Serial Monitor (or Ctrl+Shift+M)
    • Set baud rate to 9600
  2. Expected Output

    Slip Detection System Initialized
    Model: 17 nodes
    Features: 5
    Ready for detection...
    
    Features: [0.xxx, 0.xxx, ...] | Prediction: NO_SLIP | Probability: 0.xxx
    
  3. Test with Sensor

    • Apply pressure/vibration to piezoelectric sensor
    • Watch for "SLIP" predictions
    • LED on pin 13 will light up when slip is detected

4. Calibration Notes

The feature extraction in arduino_slip_detection.ino uses normalization constants that may need adjustment based on your sensor:

Current Normalization (lines 118-122):

features[0] = constrain(features[0], 0.0, 1.0);
features[1] = constrain(features[1] * 2.0, 0.0, 1.0);
features[2] = constrain(features[2] * 5.0, 0.0, 1.0);
features[3] = constrain(features[3] * 5.0, 0.0, 1.0);
features[4] = constrain(features[4], 0.0, 1.0);

To Calibrate:

  1. Run the code and observe feature values in Serial Monitor
  2. Compare with your training data ranges
  3. Adjust multipliers (2.0, 5.0, etc.) to match training data distribution

5. Memory Usage

  • Model Size: ~17 nodes (very compact!)
  • SRAM Usage: ~2KB (well within Arduino Uno's 2KB limit)
  • Flash Usage: ~8KB (well within Arduino Uno's 32KB limit)

6. Troubleshooting

"arduino_model.h: No such file or directory"

  • Ensure arduino_model.h is in the same folder as .ino file
  • Check file name spelling (case-sensitive)

Model predictions seem wrong

  • Verify sensor is connected to A0
  • Check feature normalization matches training data
  • Ensure sensor readings are in expected range (0-1023)

Serial Monitor shows no output

  • Check baud rate is set to 9600
  • Verify USB cable connection
  • Try resetting Arduino

LED not working

  • Check LED polarity (long leg = anode)
  • Verify LED is connected to pin 13
  • Test LED with simple blink sketch first

7. Next Steps

After testing with sample data:

  1. Collect real piezoelectric sensor data
  2. Label your dataset (slip vs no-slip)
  3. Retrain model with your data
  4. Regenerate arduino_model.h
  5. Re-upload to Arduino

Performance Tips

  • Sampling Rate: Currently 100 samples per window with 10ms delay = 1 second per prediction
  • To Speed Up: Reduce WINDOW_SIZE (but may affect accuracy)
  • To Improve Accuracy: Increase WINDOW_SIZE (but slower predictions)