Skip to content

PHControl Class Implementation #17

@samuelnguyen999

Description

@samuelnguyen999

The PHControl class manages pH target behavior, solenoid activation, timed pH patterns (flat, ramp, sine), and optional PID-based control. This issue tracks the work needed to complete and validate pH control features across the device.

Goals

  • Review and complete all pH-control logic, including flat, ramp, and sine target modes.
  • Validate integration with PID control when usePID is enabled.
  • Ensure proper timing, switching events, and window management for solenoid and pH modulation.
  • Confirm compatibility with the hardware platform (solenoid, control pin, timing constraints).
  • Review singleton implementation for correctness and maintainability.

Reference: PHControl Public Operations

  • instance() / clearInstance()
  • getBaseTargetPh()
  • getCurrentTargetPh()
  • getPHFunctionType()
  • getAmplitude()
  • getPhRampTimeStart()
  • getPhRampTimeEnd()
  • getPeriodInSeconds()
  • getUsePID()
  • isOn()
  • setBaseTargetPh()
  • setRampDurationHours()
  • setSineAmplitude()
  • setSineAmplitudeAndHours()
  • enablePID()
  • loop()

Internal/Private Components for Review

  • Timing fields (lastSwitchMS, lastWarnMS, rampTimeStartSeconds, rampTimeEndSeconds, sineStartTime)
  • Target calculation logic: (Base target, Ramp interpolation, Sine wave modulation)
  • Solenoid control via PH_CONTROL_PIN
  • PID window management (WINDOW_SIZE) and interaction with external PID controller
  • pH function type management (FLAT, RAMP, SINE)
  • Initialization flow within the private constructor
  • Safety considerations (over-activation, timing limits, inaccurate pH oscillation, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions