Skip to content
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

Feat: dynamic frequency #211

Merged
merged 5 commits into from
Dec 24, 2024
Merged

Conversation

sbtoonz
Copy link
Contributor

@sbtoonz sbtoonz commented Dec 20, 2024

Description

Title: Implement Dynamic Thresholding for Coil Frequency Monitoring

This update enhances the _check_hardware function by introducing a self-adjusting threshold mechanism for monitoring coil frequencies. The previous static multiplier method has been replaced with a data-driven approach that adapts to real-time frequency variations, improving anomaly detection accuracy.

Key Changes:

  • Sliding Window Implementation: Utilizes a fixed-size buffer (deque) to maintain the most recent frequency readings, enabling real-time calculation of the rolling average and standard deviation.

  • Dynamic Threshold Calculation: Sets the threshold at the rolling average plus three standard deviations (μ + 3σ), allowing the system to adapt to normal operational fluctuations without manual parameter tuning.

  • Minimum Threshold Establishment: Introduces a baseline threshold set to 20% above the initial frequency reading to ensure stability during initialization and prevent premature anomaly detection.

  • Enhanced Logging: Adds detailed debug logs to track frequency statistics and threshold values, facilitating easier monitoring and troubleshooting.

Benefits:

  • Improved Accuracy: The self-adjusting threshold reduces false positives by accounting for natural variations in frequency readings.

  • Robustness to Noise: The sliding window approach effectively filters out transient spikes, enhancing the reliability of anomaly detection.

Notes:

  • The size of the sliding window (deque with maxlen=50) can be adjusted based on system requirements and data rates.

  • The initial minimum threshold is set to 20% above the first observed frequency; this percentage can be modified if necessary to better suit specific operational conditions.

This enhancement aims to provide a more resilient and maintenance-free approach to monitoring coil frequencies, improving overall system reliability.

Checklist

The following relevant macros have been tested:

  • [ x ] CARTOGRAPHER_CALIBRATE
  • [ x ] PROBE
  • [ x ] PROBE_ACCURACY
  • [ x ] CARTOGRAPHER_THRESHOLD_SCAN
  • [ x ] CARTOGRAPHER_TOUCH CALIBRATE=1
  • [ x ] CARTOGRAPHER_TOUCH
  • [ x ] CARTOGRAPHER_TOUCH METHOD=manual
  • [ x ] BED_MESH_CALIBRATE

@github-actions github-actions bot added the feature New feature or request label Dec 20, 2024
scanner.py Outdated Show resolved Hide resolved
scanner.py Outdated Show resolved Hide resolved
scanner.py Show resolved Hide resolved
scanner.py Outdated Show resolved Hide resolved
Sliding Window Implementation: Utilizes a fixed-size buffer (deque) to maintain the most recent frequency readings, enabling real-time calculation of the rolling average and standard deviation.

Dynamic Threshold Calculation: Sets the threshold at the rolling average plus three standard deviations (μ + 3σ), allowing the system to adapt to normal operational fluctuations without manual parameter tuning.

Minimum Threshold Establishment: Introduces a baseline threshold set to 20% above the initial frequency reading to ensure stability during initialization and prevent premature anomaly detection.

Enhanced Logging: Adds detailed debug logs to track frequency statistics and threshold values, facilitating easier monitoring and troubleshooting.
@sbtoonz
Copy link
Contributor Author

sbtoonz commented Dec 21, 2024

commit squashed and issues brought up resolved let me know if anything else spotted @krautech @Jomik

@krautech krautech self-requested a review December 24, 2024 03:06
@krautech krautech merged commit edda8ca into Cartographer3D:develop Dec 24, 2024
3 checks passed
@curather
Copy link

I would move the initialization of the variables to the init function

self.freq_window = deque(maxlen=self.SLIDING_WINDOW_SIZE)
self.min_threshold = None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants