Skip to content

Commit

Permalink
Merge pull request #7 from vortigont/powerramp
Browse files Browse the repository at this point in the history
Implement PWM Power ramping
  • Loading branch information
vortigont authored May 26, 2024
2 parents 36afe33 + 0580e94 commit e2cde74
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 86 deletions.
4 changes: 2 additions & 2 deletions ESPIron/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ enum class ironState_t {
suspend, // hibernation mode
boost, // heater temperature is increased for a short period of time
setup, // iron is configuration mode, i.e. working with screen menu, heater switches off
notip // tip is missing or failed

notip, // tip is missing or failed
ramping // power ramp in progress
};

// working temperature values
Expand Down
14 changes: 3 additions & 11 deletions ESPIron/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define TEMP_MIN 150 // 最小温度
#define TEMP_MAX 450 // 最大温度
#define TEMP_STEP 5 // temperature change step / 旋转编码器温度变化步进
#define TEMP_NOTIP 500 // virtual temperature threshold when tip is not installed
#define TEMP_NOTIP 500 // virtual temperature threshold when tip is not installed (op amp max ~650 C)
#define TEMP_STANDBY 120 // 休眠温度
#define TEMP_STANDBY_MIN 100
#define TEMP_STANDBY_MAX 180
Expand All @@ -53,10 +53,6 @@
#define TEMP_BOOST_MAX 100
#define TEMP_BOOST_STEP 10

#define POWER_LIMIT_15 170 // 功率限制
#define POWER_LIMIT_20 255 // 功率限制
#define POWER_LIMIT_20_2 127 // 功率限制

// Default tip temperature calibration value / 默认的T12烙铁头温度校准值
#define TEMP200 200 // temperature at ADC = 200
#define TEMP280 280 // temperature at ADC = 280
Expand Down Expand Up @@ -89,12 +85,8 @@
#define WAKEUP_THRESHOLD 10

// Control values
#define TIME2SETTLE 5000 // The time in microseconds allowed for the OpAmp output to stabilize / 以微秒为单位的时间允许OpAmp输出稳定
#define TIME2SETTLE_20V 2000 // The time in microseconds allowed for the OpAmp output to stabilize / 以微秒为单位的时间允许OpAmp输出稳定
#define SMOOTHIE 0.2 // OpAmp output smoothing coefficient (1=no smoothing; default: 0.05) / OpAmp输出平滑系数 (1=无平滑; 默认:0.05)
//#define PID_ENABLE true // enable PID control
#define PID_ENGAGE_DIFF 30 // temperature difference when PID algo should be engaged
#define BEEP_ENABLE true // enable/disable buzzer
#define SMOOTHIE 0.2 // OpAmp output smoothing coefficient (1=no smoothing; default: 0.05) / OpAmp输出平滑系数 (1=无平滑; 默认:0.05)
#define BEEP_ENABLE true // enable/disable buzzer


// MOSFET control definitions
Expand Down
1 change: 1 addition & 0 deletions ESPIron/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ static constexpr const char* T_motionThr = "motionThr"; // motio
static constexpr const char* T_pdVolts = "pdVolts"; // PD trigger voltage
static constexpr const char* T_qcVolts = "qcVolts"; // QC trigger voltage
static constexpr const char* T_qcMode = "qcMode"; // QC Mode
static constexpr const char* T_PWMRamp = "PWMRamp"; // PWM Power ramping
1 change: 1 addition & 0 deletions ESPIron/evtloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ESP_EVENT_DEFINE_BASE(IRON_GET_EVT);
ESP_EVENT_DEFINE_BASE(IRON_NOTIFY);
ESP_EVENT_DEFINE_BASE(IRON_STATE);
ESP_EVENT_DEFINE_BASE(IRON_VISET);
ESP_EVENT_DEFINE_BASE(IRON_HEATER);


namespace evt {
Expand Down
19 changes: 15 additions & 4 deletions ESPIron/evtloop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// helper macro to reduce typing
#define EVT_POST(event_base, event_id) esp_event_post_to(evt::get_hndlr(), event_base, event_id, NULL, 0, portMAX_DELAY)
#define EVT_POST_DATA(event_base, event_id, event_data, data_size) esp_event_post_to(evt::get_hndlr(), event_base, event_id, event_data, data_size, portMAX_DELAY)
#define EVT_POST_ISR(event_base, event_id, tsk_awoken) esp_event_isr_post_to(evt::get_hndlr(), event_base, event_id, NULL, 0, tsk_awoken)

// ESP32 event loop defines
ESP_EVENT_DECLARE_BASE(SENSOR_DATA); // events coming from different sensors, i.e. temperature, voltage, orientation, etc...
Expand All @@ -24,6 +25,7 @@ ESP_EVENT_DECLARE_BASE(IRON_GET_EVT); // ESPIron getter Commands events ba
ESP_EVENT_DECLARE_BASE(IRON_NOTIFY); // ESPIron notification events base (those events are published when some state or mode changes due to any commands or component's logic)
ESP_EVENT_DECLARE_BASE(IRON_STATE); // ESPIron State publishing events base (those events are published on IRON_GET_EVT requests on demand)
ESP_EVENT_DECLARE_BASE(IRON_VISET); // ESPIron VisualSet HID events
ESP_EVENT_DECLARE_BASE(IRON_HEATER); // ESPIron heater control events

// cast enum to int
template <class E>
Expand All @@ -48,20 +50,27 @@ enum class iron_t:int32_t {

// Commands
sensorsReload = 200, // reload configuration for any sensors available
heaterTargetT, // set heater target temperature, parameter int32_t
workTemp, // set working temperature, parameter int32_t
workModeToggle, // toggle working mode on/off
boostModeToggle, // toggle boost mode on/off

// Heater Commands
heaterTargetT = 250, // set heater target temperature, parameter int32_t
heaterEnable,
heaterDisable,
heaterRampUp, // start PWM ramp heating, switch to enabled mode

reloadTemp, // reload temperature configuration
reloadTimeouts, // reload timeouts configuration
enablePWMRamp, // PWM ramping on
disablePWMRamp, // PWM ramping off

// Commands - power control
pdVoltage, // switch PD trigger, arg uint32_t in V
qcVoltage, // switch QC trigger, arg uint32_t in V
qc2enable, // activate QC trigger in QC2 mode
qc3enable, // activate QC trigger in QC3 mode
qcDisable, // disable QC trigger
// qc2enable, // activate QC trigger in QC2 mode
// qc3enable, // activate QC trigger in QC3 mode
// qcDisable, // disable QC trigger

// State notifications
stateWorking = 300,
Expand All @@ -72,6 +81,8 @@ enum class iron_t:int32_t {
stateBoost, // iron controller switched to 'Boost' mode, parameter uint32_t - seconds left to disable boost mode
stateSetup, // enter in menu confgiration mode
stateNoTip,
statePWRRampStart, // Iron has started power ramping
statePWRRampCmplt, // Iron has completed power ramping
tipEject, // sent by heater when it looses the tip sense
tipInsert, // sent by heater when detect tip sensor

Expand Down
Loading

0 comments on commit e2cde74

Please sign in to comment.