Skip to main content

Oven System

GitHub: https://github.com/adom-inc/workcell/tree/main/firmware/oven

All controllabel components of the oven include:

  • 1 Fan Motor
  • 2 Servos to control the flow of air
  • 2 Thermistors to read the internal temperatures of the hot and cold chambers
  • 2 Pumps to control the AC and Cyro respectively
  • 3 Heaters
  • 1 current sensor to detect if the fan has stopped

Thermistor

Functionality

The module implements the TempReadable trait for the Embassy Adc<'_, Async> type. This allows any asynchronous ADC instance to read temperature from a configured Thermistor. This is necessary as only 1 ADC channel can be read at a time, and so the thermistor cannot take ownership of the ADC or of the pin.

Thermistor Struct

Represents a thermistor sensor. It holds the specific ADC Channel the thermistor is connected to and its physical ThermistorConstants.

TempReadable Trait

Defines a generic interface for reading temperature. It requires implementors to provide an async fn read_temp.

CurrentSensor

Functionality

The module implements the CurrentReadable trait for the Embassy Adc<'_, Async> type. This is done for the same reason as the Thermistor.

CurrentSensor Struct

Represents a current sensor. It holds the specific ADC Channel the sensor is connected to. It is used to detect if the motor controller for the Fan Motor burns-out (They fail closed).

CurrentReadable Trait

Defines a generic interface for interacting with a current sensor via ADC.

  • read_voltage(): Reads the raw sensor output voltage (scaled by 100).
  • is_on(): Determines if current is flowing above a set base line
  • read_current(): Reads and averages the sensor output to provide a current value (scaled).
note

All ADC reads should be done in the main loop. This is where the emergency stop checks should be done about the fan using the current sensor and eventually where the internal chamber temps can be read and used for smarter control of the internal temperature system.

Servos

Angle Setting

  • set_angle(angle):
    • Sends target PWM immediately, servo will move as fast as posisble
  • slow_move(target_angle):
    • Move with a controlled rotation speed, by setting target intermediate possitions with timers in-between each step
    • Iterates from the current_pulse to the target_pulse (or vice-versa), calling send_pulse_width for each step and pausing using Timer::after_micros.
  • bounce_close(angle):
    • Purposely overshoots the motor to counteract high-friction / the internal PID of the motor, and then relaxes the motor to stop burn-out
  • flip_flop(period): A test function to move the servo back and forth between two angles repeatedly.

Motors

Defines a common interface for motor control:

  • new(...): Constructor.
  • set_power(power: u8): Instantly sets the motor power (0-100%).
  • log_data(): Returns current motor status (MotorLogData).
  • ramp_to(power: u8, period: u64): Gradually changes motor power over a specified duration (ms).
  • estimate_rpm(...): Helper to estimate RPM based on current input and configured min/max values.
  • power_for(power: u8, period: u64): Runs the motor at a power level for a duration, then stops.
  • off(): Stops the motor (set_power(0)).

FanMotor Struct

Implementation for controlling a typical brushless DC fan where speed is proportional to the PWM duty cycle.

PumpMotor Struct

Implementation for controlling a motor where speed is controlled by the frequency of the PWM signal at a fixed duty cycle of 50%.

Heaters

Power Setting (set_power)

  • Takes a total desired power percentage (power: u8, 0-100).
  • Consolidation Logic:
    • If the requested power is non-zero but less than or equal to CONSOLIDATE_THRESH:
      • The power is multiplied by the number of heaters (3 in this case) to scale it up for a single heater.
      • This scaled power is applied only to the first heater (heater_pwms[0]) using set_duty_cycle_percent.
    • Standard Distribution:
      • If the power is above the threshold or zero:
        • The same power percentage is applied to all heaters in the heater_pwms array using set_duty_cycle_percent.
  • Sends the resulting cur_powers array to the logger.
Consolidation

The consolidation logic aims to improve efficiency or control precision at very low power levels. Instead of running three heaters at a very low (potentially ineffective) duty cycle, it runs one heater at a higher, more effective duty cycle. The threshold must be less than 100 / num_heaters.