Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
Si, nunca estuvo soldado, los demás componentes sí los removí y pasé a bases para poder realizar las pruebas más fáciles, pero el MCU ya estaba así desde fábrica.¿Me equivoco o ese micro va con zócalo?
Nunca me gustó las memorias en zócalo, menos los microcontroladores..
Cuando lo remuevo de la base el voltaje llega correctamente a 5V, como se puede observar en las fotos el LED enciende correctamente cuando lo inserto en los pines que corresponden a tierra y el interruptor. Lo que no me gusta del diseño es que no existe ninguna resistencia de protección al pin, sino que va directo, pero no entiendo cómo pudo dañarse.Si fuera posible levantaría el pin del microcontrolador del PCB y forzaría el estado alto mediante un PullUp externo y mediria a ver que pasa.
Entonces no te quedan dudas de donde esta el problema. Por algo "gastaron" en poner zócalo, tal vez por eso que te paso.Si, nunca estuvo soldado, los demás componentes sí los removí y pasé a bases para poder realizar las pruebas más fáciles, pero el MCU ya estaba así desde fábrica.
Cuando lo remuevo de la base el voltaje llega correctamente a 5V, como se puede observar en las fotos el LED enciende correctamente cuando lo inserto en los pines que corresponden a tierra y el interruptor. Lo que no me gusta del diseño es que no existe ninguna resistencia de protección al pin, sino que va directo, pero no entiendo cómo pudo dañarse.
¿De casualidad alguien tendrá el circuito? si no tendré que trazarlo por mi cuenta, hay un integrado de 8 pines que fue borrado (tiene lijada la nomenclatura) por lo que no sé qué podría ser.
#define DISPLAY_1 6
#define DISPLAY_2 7
#define DISPLAY_3 A0
#define DISPLAY_A 8
#define DISPLAY_B 9
#define DISPLAY_C 10
#define DISPLAY_D 11
#define DISPLAY_E 12
#define DISPLAY_F 13
#define DISPLAY_G 4
#define DISPLAY_DP 5
#define PIN_FAN A3
#define SENSE_FAN A2
#define SENSE_TEMP A1
#define HEAT_ELEMENT 3
#define BUTTON_UP A5
#define BUTTON_DOWN A4
#define MAG_SW 2
#define USE_TIMER_1 true
#include "TimerInterrupt.h"
#define TIMER_INTERVAL_MS 5
struct {
const uint8_t dp = 0x80;
const uint8_t numbers[16] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 };
} Display7Seg;
uint8_t displayBuffer[3] = { 0, 0, 0 };
int displayIndex = 0;
void TimerHandler(void) {
switch (displayIndex) {
case 0:
digitalWrite(DISPLAY_3, LOW);
digitalWrite(DISPLAY_1, HIGH);
break;
case 1:
digitalWrite(DISPLAY_1, LOW);
digitalWrite(DISPLAY_2, HIGH);
break;
case 2:
digitalWrite(DISPLAY_2, LOW);
digitalWrite(DISPLAY_3, HIGH);
break;
}
if (0x01 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_A, HIGH);
else digitalWrite(DISPLAY_A, LOW);
if (0x02 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_B, HIGH);
else digitalWrite(DISPLAY_B, LOW);
if (0x04 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_C, HIGH);
else digitalWrite(DISPLAY_C, LOW);
if (0x08 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_D, HIGH);
else digitalWrite(DISPLAY_D, LOW);
if (0x10 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_E, HIGH);
else digitalWrite(DISPLAY_E, LOW);
if (0x20 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_F, HIGH);
else digitalWrite(DISPLAY_F, LOW);
if (0x40 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_G, HIGH);
else digitalWrite(DISPLAY_G, LOW);
if (0x80 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_DP, HIGH);
else digitalWrite(DISPLAY_DP, LOW);
if (displayIndex == 2) displayIndex = 0;
else displayIndex++;
}
void displayNumber(uint16_t val) {
int cents = val / 100;
if (cents < 10) displayBuffer[0] = ~Display7Seg.numbers[cents];
int x = val % 100;
int dec = x / 10;
if (dec < 10) displayBuffer[1] = ~Display7Seg.numbers[dec];
int unit = x % 10;
if (unit < 10) displayBuffer[2] = ~Display7Seg.numbers[unit];
}
volatile int temp = 0, speed = 0, heater = 0;
void setup() {
// put your setup code here, to run once:
pinMode(DISPLAY_A, OUTPUT);
pinMode(DISPLAY_B, OUTPUT);
pinMode(DISPLAY_C, OUTPUT);
pinMode(DISPLAY_D, OUTPUT);
pinMode(DISPLAY_E, OUTPUT);
pinMode(DISPLAY_F, OUTPUT);
pinMode(DISPLAY_G, OUTPUT);
pinMode(DISPLAY_DP, OUTPUT);
pinMode(DISPLAY_1, OUTPUT);
pinMode(DISPLAY_2, OUTPUT);
pinMode(DISPLAY_3, OUTPUT);
pinMode(PIN_FAN, OUTPUT);
pinMode(HEAT_ELEMENT, OUTPUT);
digitalWrite(HEAT_ELEMENT, HIGH);
pinMode(MAG_SW, INPUT_PULLUP);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
Serial.begin(115200);
displayBuffer[0] = ~0x6D;
displayBuffer[1] = ~0x79;
displayBuffer[2] = ~0x50;
heater = 50;
ITimer1.init();
if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_MS, TimerHandler)) {
Serial.println(F("Starting ITimer1 OK"));
} else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
}
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(SENSE_TEMP);
speed = analogRead(SENSE_FAN);
if (Serial.available() != 0) {
int tvar = Serial.parseInt();
heater = tvar;
//analogWrite(HEAT_ELEMENT, heater);
}
if (digitalRead(MAG_SW)) {
digitalWrite(PIN_FAN, LOW);
if (temp > heater) {
digitalWrite(HEAT_ELEMENT, HIGH);
Serial.print("Inactive");
} else {
digitalWrite(HEAT_ELEMENT, LOW);
Serial.print("Active");
}
} else {
digitalWrite(HEAT_ELEMENT, HIGH);
Serial.print("Inactive");
if(temp < 20) digitalWrite(PIN_FAN, HIGH);
}
Serial.print(" T ");
Serial.print(temp);
Serial.print(" S ");
Serial.print(speed);
Serial.print(" P ");
Serial.println(heater);
displayNumber(temp);
delay(100);
}
#define DISPLAY_1 6
#define DISPLAY_2 7
#define DISPLAY_3 A0
#define DISPLAY_A 8
#define DISPLAY_B 9
#define DISPLAY_C 10
#define DISPLAY_D 11
#define DISPLAY_E 12
#define DISPLAY_F 13
#define DISPLAY_G 4
#define DISPLAY_DP 5
#define PIN_FAN A3
#define SENSE_FAN A2
#define SENSE_TEMP A1
#define HEAT_ELEMENT 3
#define BUTTON_UP A5
#define BUTTON_DOWN A4
#define MAG_SW 2
#define USE_TIMER_1 true
#include "TimerInterrupt.h"
#define TIMER_INTERVAL_MS 5
#define DEBOUNCING_INTERVAL_MS 200
#define LONG_PRESS_INTERVAL_MS 3000
#define SETTINGS_TIMEOUT 3000
//buttons
volatile bool Changing_Settings = false;
volatile int Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
volatile bool Button_Up_Pressed = false;
volatile bool Button_Up_Release = false;
volatile bool Button_Up_Hold = false;
volatile int Button_Up_Cicles = 0;
volatile bool Button_Down_Pressed = false;
volatile bool Button_Down_Release = false;
volatile bool Button_Down_Hold = false;
volatile int Button_Down_Cicles = 0;
struct {
const uint8_t dp = 0x80;
const uint8_t numbers[16] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 };
} Display7Seg;
const int calTable[] = { //Calibration table, temperature by value on ADC
32, 33, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 47, 49, 50,
51, 52, 53, 54, 56, 57, 58, 59,
60, 61, 63, 64, 65, 66, 67, 68,
70, 71, 72, 73, 74, 75, 77, 78,
79, 80, 81, 83, 84, 85, 86, 87,
88, 90, 91, 92, 93, 94, 95, 97,
98, 99, 100, 101, 102, 104, 105, 106,
107, 108, 109, 111, 112, 113, 114, 115,
116, 118, 119, 120, 121, 122, 123, 125,
126, 127, 128, 129, 131, 132, 133, 134,
135, 136, 138, 139, 140, 141, 142, 143,
145, 146, 147, 148, 149, 150, 152, 153,
154, 155, 156, 157, 159, 160, 161, 162,
163, 164, 166, 167, 168, 169, 170, 172,
173, 174, 175, 176, 177, 179, 180, 181,
182, 183, 184, 186, 187, 188, 189, 190,
191, 193, 194, 195, 196, 197, 198, 200,
201, 202, 203, 204, 205, 207, 208, 209,
210, 211, 212, 214, 215, 216, 217, 218,
220, 221, 222, 223, 224, 225, 227, 228,
229, 230, 231, 232, 234, 235, 236, 237,
238, 239, 241, 242, 243, 244, 245, 246,
248, 249, 250, 251, 252, 253, 255, 256,
257, 258, 259, 260, 262, 263, 264, 265,
266, 268, 269, 270, 271, 272, 273, 275,
276, 277, 278, 279, 280, 282, 283, 284,
285, 286, 287, 289, 290, 291, 292, 293,
294, 296, 297, 298, 299, 300, 301, 303,
304, 305, 306, 307, 308, 310, 311, 312,
313, 314, 316, 317, 318, 319, 320, 321,
323, 324, 325, 326, 327, 328, 330, 331
};
volatile int temp = 0, speed = 0, heater = 0;
uint8_t displayBuffer[3] = { 0, 0, 0 };
volatile int displayIndex = 0;
void TimerHandler(void) {
switch (displayIndex) {
case 0:
digitalWrite(DISPLAY_3, LOW);
digitalWrite(DISPLAY_1, HIGH);
break;
case 1:
digitalWrite(DISPLAY_1, LOW);
digitalWrite(DISPLAY_2, HIGH);
break;
case 2:
digitalWrite(DISPLAY_2, LOW);
digitalWrite(DISPLAY_3, HIGH);
break;
}
if (0x01 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_A, HIGH);
else digitalWrite(DISPLAY_A, LOW);
if (0x02 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_B, HIGH);
else digitalWrite(DISPLAY_B, LOW);
if (0x04 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_C, HIGH);
else digitalWrite(DISPLAY_C, LOW);
if (0x08 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_D, HIGH);
else digitalWrite(DISPLAY_D, LOW);
if (0x10 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_E, HIGH);
else digitalWrite(DISPLAY_E, LOW);
if (0x20 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_F, HIGH);
else digitalWrite(DISPLAY_F, LOW);
if (0x40 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_G, HIGH);
else digitalWrite(DISPLAY_G, LOW);
if (0x80 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_DP, HIGH);
else digitalWrite(DISPLAY_DP, LOW);
if (displayIndex == 2) displayIndex = 0;
else displayIndex++;
if (Button_Up_Pressed) { //actions at Up button
//Button already pressed
Button_Up_Cicles++; //increase the counter
if (Button_Up_Cicles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_UP)) { //at release
//button press action
if (heater < 229) heater++;
Button_Up_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Up_Cicles = 0;
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_UP) == false) {
Button_Up_Pressed = true;
Changing_Settings = true;
}
}
if (Button_Down_Pressed) { //actions at Down button
//Button already pressed
Button_Down_Cicles++; //increase the counter
if (Button_Down_Cicles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_DOWN)) { //at release
//button press action
if (heater > 0) heater--;
Button_Down_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Down_Cicles = 0;
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_DOWN) == false) {
Button_Down_Pressed = true;
Changing_Settings = true;
}
}
if(Changing_Settings == false && Changing_Settings_Timeout) Changing_Settings_Timeout--;
}
void displayNumber(uint16_t val) {
int cents = val / 100;
if (cents < 10) displayBuffer[0] = ~Display7Seg.numbers[cents];
int x = val % 100;
int dec = x / 10;
if (dec < 10) displayBuffer[1] = ~Display7Seg.numbers[dec];
int unit = x % 10;
if (unit < 10) displayBuffer[2] = ~Display7Seg.numbers[unit];
}
void displayShow(uint8_t symbol1, uint8_t symbol2, uint8_t symbol3) {
displayBuffer[0] = ~symbol1;
displayBuffer[1] = ~symbol2;
displayBuffer[2] = ~symbol3;
}
void setup() {
// put your setup code here, to run once:
//Priority
pinMode(PIN_FAN, OUTPUT); //stop fan
digitalWrite(PIN_FAN, HIGH);
pinMode(HEAT_ELEMENT, OUTPUT); //Set heater and disable
digitalWrite(HEAT_ELEMENT, HIGH);
heater = 0;
//Config display pins
pinMode(DISPLAY_A, OUTPUT);
pinMode(DISPLAY_B, OUTPUT);
pinMode(DISPLAY_C, OUTPUT);
pinMode(DISPLAY_D, OUTPUT);
pinMode(DISPLAY_E, OUTPUT);
pinMode(DISPLAY_F, OUTPUT);
pinMode(DISPLAY_G, OUTPUT);
pinMode(DISPLAY_DP, OUTPUT);
pinMode(DISPLAY_1, OUTPUT);
pinMode(DISPLAY_2, OUTPUT);
pinMode(DISPLAY_3, OUTPUT);
//configure control inputs
pinMode(MAG_SW, INPUT_PULLUP);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
Serial.begin(115200);
/*
displayBuffer[0] = ~0x6D;
displayBuffer[1] = ~0x79;
displayBuffer[2] = ~0x50;
*/
ITimer1.init();
if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_MS, TimerHandler)) {
Serial.println(F("Starting ITimer1 OK"));
} else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
displayShow(0x50, 0x5E, 0x6E); //Message rdY
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(SENSE_TEMP);
speed = analogRead(SENSE_FAN);
if (Serial.available() != 0) {
int tvar = Serial.parseInt();
heater = tvar;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
}
if (digitalRead(MAG_SW)) {
digitalWrite(PIN_FAN, LOW);
if (temp > heater) {
digitalWrite(HEAT_ELEMENT, HIGH);
} else {
digitalWrite(HEAT_ELEMENT, LOW);
}
} else {
digitalWrite(HEAT_ELEMENT, HIGH);
if (temp < 20) digitalWrite(PIN_FAN, HIGH);
}
Serial.print(temp);
Serial.print(" ");
Serial.print(speed);
Serial.print(" ");
Serial.println(heater);
if(Changing_Settings || Changing_Settings_Timeout){
displayNumber(calTable[heater]);
} else {
displayNumber(calTable[temp]);
}
delay(25);
}
//Pin DEF
#define DISPLAY_1 A3
#define DISPLAY_2 A2
#define DISPLAY_3 4
#define DISPLAY_A 8
#define DISPLAY_B 9
#define DISPLAY_C 10
#define DISPLAY_D 11
#define DISPLAY_E 12
#define DISPLAY_F 13
#define DISPLAY_G 6
#define DISPLAY_DP 7
#define PIN_FAN 5
#define SENSE_FAN A1
#define SENSE_TEMP A0
#define HEAT_ELEMENT 3
#define BUTTON_UP A5
#define BUTTON_DOWN A4
#define MAG_SW 2
#define USE_TIMER_1 true
#include "TimerInterrupt.h"
#define TIMER_INTERVAL_MS 5
#define DEBOUNCING_INTERVAL_MS 200
#define LONG_PRESS_INTERVAL_MS 1000
#define LONG_PRESS_INTERVAL_DIV 10
#define SETTINGS_TIMEOUT 3000
#define TEMP_LIMIT 500
#define SAFE_TEMP 40
#define MIN_FAN_VALUE 60
#define SAFE_DISCHARGE_RATIO 0.75f
const int calTable[] = { //Calibration table, temperature by value on ADC
32, 33, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 47, 49, 50,
51, 52, 53, 54, 56, 57, 58, 59,
60, 61, 63, 64, 65, 66, 67, 68,
70, 71, 72, 73, 74, 75, 77, 78,
79, 80, 81, 83, 84, 85, 86, 87,
88, 90, 91, 92, 93, 94, 95, 97,
98, 99, 100, 101, 102, 104, 105, 106,
107, 108, 109, 111, 112, 113, 114, 115,
116, 118, 119, 120, 121, 122, 123, 125,
126, 127, 128, 129, 131, 132, 133, 134,
135, 136, 138, 139, 140, 141, 142, 143,
145, 146, 147, 148, 149, 150, 152, 153,
154, 155, 156, 157, 159, 160, 161, 162,
163, 164, 166, 167, 168, 169, 170, 172,
173, 174, 175, 176, 177, 179, 180, 181,
182, 183, 184, 186, 187, 188, 189, 190,
191, 193, 194, 195, 196, 197, 198, 200,
201, 202, 203, 204, 205, 207, 208, 209,
210, 211, 212, 214, 215, 216, 217, 218,
220, 221, 222, 223, 224, 225, 227, 228,
229, 230, 231, 232, 234, 235, 236, 237,
238, 239, 241, 242, 243, 244, 245, 246,
248, 249, 250, 251, 252, 253, 255, 256,
257, 258, 259, 260, 262, 263, 264, 265,
266, 268, 269, 270, 271, 272, 273, 275,
276, 277, 278, 279, 280, 282, 283, 284,
285, 286, 287, 289, 290, 291, 292, 293,
294, 296, 297, 298, 299, 300, 301, 303,
304, 305, 306, 307, 308, 310, 311, 312,
313, 314, 316, 317, 318, 319, 320, 321,
323, 324, 325, 326, 327, 328, 330, 331
};
//buttons
volatile bool Changing_Settings = false;
volatile int Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
volatile int Cycles_Div = LONG_PRESS_INTERVAL_DIV;
volatile bool Button_Up_Pressed = false;
volatile bool Button_Up_Release = false;
volatile bool Button_Up_Hold = false;
volatile int Button_Up_Cycles = 0;
volatile bool Button_Down_Pressed = false;
volatile bool Button_Down_Release = false;
volatile bool Button_Down_Hold = false;
volatile int Button_Down_Cycles = 0;
struct {
const uint8_t dp = 0x80; // 0 1 2 3 4 5 6 7 8 9 A B C D E F
const uint8_t numbers[16] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 };
} Display7Seg;
volatile int temp = 0, speed = 0, heater = 0;
volatile uint8_t displayBuffer[3] = { 0, 0, 0 };
volatile int displayIndex = 0;
void TimerHandler(void) {
/***********************************
Display MUX Section
***********************************/
switch (displayIndex) {
case 0:
digitalWrite(DISPLAY_3, LOW);
digitalWrite(DISPLAY_1, HIGH);
break;
case 1:
digitalWrite(DISPLAY_1, LOW);
digitalWrite(DISPLAY_2, HIGH);
break;
case 2:
digitalWrite(DISPLAY_2, LOW);
digitalWrite(DISPLAY_3, HIGH);
break;
}
if (0x01 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_A, HIGH);
else digitalWrite(DISPLAY_A, LOW);
if (0x02 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_B, HIGH);
else digitalWrite(DISPLAY_B, LOW);
if (0x04 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_C, HIGH);
else digitalWrite(DISPLAY_C, LOW);
if (0x08 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_D, HIGH);
else digitalWrite(DISPLAY_D, LOW);
if (0x10 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_E, HIGH);
else digitalWrite(DISPLAY_E, LOW);
if (0x20 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_F, HIGH);
else digitalWrite(DISPLAY_F, LOW);
if (0x40 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_G, HIGH);
else digitalWrite(DISPLAY_G, LOW);
if (0x80 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_DP, HIGH);
else digitalWrite(DISPLAY_DP, LOW);
if (displayIndex == 2) displayIndex = 0;
else displayIndex++;
/***********************************
Button Scan Section
***********************************/
if (Button_Up_Pressed) { //actions at Up button
//Button already pressed
Button_Up_Cycles++; //increase the counter
if (Button_Up_Cycles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_UP)) { //at release
//button press action
if (heater < 229) heater++;
Button_Up_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Up_Cycles = DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS;
} else {
if (Button_Up_Cycles > (LONG_PRESS_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (Cycles_Div) {
Cycles_Div--;
} else {
Cycles_Div = LONG_PRESS_INTERVAL_DIV;
if (heater < 229) heater++;
}
}
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_UP) == false) {
Button_Up_Pressed = true;
Changing_Settings = true;
}
}
if (Button_Down_Pressed) { //actions at Down button
//Button already pressed
Button_Down_Cycles++; //increase the counter
if (Button_Down_Cycles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_DOWN)) { //at release
//button press action
if (heater > 0) heater--;
Button_Down_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Down_Cycles = 0;
} else {
if (Button_Down_Cycles > (LONG_PRESS_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (Cycles_Div) {
Cycles_Div--;
} else {
Cycles_Div = LONG_PRESS_INTERVAL_DIV;
if (heater > 0) heater--;
}
}
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_DOWN) == false) {
Button_Down_Pressed = true;
Changing_Settings = true;
}
}
if (Changing_Settings == false && Changing_Settings_Timeout) Changing_Settings_Timeout--;
}
// Raw byte to display buffer
void displayShow(uint8_t symbol1, uint8_t symbol2, uint8_t symbol3) {
displayBuffer[0] = ~symbol1;
displayBuffer[1] = ~symbol2;
displayBuffer[2] = ~symbol3;
}
// uint16_t to display, max value is 999
void displayNumber(uint16_t val) {
int cents = val / 100;
if (cents < 10) displayBuffer[0] = ~Display7Seg.numbers[cents];
else displayShow(0x40, 0x40, 0x40); //Show [---] in overflow 999
int x = val % 100;
int dec = x / 10;
if (dec < 10) displayBuffer[1] = ~Display7Seg.numbers[dec];
int unit = x % 10;
if (unit < 10) displayBuffer[2] = ~Display7Seg.numbers[unit];
}
void criticalError() {
digitalWrite(HEAT_ELEMENT, HIGH); //turn off heat element
digitalWrite(PIN_FAN, LOW); //keep fan on for safety
displayShow(0x79, 0x40, 0x39); //Message [E-C]
Serial.println("#### Critical Error!! ####\r\nTurn off manually");
while (1)
; //stop
}
void setup() {
// put your setup code here, to run once:
//Priority
pinMode(PIN_FAN, OUTPUT); //stop fan
digitalWrite(PIN_FAN, HIGH);
pinMode(HEAT_ELEMENT, OUTPUT); //Set heater and disable
digitalWrite(HEAT_ELEMENT, HIGH); //off
heater = 58;
//Config display pins
pinMode(DISPLAY_A, OUTPUT);
pinMode(DISPLAY_B, OUTPUT);
pinMode(DISPLAY_C, OUTPUT);
pinMode(DISPLAY_D, OUTPUT);
pinMode(DISPLAY_E, OUTPUT);
pinMode(DISPLAY_F, OUTPUT);
pinMode(DISPLAY_G, OUTPUT);
pinMode(DISPLAY_DP, OUTPUT);
pinMode(DISPLAY_1, OUTPUT);
pinMode(DISPLAY_2, OUTPUT);
pinMode(DISPLAY_3, OUTPUT);
//init value should show [8.8.8.] as lamp test
//configure control inputs
pinMode(MAG_SW, INPUT_PULLUP);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
Serial.begin(115200);
ITimer1.init();
if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_MS, TimerHandler)) {
Serial.println(F("Starting"));
} else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
//Startup checks
displayShow(0x04, 0x54, 0x70); //Message [int]
delay(2000); //wait for stability
//Fan test
Serial.print("Fan Test ");
int fan_voltage = analogRead(SENSE_FAN);
Serial.print("Off: ");
Serial.print(fan_voltage);
digitalWrite(PIN_FAN, LOW); // Fan On
delay(2000); //wait for stability
fan_voltage = analogRead(SENSE_FAN);
Serial.print(" On: ");
Serial.print(fan_voltage);
digitalWrite(PIN_FAN, HIGH); // Fan Off
if (fan_voltage < MIN_FAN_VALUE) {
displayShow(0x79, 0x40, 0x71); //Message [E-F]
Serial.println("ERROR: active minimum low");
while (1)
; //stop
}
delay(2); //wait for decay
int fan_hold = analogRead(SENSE_FAN);
Serial.print(" Hold: ");
Serial.print(fan_hold);
float ratio = (float)fan_hold / (float)fan_voltage;
Serial.print(" Ratio: ");
Serial.println(ratio);
if (ratio > SAFE_DISCHARGE_RATIO) {
displayShow(0x79, 0x40, 0x71); //Message [E-F]
Serial.println("ERROR: Fan load low, check connection");
while (1)
; //stop
}
Serial.println("PASS");
//Temp sensor check
int temp_sensor = analogRead(SENSE_TEMP);
Serial.print("Temp Sensor Test: ");
Serial.println(temp_sensor);
if (temp_sensor > 800) { //900 is no sensor lecture
Serial.println("ERROR: Temp Sensor");
displayShow(0x79, 0x40, 0x6D); //Message [E-S]
delay(1000);
while (1)
; //stop
} else Serial.println("PASS");
// Hotair Gun mag switch presence
if (digitalRead(MAG_SW)) { // HIGH = gun not in place or fail switch
Serial.println("Hot Air Gun magnetic switch is open\r\nCheck position in the base");
displayShow(0x7D, 0x1C, 0x54); //Message [Gun]
while (digitalRead(MAG_SW))
; //wait until is in place.
}
Serial.println("Gun detected in the base");
//Heat element test
digitalWrite(PIN_FAN, LOW); //fan on
if (temp_sensor > 40) Serial.println("Too hot to test, waiting. . . ");
while (temp_sensor > 40) { //wait if is hot
temp_sensor = analogRead(SENSE_TEMP);
}
Serial.print("Heat Element Test Temp 1: ");
temp_sensor = analogRead(SENSE_TEMP);
Serial.print(temp_sensor);
digitalWrite(HEAT_ELEMENT, LOW); //heat on
delay(2000); //delay to heat
digitalWrite(HEAT_ELEMENT, HIGH); //off
Serial.print(" Temp 2: ");
int new_temp_sensor = analogRead(SENSE_TEMP);
Serial.println(new_temp_sensor);
if ((new_temp_sensor - temp_sensor) > 15) {
Serial.println("PASS");
displayShow(0x50, 0x5E, 0x6E); //Message [rdY]
Serial.println("Ready");
delay(1000);
} else {
displayShow(0x79, 0x40, 0x76); //Message [E-H]
Changing_Settings_Timeout = 10000 / TIMER_INTERVAL_MS;
Serial.println("Verify heater element");
}
}
#define SAMPLES_TO_AVERAGE 64
int SamplerIndex = 0;
int SamplerArray[SAMPLES_TO_AVERAGE] = { 0 };
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(SENSE_TEMP);
speed = analogRead(SENSE_FAN);
if (Serial.available() != 0) {
int tvar = Serial.parseInt();
heater = tvar;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
}
if (digitalRead(MAG_SW)) {
digitalWrite(PIN_FAN, LOW);
if (temp > heater) {
digitalWrite(HEAT_ELEMENT, HIGH);
if (temp > TEMP_LIMIT) criticalError();
} else {
digitalWrite(HEAT_ELEMENT, LOW);
}
} else {
digitalWrite(HEAT_ELEMENT, HIGH);
if (temp < SAFE_TEMP) digitalWrite(PIN_FAN, HIGH);
//else digitalWrite(PIN_FAN, LOW);
}
Serial.print(temp);
Serial.print(" ");
Serial.print(speed);
Serial.print(" ");
Serial.println(heater);
/* Average samples */
SamplerArray[SamplerIndex] = temp;
if (SamplerIndex < SAMPLES_TO_AVERAGE) SamplerIndex++;
else SamplerIndex = 0;
int sigmaTemp = 0;
for (int i = 0; i < SAMPLES_TO_AVERAGE; i++) {
sigmaTemp += SamplerArray[i];
}
//int tempAvg = sigmaTemp / SAMPLES_TO_AVERAGE;
int tempAvg = sigmaTemp >> 6; // DIV 64
if (Changing_Settings || Changing_Settings_Timeout) {
displayNumber(calTable[heater]);
} else {
if(tempAvg < SAFE_TEMP && digitalRead(MAG_SW)==LOW) displayShow(0x40, 0x40, 0x40);
else displayNumber(calTable[tempAvg]);
}
}
//Pin DEF
#define DISPLAY_C 2
#define DISPLAY_D 3
#define DISPLAY_E 4
#define DISPLAY_F 5
#define DISPLAY_G 6
#define DISPLAY_DP 7
#define DISPLAY_A 8
#define DISPLAY_B 9
#define PIN_FAN 10 //PWM
#define DISPLAY_1 11
#define DISPLAY_2 12
#define DISPLAY_3 A1
#define HEAT_ELEMENT 13
#define FAN_ON LOW
#define FAN_OFF HIGH
#define HEAT_ON LOW
#define HEAT_OFF HIGH
#define SENSE_FAN A2 //Analog
#define SENSE_TEMP A3 //Analog
#define BUTTON_UP A5 //I2C
#define BUTTON_DOWN A4 //I2C
#define MAG_SW A0
#define USE_TIMER_1 true
#include "TimerInterrupt.h"
#define TIMER_INTERVAL_MS 5
#define DEBOUNCING_INTERVAL_MS 200
#define LONG_PRESS_INTERVAL_MS 1000
#define LONG_PRESS_INTERVAL_DIV 10
#define SETTINGS_TIMEOUT 3000
#define TEMP_LIMIT 500
#define SAFE_TEMP 40
#define MIN_FAN_VALUE 60
#define SAFE_DISCHARGE_RATIO 0.75f
const int calTable[] = { //Calibration table, temperature by value on ADC
32, 33, 35, 36, 37, 38, 39, 40,
42, 43, 44, 45, 46, 47, 49, 50,
51, 52, 53, 54, 56, 57, 58, 59,
60, 61, 63, 64, 65, 66, 67, 68,
70, 71, 72, 73, 74, 75, 77, 78,
79, 80, 81, 83, 84, 85, 86, 87,
88, 90, 91, 92, 93, 94, 95, 97,
98, 99, 100, 101, 102, 104, 105, 106,
107, 108, 109, 111, 112, 113, 114, 115,
116, 118, 119, 120, 121, 122, 123, 125,
126, 127, 128, 129, 131, 132, 133, 134,
135, 136, 138, 139, 140, 141, 142, 143,
145, 146, 147, 148, 149, 150, 152, 153,
154, 155, 156, 157, 159, 160, 161, 162,
163, 164, 166, 167, 168, 169, 170, 172,
173, 174, 175, 176, 177, 179, 180, 181,
182, 183, 184, 186, 187, 188, 189, 190,
191, 193, 194, 195, 196, 197, 198, 200,
201, 202, 203, 204, 205, 207, 208, 209,
210, 211, 212, 214, 215, 216, 217, 218,
220, 221, 222, 223, 224, 225, 227, 228,
229, 230, 231, 232, 234, 235, 236, 237,
238, 239, 241, 242, 243, 244, 245, 246,
248, 249, 250, 251, 252, 253, 255, 256,
257, 258, 259, 260, 262, 263, 264, 265,
266, 268, 269, 270, 271, 272, 273, 275,
276, 277, 278, 279, 280, 282, 283, 284,
285, 286, 287, 289, 290, 291, 292, 293,
294, 296, 297, 298, 299, 300, 301, 303,
304, 305, 306, 307, 308, 310, 311, 312,
313, 314, 316, 317, 318, 319, 320, 321,
323, 324, 325, 326, 327, 328, 330, 331
};
//buttons
volatile bool Changing_Settings = false;
volatile int Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
volatile int Cycles_Div = LONG_PRESS_INTERVAL_DIV;
volatile bool Button_Up_Pressed = false;
volatile bool Button_Up_Release = false;
volatile bool Button_Up_Hold = false;
volatile int Button_Up_Cycles = 0;
volatile bool Button_Down_Pressed = false;
volatile bool Button_Down_Release = false;
volatile bool Button_Down_Hold = false;
volatile int Button_Down_Cycles = 0;
struct {
const uint8_t dp = 0x80; // 0 1 2 3 4 5 6 7 8 9 A B C D E F
const uint8_t numbers[16] = { 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71 };
} Display7Seg;
#include <ArduinoJson.h>
volatile int temp = 0, speed = 0, heater = 0, Target = 0;
volatile bool Enabled = true;
volatile uint8_t displayBuffer[3] = { 0, 0, 0 };
volatile int displayIndex = 0;
void TimerHandler(void) {
/***********************************
Display MUX Section
***********************************/
switch (displayIndex) {
case 0:
digitalWrite(DISPLAY_3, LOW);
digitalWrite(DISPLAY_1, HIGH);
break;
case 1:
digitalWrite(DISPLAY_1, LOW);
digitalWrite(DISPLAY_2, HIGH);
break;
case 2:
digitalWrite(DISPLAY_2, LOW);
digitalWrite(DISPLAY_3, HIGH);
break;
}
if (0x01 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_A, HIGH);
else digitalWrite(DISPLAY_A, LOW);
if (0x02 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_B, HIGH);
else digitalWrite(DISPLAY_B, LOW);
if (0x04 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_C, HIGH);
else digitalWrite(DISPLAY_C, LOW);
if (0x08 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_D, HIGH);
else digitalWrite(DISPLAY_D, LOW);
if (0x10 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_E, HIGH);
else digitalWrite(DISPLAY_E, LOW);
if (0x20 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_F, HIGH);
else digitalWrite(DISPLAY_F, LOW);
if (0x40 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_G, HIGH);
else digitalWrite(DISPLAY_G, LOW);
if (0x80 & displayBuffer[displayIndex]) digitalWrite(DISPLAY_DP, HIGH);
else digitalWrite(DISPLAY_DP, LOW);
if (displayIndex == 2) displayIndex = 0;
else displayIndex++;
/***********************************
Button Scan Section
***********************************/
if (Button_Up_Pressed) { //actions at Up button
//Button already pressed
Button_Up_Cycles++; //increase the counter
if (Button_Up_Cycles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_UP)) { //at release
//button press action
if (heater < 229) heater++;
Button_Up_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Up_Cycles = DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS;
} else {
if (Button_Up_Cycles > (LONG_PRESS_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (Cycles_Div) {
Cycles_Div--;
} else {
Cycles_Div = LONG_PRESS_INTERVAL_DIV;
if (heater < 229) heater++;
}
}
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_UP) == false) {
Button_Up_Pressed = true;
Changing_Settings = true;
}
}
if (Button_Down_Pressed) { //actions at Down button
//Button already pressed
Button_Down_Cycles++; //increase the counter
if (Button_Down_Cycles >= (DEBOUNCING_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (digitalRead(BUTTON_DOWN)) { //at release
//button press action
if (heater > 0) heater--;
Button_Down_Pressed = false;
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
Changing_Settings = false;
Button_Down_Cycles = 0;
} else {
if (Button_Down_Cycles > (LONG_PRESS_INTERVAL_MS / TIMER_INTERVAL_MS)) {
if (Cycles_Div) {
Cycles_Div--;
} else {
Cycles_Div = LONG_PRESS_INTERVAL_DIV;
if (heater > 0) heater--;
}
}
}
}
} else {
//Button not pressed
if (digitalRead(BUTTON_DOWN) == false) {
Button_Down_Pressed = true;
Changing_Settings = true;
}
}
if (Changing_Settings == false && Changing_Settings_Timeout) Changing_Settings_Timeout--;
}
// Raw byte to display buffer
void displayShow(uint8_t symbol1, uint8_t symbol2, uint8_t symbol3) {
displayBuffer[0] = ~symbol1;
displayBuffer[1] = ~symbol2;
displayBuffer[2] = ~symbol3;
}
// uint16_t to display, max value is 999
void displayNumber(uint16_t val) {
int cents = val / 100;
if (cents < 10) displayBuffer[0] = ~Display7Seg.numbers[cents];
else displayShow(0x40, 0x40, 0x40); //Show [---] in overflow 999
int x = val % 100;
int dec = x / 10;
if (dec < 10) displayBuffer[1] = ~Display7Seg.numbers[dec];
int unit = x % 10;
if (unit < 10) displayBuffer[2] = ~Display7Seg.numbers[unit];
}
void criticalError() {
digitalWrite(HEAT_ELEMENT, HIGH); //turn off heat element
digitalWrite(PIN_FAN, LOW); //keep fan on for safety
displayShow(0x79, 0x40, 0x39); //Message [E-C]
Serial.println("#### Critical Error!! ####\r\nTurn off manually");
while (1)
; //stop
}
void SysTest() {
//Fan test
Serial.print("Fan Test ");
int fan_voltage = analogRead(SENSE_FAN);
Serial.print("Off: ");
Serial.print(fan_voltage);
digitalWrite(PIN_FAN, LOW); // Fan On
delay(2000); //wait for stability
fan_voltage = analogRead(SENSE_FAN);
Serial.print(" On: ");
Serial.print(fan_voltage);
digitalWrite(PIN_FAN, HIGH); // Fan Off
if (fan_voltage < MIN_FAN_VALUE) {
displayShow(0x79, 0x40, 0x71); //Message [E-F]
Serial.println("ERROR: active minimum low");
while (1)
; //stop
}
delay(2); //wait for decay
int fan_hold = analogRead(SENSE_FAN);
Serial.print(" Hold: ");
Serial.print(fan_hold);
float ratio = (float)fan_hold / (float)fan_voltage;
Serial.print(" Ratio: ");
Serial.println(ratio);
if (ratio > SAFE_DISCHARGE_RATIO) {
displayShow(0x79, 0x40, 0x71); //Message [E-F]
Serial.println("ERROR: Fan load low, check connection");
while (1)
; //stop
}
Serial.println("PASS");
//Temp sensor check
int temp_sensor = analogRead(SENSE_TEMP);
Serial.print("Temp Sensor Test: ");
Serial.println(temp_sensor);
if (temp_sensor > 800) { //900 is no sensor lecture
Serial.println("ERROR: Temp Sensor");
displayShow(0x79, 0x40, 0x6D); //Message [E-S]
delay(1000);
while (1)
; //stop
} else Serial.println("PASS");
// Hotair Gun mag switch presence
if (digitalRead(MAG_SW)) { // HIGH = gun not in place or fail switch
Serial.println("Hot Air Gun magnetic switch is open\r\nCheck position in the base");
displayShow(0x7D, 0x1C, 0x54); //Message [Gun]
while (digitalRead(MAG_SW))
; //wait until is in place.
}
Serial.println("Gun detected in the base");
//Heat element test
digitalWrite(PIN_FAN, LOW); //fan on
if (temp_sensor > 40) {
Serial.println("Too hot to test, waiting. . . ");
displayShow(0x76, 0x5C, 0x70); //Message [Hot]
}
while (temp_sensor > 40) { //wait if is hot
temp_sensor = analogRead(SENSE_TEMP);
}
Serial.print("Heat Element Test Temp 1: ");
temp_sensor = analogRead(SENSE_TEMP);
Serial.print(temp_sensor);
digitalWrite(HEAT_ELEMENT, LOW); //heat on
delay(2000); //delay to heat
digitalWrite(HEAT_ELEMENT, HIGH); //off
Serial.print(" Temp 2: ");
int new_temp_sensor = analogRead(SENSE_TEMP);
Serial.println(new_temp_sensor);
if ((new_temp_sensor - temp_sensor) > 15) {
Serial.println("PASS");
displayShow(0x50, 0x5E, 0x6E); //Message [rdY]
Serial.println("Ready");
delay(1000);
} else {
displayShow(0x79, 0x40, 0x76); //Message [E-H]
Changing_Settings_Timeout = 10000 / TIMER_INTERVAL_MS;
Serial.println("Verify heater element");
while (temp_sensor > 40) { //wait if is hot
temp_sensor = analogRead(SENSE_TEMP);
}
digitalWrite(PIN_FAN, HIGH); // Fan Off
delay(10000);
}
}
String inputString = ""; // a String to hold incoming data
bool stringComplete = false; // whether the string is complete
void setup() {
// put your setup code here, to run once:
//Priority
pinMode(HEAT_ELEMENT, OUTPUT); //Set heater and disable
digitalWrite(HEAT_ELEMENT, HIGH); //off
pinMode(PIN_FAN, OUTPUT); //Fan
digitalWrite(PIN_FAN, HIGH);
//configure control inputs
pinMode(MAG_SW, INPUT_PULLUP);
pinMode(BUTTON_UP, INPUT_PULLUP);
pinMode(BUTTON_DOWN, INPUT_PULLUP);
heater = 58;
//Config display pins
pinMode(DISPLAY_A, OUTPUT);
pinMode(DISPLAY_B, OUTPUT);
pinMode(DISPLAY_C, OUTPUT);
pinMode(DISPLAY_D, OUTPUT);
pinMode(DISPLAY_E, OUTPUT);
pinMode(DISPLAY_F, OUTPUT);
pinMode(DISPLAY_G, OUTPUT);
pinMode(DISPLAY_DP, OUTPUT);
pinMode(DISPLAY_1, OUTPUT);
pinMode(DISPLAY_2, OUTPUT);
pinMode(DISPLAY_3, OUTPUT);
Serial.begin(115200);
inputString.reserve(60);
ITimer1.init();
if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_MS, TimerHandler)) {
Serial.println(F("Starting"));
} else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
//Startup checks
displayShow(0x04, 0x54, 0x70); //Message [int]
delay(2000); //wait for stability
SysTest();
}
#define SAMPLES_TO_AVERAGE 64
int SamplerIndex = 0;
int SamplerArray[SAMPLES_TO_AVERAGE] = { 0 };
int tempAvg = 0;
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(SENSE_TEMP);
speed = analogRead(SENSE_FAN);
if (stringComplete) {
//int tvar = Serial.parseInt();
//heater = tvar;
StaticJsonDocument<24> filter;
filter["Target"] = true;
filter["Enabled"] = true;
StaticJsonDocument<60> doc;
DeserializationError error = deserializeJson(doc, inputString, DeserializationOption::Filter(filter));
if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}
if (inputString.indexOf("Target") > 0) {
Target = doc["Target"]; // 999
int indexSearch = 0;
while (Target > (calTable[indexSearch])) indexSearch++;
if (indexSearch == 0) {
heater = 0;
} else if (indexSearch < (sizeof(calTable) / sizeof(calTable[0]))) {
heater = indexSearch - 1;
} else {
heater = (sizeof(calTable) / sizeof(calTable[0])) - 1;
}
}
if (inputString.indexOf("Enabled") > 0)
Enabled = doc["Enabled"]; // 1
Changing_Settings_Timeout = SETTINGS_TIMEOUT / TIMER_INTERVAL_MS;
inputString = "";
stringComplete = false;
}
if (digitalRead(MAG_SW) && Enabled) {
digitalWrite(PIN_FAN, LOW);
if (temp > heater) {
digitalWrite(HEAT_ELEMENT, HIGH);
if (temp > TEMP_LIMIT) criticalError();
} else {
digitalWrite(HEAT_ELEMENT, LOW);
}
} else {
digitalWrite(HEAT_ELEMENT, HIGH);
if (temp < SAFE_TEMP) digitalWrite(PIN_FAN, HIGH);
//else digitalWrite(PIN_FAN, LOW);
}
Serial.print("{\"Target\": ");
Serial.print(calTable[heater]);
Serial.print(", \"Fan\": ");
Serial.print(speed);
Serial.print(", \"Status\": ");
Serial.print(digitalRead(MAG_SW) ? 1 : 0); //Active HIGH
Serial.print(", \"Enabled\": ");
Serial.print(Enabled ? 1 : 0); //Active HIGH
Serial.print(", \"Sensor\": ");
Serial.print(calTable[temp]);
Serial.print(", \"Avg\": ");
Serial.print(calTable[tempAvg]);
Serial.print(", \"Heater\": ");
Serial.print(bitRead(PORTB, 5) ? 0 : 1); //Active LOW Lectura de estado de pin
Serial.println("}");
/* Average samples */
SamplerArray[SamplerIndex] = temp;
if (SamplerIndex < SAMPLES_TO_AVERAGE) SamplerIndex++;
else SamplerIndex = 0;
int sigmaTemp = 0;
for (int i = 0; i < SAMPLES_TO_AVERAGE; i++) {
sigmaTemp += SamplerArray[i];
}
//int tempAvg = sigmaTemp / SAMPLES_TO_AVERAGE;
tempAvg = sigmaTemp >> 6; // DIV 64
if (Changing_Settings || Changing_Settings_Timeout) {
displayNumber(calTable[heater]);
} else {
if (tempAvg < SAFE_TEMP && digitalRead(MAG_SW) == LOW) displayShow(0x40, 0x40, 0x40);
else displayNumber(calTable[tempAvg]);
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}
Uieru¿Ese comportamiento ocurre en cualquier temperatura que estableces o solo al pasar los 200ºC? me refiero a si ocurre si lo estableces a 150ºC, por ejemplo. Eso podría indicar también fallo en el firmware como le pasó a la mía, en mi caso la entrada que detectaba el interruptor en la pistola se estaba comportando como salida a tierra por lo que no se activaba al removerla de la base.
El 78M05 es regulador de voltaje, normalmente el TRIAC se usa para el control de la resistencia calefactora, te recomendaría revisar primero el voltaje del ventilador según sea de 24 o 12V, en uno de mis mensajes mientras reparaba la mía puse el circuito que obtuve al ver el trazado del circuito del ventilador, tendrás que revisar de dónde viene la línea del ventilador y determinar el circuito, quizá hasta se parecen, para mi caso uno de los transistores estaba dañado por lo que el ventilador quedaba encendido a máxima velocidad así que tienes que evaluar que puede causar el error, por otra parte, recomendaría que no conectes la resistencia mientras pruebas que el ventilador sí reciba el voltaje correcto.Un gusto señores , Soy nuevo y estuve leyendo todo este hilo y les paso a comentar a ver si alguien puede confirmarme un herror en una estacion de soldado Marca YAXUN 852 A+, La falla es en la pistola de calor el soplador esta en la pistola como un FAN , la falla es que empiesa a calentar y no para hasta derretir todo . compre una de repuesto y lo que pude ver es que el ventilador no prende pero el regulador no sube ni baja la temperatura y la tira a derretir a la nueva igual . revise y tiene in triac 908 0122G ( este me mide 2) justo al lado del regulador de la pistola que no me mide igual que el que esta del lado del cautin 78M05( este me mide 26) Midiendo con DCV del tester todo lo demas ya hice segun fui leyendo , repase soldaduras medi y revise cada regulador y continuidad . desde ya mucahs gracias pro su ayuda...
Hola , gracias por tu rápida respuesta , y crees que lo que me da un valor indique su funcionamiento correcto ? Y que el 908 j122G mida solo " sea también correcto? Ahora voy a medir otras partes y mediré si le llega voltaje . Gracias de antemano y segiré midiendo.el 78M05 es regulador de voltaje, normalmente el TRIAC se usa para el control de la resistencia calefactora, te recomendaría revisar primero el voltaje del ventilador según sea de 24 o 12V, en uno de mis mensajes mientras reparaba la mía puse el circuito que obtuve al ver el trazado del circuito del ventilador, tendrás que revisar de donde viene la línea del ventilador y determinar el circuito, quizá hasta se parecen, para mi caso uno de los transistores estaba dañado por lo que el ventilador quedaba encendido a máxima velocidad así que tienes que evaluar que puede causar el error, por otra parte, recomendaría que no conectes la resistencia mientras pruebas que el ventilador sí reciba el voltaje correcto.
@Nuyel , Ok revisé lo del ventilador , no le llega corriente y me di cuenta que el cautin cuando está calentando el led titila , pero el de la pistola está fijo y prendido o apagado le llega corriente a la pistola y empieza a calentar desde que lo enchufo , Desoldé la resistencia y en el relój de la temperatura con la resistencia desoldada pone 3 rayitas , sin la pistola o con la resistencia soldada el relój muestra números. Gracias_por su ayuda.@Nuyel , Ahi revise tu mensaje ... pfssss Solo entendilo del Q1 por el Q2 que lo explicaste , no soy tecnico y compre la estacion para aprender y estoy aprendiendo con la estacion JAJA .... Voy a empezar con lo que me decis y despues comento ...![]()