Skip to content

Arduino firmware and ASCOM driver for managing dew heater straps

License

Notifications You must be signed in to change notification settings

michelegz/OpenDewControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌙 OpenDewControl

An open-source Arduino firmware and ASCOM driver for managing dew heater straps in astrophotography setups.
It provides 3 independent PWM channels, an auxiliary output, and supports both manual and automatic dew prevention modes — with persistent configuration in EEPROM and a simple, human-readable serial protocol.


▶️ Hardware prototype

Prototype

This is a concept prototype using a Nano 328P controller and a common, ready to use, mosfet board.

⚙️ Features

  • 3 independent PWM heater channels (0–100%)
  • 1 auxiliary digital ON/OFF output
  • DHT22 sensor for temperature and humidity
  • Automatic dew control using the Magnus dew point equation
  • Manual and automatic modes
  • Global dewMargin (safety temperature offset above dew point)
  • Individual ΔTmax to calibrate each channel
  • Master ON/OFF switch for all outputs
  • 10% discretization (rounded upward)
  • EEPROM storage and versioning
  • Human-readable serial protocol, ideal for ASCOM or standalone drivers
  • Designed for Arduino Uno / Nano

🧠 Theory of Operation

🔹 Dew Point Calculation

The dew point is computed from ambient temperature (°C) and relative humidity (%) using the Magnus formula:

Tdew = (b * α) / (a - α)
α = (a * T) / (b + T) + ln(RH / 100)

where
a = 17.27, b = 237.7, T = ambient temperature (°C), and RH = relative humidity (%).


🔹 Open-Loop Heater Control

Each heater strap has a maximum temperature rise (ΔTmax) above ambient when powered at 100%.
Assuming an approximately linear relationship between PWM power and heat output:

ΔT ≈ (PWM% / 100) * ΔTmax

We define a target heater temperature slightly above the dew point:

Target = Tdew + dewMargin

and compute the required PWM:

PWM% = ceil( ((Target - Tamb) / ΔTmax) * 100 )

Then the PWM is discretized in 10% steps, always rounded upward to ensure adequate heating.


🔹 Open-Loop Control — Pros & Cons

Advantages

  • No extra temperature sensors required on the straps
  • Simple wiring
  • No risk of extra probes failure

Limitations

  • Heater temperature is estimated, not measured
  • Requires experimental calibration of ΔTmax per strap
  • May vary slightly with airflow or ambient changes

In practice, open-loop control is accurate enough for most astrophotography applications when ΔTmax and dewMargin are correctly calibrated.


🧩 EEPROM Parameters

All parameters are saved to EEPROM and automatically restored at boot.
If EEPROM data are invalid or missing, safe defaults are loaded.

Parameter Type Default Description
EEPROM_VERSION int 1000 Firmware structure version
dewMargin float 3.0 °C Global dew offset above dew point
ΔTmax1..3 float 5.0 °C Temperature rise per channel at 100% power (to be measured)
mode byte MANUAL Operation mode

🧭 Operating Modes

Mode Description
MANUAL User directly controls PWM per channel
AUTO PWM calculated automatically from dew point, ΔTmax, and dewMargin
  • Mode persists until changed manually.
  • No automatic fallback between AUTO and MANUAL.
  • In both modes, MASTER must be ON for outputs to be active.

🪫 Master & AUX Outputs

  • MASTER: globally enables or disables all PWM and AUX outputs.
  • AUX: separate ON/OFF channel, useful for relays, fans, or accessories.

🔌 Serial Command Protocol

All commands are case-insensitive and end with the # character. Responses are in the format COMMAND=VALUE# or a multi-value string for status/config requests.

🔹 Connection Handshake

The firmware uses an auto-reset mechanism common to Arduino boards.

  1. When a serial connection is opened by a driver or terminal, the Arduino board automatically resets.
  2. After completing its setup() routine, the firmware sends a READY# signal.
  3. The driver must wait for this READY# signal before sending any other commands. This ensures the device is fully initialized and ready to communicate.

🔹 General Commands

Command Description Example Response
GET_INFO Get firmware name GET_INFO# GET_INFO=MGZ_OpenDewControl#
GET_FWVERSION Get firmware version GET_FWVERSION# GET_FWVERSION=1.0#
RESET Restart the device RESET# RESET=OK#

🔹 Configuration Commands (SET)

Command Description Example Response
SET_MASTER:TRUE Turn all outputs ON SET_MASTER:TRUE# SET_MASTER=TRUE#
SET_MASTER:FALSE Turn all outputs OFF SET_MASTER:FALSE# SET_MASTER=FALSE#
SET_AUX:TRUE Enable AUX output SET_AUX:TRUE# SET_AUX=TRUE#
SET_AUX:FALSE Disable AUX output SET_AUX:FALSE# SET_AUX=FALSE#
SET_MODE_AUTO:TRUE Enable automatic mode SET_MODE_AUTO:TRUE# SET_MODE_AUTO=TRUE#
SET_MODE_AUTO:FALSE Enable manual mode SET_MODE_AUTO:FALSE# SET_MODE_AUTO=FALSE#
SET_POWER1:X Set CH1 power (0–100%) SET_POWER1:50# SET_POWER1=50#
SET_POWER2:X Set CH2 power (0-100%) SET_POWER2:20# SET_POWER2=20#
SET_POWER3:X Set CH3 power (0-100%) SET_POWER3:100# SET_POWER3=100#
SET_DEWMARGIN:X Set global dew margin (°C) SET_DEWMARGIN:2.5# SET_DEWMARGIN=2.50#
SET_DTMAX1:X Set ΔTmax for CH1 (°C) SET_DTMAX1:8.2# SET_DTMAX1=8.20#
SET_DTMAX2:X Set ΔTmax for CH2 (°C) SET_DTMAX2:10.0# SET_DTMAX2=10.00#
SET_DTMAX3:X Set ΔTmax for CH3 (°C) SET_DTMAX3:12.5# SET_DTMAX3=12.50#

🔹 Status & Config Readback (GET)

Command Description Example Response
GET_STATUS Get all real-time status values GET_STATUS# `GET_STATUS=MASTER=TRUE
GET_CONFIG Get all configuration parameters GET_CONFIG# `GET_CONFIG=MODE_AUTO=TRUE
GET_MASTER Get master status GET_MASTER# GET_MASTER=TRUE#
GET_AUX Get AUX status GET_AUX# GET_AUX=FALSE#
GET_MODE_AUTO Get current mode GET_MODE_AUTO# GET_MODE_AUTO=TRUE#
GET_DEWMARGIN Get global dew margin GET_DEWMARGIN# GET_DEWMARGIN=3.00#
GET_DTMAX1 Get ΔTmax for CH1 GET_DTMAX1# GET_DTMAX1=5.00#
GET_DTMAX2 Get ΔTmax for CH2 GET_DTMAX2# GET_DTMAX2=5.00#
GET_DTMAX3 Get ΔTmax for CH3 GET_DTMAX3# GET_DTMAX3=5.00#

🔹 EEPROM Management

Command Description Example Response
SAVE_EEPROM Save all settings to EEPROM SAVE_EEPROM# SAVE_EEPROM=OK#
READ_EEPROM Reload settings from EEPROM READ_EEPROM# READ_EEPROM=OK#

⚗️ Parameter Calibration

ΔTmax (Maximum Temperature Rise)

  1. Power the heater strap at 100% in still air for a few minutes.
  2. Measure the temperature difference between the strap and ambient air.
  3. Use this value as ΔTmax.

dewMargin

Defines how much higher the heater temperature should be compared to the dew point.
Typical setting: 2–3 °C


🧮 Example Calculation

Given:

T_amb = 10°C
RH = 90%
dewMargin = 2°C
ΔTmax = 10°C

Then:

Tdew ≈ 8.3°C
Target = 8.3 + 2 = 10.3°C
ΔT = 10.3 - 10 = 0.3°C
PWM = ceil((0.3 / 10) * 100) = 10%

→ Heater runs at 10% duty cycle (1/10 step).


🧾 License

This project is released under the MIT License

⚠️ Disclaimer

This software provided "as is". The author is not responsible for any hardware or software issue. Use at your own risk.