// Soldering lightsaber // !!! Disclaimer - read this !!! ------------------------------------------------------------------ // This firmware is purely for experimental and demonstrative purposes. // This AI firmware is not the final tested version and it could take erroneous decisions // that could lead to hazards. The designer assumes no responsibility for any of these. // Hazards could include but are not limited to: severe injuries, explosions, domestic fires, death. // !!! Exercise caution at all times when testing it !!! ------------------------------------------ #include "msp430G2553.h" #include "math.h" //============ Define preset values here #define firmware_version 2.1 // This will show up on the Info screen #define hardware_version 3.3 // This will show up on the Info screen - The first char means A,B or C versions #define encoder_revert 1 // (0) This will revert the logic and the rotation way of the encoder. 1 means revert. #define max_solder_temp 440 // [*C] (440) maximum temperature you can set #define min_solder_temp 250 // [*C] (250) minimum temperature you can set #define max_sb_temp 200 // [*C] (200) maximum temperature you can set #define min_sb_temp 50 // [*C] (50) minimum temperature you can set #define max_time 500 // [s] (390) maximum time you can set before the soldering iron will drop to st by temperature #define min_time 30 // [s] minimum time you can set before the soldering iron will drop to st by temperature #define default_time 300 // [s] default time until the soldering iron will drop to st by temperature #define default_st_by_temp 195 // [*C] default stand by temperature #define default_solder_temp 395// [*C] default soldering temperature #define default_sound 2 // default sound setting #define default_light 55 // PWM default backlight setting #define tip_ol_value 0.0 // [A] (0.5) less than this current on the heating element will trigger the error #define tip_sc_value 9.0 // [A] (5.0) more than this current on the heating element will trigger the error #define tip_range_temp 820 // [*C] (620) more than this temp value triggers an error #define th_shut_down 85 // [*C] thermal shut down - PCB temp value at which the soldering station stops the heating #define over_voltage_value 29 // [V] exceeding this input voltage will trigger the error //=========== Define general values here #define Clear 0x00 // LCD bits and commands definition #define SDA BIT0 #define SCL BIT1 #define SLAVE_ADDR 0x78 #define COMMAND_STR 0x00 #define COMMA_SINGLE 0x80 #define DATA_STR 0x40 #define DISP_OFF 0xAE #define DISP_ON 0xAF #define SETCOL_ADR 0x21 #define SETPAGE_ADR 0x22 #define SETSTARTLINE 0x40 #define SETCONTRAST 0x81 #define MEMORYMODE 0x20 #define SETMULTIPLEX 0xA8 #define DISP_OFFSET 0xD3 #define CHARGE_PUMP 0x8D #define DISP_CK_DIV 0x5D #define PRE_CHARGE 0xD9 #define VCOMH_DESEL 0xDB #define NORMAL_DISP 0xA6 #define INVERT_DISP 0xA7 #define NORMAL_X 0xA1 #define FLIPED_X 0xA0 #define NORMAL_Y 0xC8 #define FLIPED_Y 0xC0 #define EN_heater BIT0 #define ERR_OL BIT0 // Open load error. Signifies disconnected aviator plug or heating element #define ERR_DT BIT1 // Damaged tip error (taking too much current or too less). Signifies poor contact, short circuit, loose wires or burned heating element #define ERR_OT BIT2 // Over temp error. Signifies that the motherboard is too hot #define ERR_OV BIT3 // Over voltage error. Signifies that the input voltage is above the safe limit. const unsigned char bck_ground_logo1[28] = {'S','o','l','d','e','r','i','n','g','l','i','g','h','t','s','a','b','e','r',' ','M','a','r','i','u','s',' ','T'}; const unsigned char AI_preheat_txt[10]={'A','I',' ','p','r','e','h','e','a','t'}; const unsigned char bck_ground_main[16] = {' ',' ','M','a','i','n',' ',' ',0x00,0x01,' ',' ',' ',' ',' ','>'}; const unsigned char bck_ground_solder[16] = {' ','S','o','l','d','e','r',' ',0x00,0x01,' ',' ',0x02,' ',' ','>'}; const unsigned char bck_ground_up[16] = {'U','p',' ','t','e','m','p',' ','<',' ',' ',' ',0x02,' ',' ','>'}; const unsigned char bck_ground_low[8] = {'L','o','w',' ','t','e','m','p'}; const unsigned char bck_ground_time[8] = {'T','i','m','e',' ','h','o','t'}; const unsigned char bck_ground_sound[8] = {' ','S','o','u','n','d',' ',' '}; const unsigned char bck_ground_light[8] = {'B','k',' ','l','i','g','h','t'}; const unsigned char bck_ground_default[16] = {'D','e','f','a','u','l','t',' ','A','l','l',' ','s','e','t',' '}; const unsigned char bck_ground_info[16] = {' ',' ','I','n','f','o',' ',' ','<',' ',' ',' ',0x02,' ',' ',' '}; const unsigned char bck_ground_subsolder[16] = {' ',' ',' ',' ',' ',' ','*','C'}; const unsigned char bck_ground_retmain[8] = {'M','a','i','n',' ',0x02,' ','>'}; const unsigned char bck_ground_retsol[8] = {'<',' ',0x02,' ','B','a','c','k'}; const unsigned char err_plug[8] = {'E','r','r',' ','p','l','u','g'}; const unsigned char err_tip[8] = {'E','r','r',' ','t','i','p',' '}; const unsigned char err_over_heat[8] = {'O','v','r',' ','h','e','a','t'}; const unsigned char err_over_volt[8] = {'O','v','r',' ','v','o','l','t'}; const unsigned char errors_multiple[8] = {' ','E','r','r','o','r','s',' '}; const unsigned char mask[8] = {0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; const unsigned char ascii_chart[640] = { /*00-000- */0x80,0x40,0x28,0x1C,0x3E, /*01-001- */0x0F,0x07,0x01,0x02,0x1C, /*02-002- */0x82,0x66,0xAF,0xE6,0x82, /*03-003- */0x78,0x24,0x22,0x24,0x78, /*04-004- */0x78,0x24,0x22,0x24,0x78, /*05-005- */0x78,0x24,0x22,0x24,0x78, /*06-006- */0x78,0x24,0x22,0x24,0x78, /*07-007- */0x78,0x24,0x22,0x24,0x78, /*08-008- */0x78,0x24,0x22,0x24,0x78, /*09-009- */0x78,0x24,0x22,0x24,0x78, /*0A-010- */0x78,0x24,0x22,0x24,0x78, /*0B-011- */0x78,0x24,0x22,0x24,0x78, /*0C-012- */0x78,0x24,0x22,0x24,0x78, /*0D-013- */0x78,0x24,0x22,0x24,0x78, /*0E-014- */0x78,0x24,0x22,0x24,0x78, /*0F-015- */0x78,0x24,0x22,0x24,0x78, /*10-016- */0x78,0x24,0x22,0x24,0x78, /*11-017- */0x78,0x24,0x22,0x24,0x78, /*12-018- */0x78,0x24,0x22,0x24,0x78, /*13-019- */0x78,0x24,0x22,0x24,0x78, /*14-020- */0x78,0x24,0x22,0x24,0x78, /*15-021- */0x78,0x24,0x22,0x24,0x78, /*16-022- */0x78,0x24,0x22,0x24,0x78, /*17-023- */0x78,0x24,0x22,0x24,0x78, /*18-024- */0x78,0x24,0x22,0x24,0x78, /*19-025- */0x78,0x24,0x22,0x24,0x78, /*1A-026- */0x78,0x24,0x22,0x24,0x78, /*1B-027- */0x78,0x24,0x22,0x24,0x78, /*1C-028- */0x78,0x24,0x22,0x24,0x78, /*1D-029- */0x78,0x24,0x22,0x24,0x78, /*1E-030- */0x78,0x24,0x22,0x24,0x78, /*1F-031- */0x78,0x24,0x22,0x24,0x78, /*20-032- */0x00,0x00,0x00,0x00,0x00, /*21-033- */0x78,0x24,0x22,0x24,0x78, /*22-034- */0x78,0x24,0x22,0x24,0x78, /*23-035- */0x78,0x24,0x22,0x24,0x78, /*24-036- */0x78,0x24,0x22,0x24,0x78, /*25-037-%*/0x23,0x13,0x08,0x64,0x62, /*26-038- */0x78,0x24,0x22,0x24,0x78, /*27-039- */0x78,0x24,0x22,0x24,0x78, /*28-040- */0x78,0x24,0x22,0x24,0x78, /*29-041- */0x78,0x24,0x22,0x24,0x78, /*2A-042-**/0x00,0x06,0x09,0x09,0x06, /*2B-043-+*/0x08,0x08,0x3E,0x08,0x08, /*2C-044-,*/0x78,0x24,0x22,0x24,0x78, /*2D-045--*/0x08,0x08,0x08,0x08,0x08, /*2E-046-.*/0x00,0x60,0x60,0x00,0x00, /*2F-047- */0x78,0x24,0x22,0x24,0x78, /*30-048-0*/0x3E,0x51,0x49,0x45,0x3E, /*31-049-1*/0x00,0x42,0x7F,0x40,0x00, /*32-050-2*/0x42,0x61,0x51,0x49,0x46, /*33-051-3*/0x21,0x41,0x45,0x4B,0x31, /*34-052-4*/0x18,0x14,0x12,0x7F,0x10, /*35-053-5*/0x27,0x45,0x45,0x45,0x39, /*36-054-6*/0x3C,0x4A,0x49,0x49,0x30, /*37-055-7*/0x03,0x01,0x71,0x09,0x07, /*38-056-8*/0x36,0x49,0x49,0x49,0x36, /*39-057-9*/0x06,0x49,0x49,0x29,0x1E, /*3A-058- */0x78,0x24,0x22,0x24,0x78, /*3B-059- */0x78,0x24,0x22,0x24,0x78, /*3C-060-<*/0x64,0xCE,0x9F,0x84,0x78, /*3D-061-=*/0x14,0x14,0x14,0x14,0x14, /*3E-062->*/0x78,0x84,0x9F,0xCE,0x64, /*3F-063- */0x78,0x24,0x9F,0xCE,0x64, /*40-064- */0x78,0x24,0x22,0x24,0x78, /*41-065-A*/0x7C,0x1E,0x11,0x12,0x7C, /*42-066-B*/0x7F,0x79,0x49,0x49,0x36, /*43-067-C*/0x3E,0x7F,0x41,0x41,0x22, /*44-068-D*/0x7F,0x7F,0x41,0x41,0x3E, /*45-069-E*/0x7F,0x7F,0x49,0x49,0x41, /*46-070-F*/0x7F,0x7F,0x09,0x09,0x01, /*47-071-G*/0x3E,0x7F,0x41,0x51,0x72, /*48-072-H*/0x7F,0x7F,0x08,0x08,0x7F, /*49-073-I*/0x00,0x41,0x7F,0x41,0x00, /*4A-074-J*/0x20,0x41,0x41,0x3F,0x01, /*4B-075-K*/0x7F,0x1C,0x36,0x63,0x41, /*4C-076-L*/0x7F,0x7F,0x40,0x40,0x40, /*4D-077-M*/0x7F,0x02,0x0C,0x02,0x7F, /*4E-078-N*/0x7F,0x06,0x0C,0x18,0x7F, /*4F-079-O*/0x3E,0x7F,0x41,0x41,0x3E, /*50-080-P*/0x7F,0x0F,0x09,0x09,0x06, /*51-081-Q*/0x3E,0x7F,0x51,0x21,0x5E, /*52-082-R*/0x7F,0x0F,0x19,0x29,0x46, /*53-083-S*/0x46,0x4F,0x49,0x79,0x31, /*54-084-T*/0x01,0x01,0x7F,0x01,0x01, /*55-085-U*/0x3F,0x7F,0x40,0x40,0x3F, /*56-086-V*/0x1F,0x20,0x60,0x20,0x1F, /*57-087-W*/0x3F,0x40,0x38,0x40,0x3F, /*58-088-X*/0x63,0x14,0x08,0x14,0x63, /*59-089-Y*/0x07,0x08,0x70,0x08,0x07, /*5A-090-Z*/0x61,0x71,0x49,0x45,0x43, /*5B-091- */0x78,0x24,0x22,0x24,0x78, /*5C-092- */0x78,0x24,0x22,0x24,0x78, /*5D-093- */0x78,0x24,0x22,0x24,0x78, /*5E-094- */0x78,0x24,0x22,0x24,0x78, /*5F-095- */0x78,0x24,0x22,0x24,0x78, /*60-096- */0x78,0x24,0x22,0x24,0x78, /*61-097-a*/0x20,0x54,0x54,0x54,0x78, /*62-098-b*/0x7F,0x48,0x44,0x44,0x38, /*63-099-c*/0x38,0x44,0x44,0x44,0x20, /*64-100-d*/0x38,0x44,0x44,0x48,0x3F, /*65-101-e*/0x38,0x54,0x54,0x54,0x18, /*66-102-f*/0x08,0x7E,0x09,0x01,0x02, /*67-103-g*/0x0C,0x52,0x52,0x52,0x2E, /*68-104-h*/0x7F,0x08,0x04,0x04,0x78, /*69-105-i*/0x00,0x44,0x7D,0x40,0x00, /*6A-106-j*/0x20,0x40,0x44,0x3D,0x00, /*6B-107-k*/0x7F,0x10,0x28,0x44,0x00, /*6C-108-l*/0x00,0x41,0x7F,0x40,0x00, /*6D-109-m*/0x7C,0x04,0x18,0x04,0x78, /*6E-110-n*/0x7C,0x08,0x04,0x04,0x78, /*6F-111-o*/0x38,0x44,0x44,0x44,0x38, /*70-112-p*/0x7C,0x14,0x14,0x14,0x08, /*71-113-q*/0x08,0x14,0x14,0x18,0x7C, /*72-114-r*/0x7C,0x08,0x04,0x04,0x08, /*73-115-s*/0x48,0x54,0x54,0x54,0x20, /*74-116-t*/0x04,0x3F,0x44,0x40,0x20, /*75-117-u*/0x3C,0x40,0x40,0x20,0x7C, /*76-118-v*/0x1C,0x20,0x40,0x20,0x1C, /*77-119-w*/0x3C,0x40,0x38,0x40,0x3C, /*78-120-x*/0x44,0x28,0x10,0x28,0x44, /*79-121-y*/0x0C,0x50,0x50,0x50,0x3C, /*7A-122-z*/0x44,0x64,0x54,0x4C,0x44, /*7B-123- */0x78,0x24,0x22,0x24,0x78, /*7C-124- */0x78,0x24,0x22,0x24,0x78, /*7D-125- */0x78,0x24,0x22,0x24,0x78, /*7E-126- */0x78,0x24,0x22,0x24,0x78, /*7F-127- */0x78,0x24,0x22,0x24,0x78, }; const unsigned char large_number_chart[220] = { /*01-000-0*/0xFC,0x06,0x03,0x01,0x01, /*02-000-0*/0x01,0x01,0x03,0xFE,0xFC, /*03-000-0*/0x1F,0x20,0x40,0x40,0x40, /*04-000-0*/0x40,0x40,0x60,0x3F,0x1F, /*01-000-1*/0x20,0x30,0x18,0x0C,0x06, /*02-000-1*/0xFF,0xFF,0x00,0x00,0x00, /*03-000-1*/0x40,0x60,0x60,0x60,0x60, /*04-000-1*/0x7F,0x7F,0x60,0x60,0x70, /*01-000-2*/0x30,0x3C,0x06,0x03,0x01, /*02-000-2*/0x01,0x81,0xC3,0x66,0x3C, /*03-000-2*/0x60,0x70,0x78,0x6C,0x66, /*04-000-2*/0x63,0x61,0x60,0x60,0x70, /*01-000-3*/0x07,0x03,0x03,0x03,0xC3, /*02-000-3*/0xC3,0x63,0x13,0x0B,0x07, /*03-000-3*/0x30,0x60,0x60,0x60,0x60, /*04-000-3*/0x60,0x61,0x61,0x33,0x1E, /*01-000-4*/0xC0,0xF0,0x3C,0x0F,0x03, /*02-000-4*/0x00,0xE0,0x00,0x00,0x00, /*03-000-4*/0x03,0x03,0x03,0x03,0x03, /*04-000-4*/0x03,0x7F,0x03,0x03,0x03, /*01-000-5*/0xFF,0xC3,0x63,0x63,0x63, /*02-000-5*/0x63,0x63,0xE3,0xC3,0x87, /*03-000-5*/0x30,0x30,0x40,0x40,0x40, /*04-000-5*/0x40,0x40,0x60,0x3F,0x1F, /*01-000-6*/0xF0,0xF8,0x6C,0x66,0x63, /*02-000-6*/0x61,0x61,0xE0,0xC0,0x80, /*03-000-6*/0x1F,0x20,0x40,0x40,0x40, /*04-000-6*/0x40,0x40,0x60,0x3F,0x1F, /*01-000-7*/0x07,0x03,0x03,0x03,0x03, /*02-000-7*/0x83,0xE3,0x7B,0x1F,0x07, /*03-000-7*/0x00,0x00,0x01,0x79,0x7F, /*04-000-7*/0x07,0x01,0x01,0x00,0x00, /*01-000-8*/0x80,0xCE,0x5B,0x71,0x61, /*02-000-8*/0x61,0x61,0xFF,0xCE,0x80, /*03-000-8*/0x1F,0x20,0x40,0x40,0x40, /*04-000-8*/0x40,0x40,0x60,0x3F,0x1F, /*01-000-9*/0xFC,0x86,0x03,0x01,0x01, /*02-000-9*/0x01,0x01,0x83,0xFE,0xFC, /*03-000-9*/0x00,0x01,0x01,0x01,0x61, /*04-000-9*/0x79,0x1F,0x07,0x01,0x00, /*01-000-|*/0x7C,0xC7,0x00,0x78,0x1F, /*02-000-|*/0x00,0xA0,0xF0,0xF8,0xFC, /*03-000-|*/0x40,0x31,0x38,0x1C,0x0E, /*04-000-|*/0x07,0x03,0x21,0x70,0x21 }; const unsigned char Init[27] = { 0x00, DISP_OFF, COMMAND_STR, SETCONTRAST,0x7F, MEMORYMODE,0x00, 0xB0,0x00,0x10, FLIPED_X, FLIPED_Y, SETMULTIPLEX,0x3F, DISP_OFFSET,0x00, CHARGE_PUMP,0x14, DISP_CK_DIV,0x80, PRE_CHARGE,0x22, VCOMH_DESEL,0x20, NORMAL_DISP, SETSTARTLINE, DISP_ON}; const unsigned char default_learning_stack[20] = {188,252,332,1540,621,477,320,249,241,252,25,23,20,12,16,19,20,23,25,22}; int array_div_mod[4]; float medc[5],medv[5],medbt[5],medtt[5]; float machine_learning_volt[10]; //x float machine_learning_time[10]; //y float x_bar_difference[10]; //(x-x') float y_bar_difference[10]; //(y-y') unsigned char match,match_low,err,txt,half,first_heat; int temp2,tenthsp,unitsp,tenthsv,unitsv,decimal1v,menu; int tenthsbt,unitsbt,tenthstt,unitstt,decimal1tt; int menumem,menu_ps,buton,rotE,beep_l,beep_f,PWM_test,temp_preset,low_temp_preset,time_hot_preset,sound_preset,light_preset; int IntVolt,IntCur,IntBtemp,IntTtemp,temp_reference,st_by_timer,info; int count_m,j,k,l,byte,a,c,x,y,i,n,ni,m; int time_learn,time_do; float btemp_val_c,ttemp_val_c,volt_val_c,cur_val_c,volt_val,cur_val,btemp_val,ttemp_val,ttemp_val_disp,d_power; float x_bar,y_bar,sum_prods,sum_diffsquarex,sum_diffsquarey,pearson_r,sy,sx,b_coef,a_coef,estimated_time; float convert_volt(float); float convert_cur(float); float convert_btemp(float); float convert_ttemp(float); float bucla_div_mod(float); void ADC_sampling(int); void ADC_convert(int); void ADC_average(int); void ADC_div_mod(int); void move_cursor_xy(int,int); void beep_lf(int,int); void display_char(unsigned char); void write_flash_data(int); void read_flash_data(int); void delay_time(int); void delay_long(int); void delay_extra_long(int); void cls(int); void draw_Logo(int); void draw_info_screen(int); void draw_main_menu_screen(int); void draw_solder_screen(int); void draw_time_hot_screen(int); void draw_sound_screen(int); void draw_light_screen(int); void draw_default(int); void draw_low_temp_screen(int); void draw_hi_temp_screen(int); void draw_sub_solder(int); void draw_sub_solder_mm(int); void draw_sub_solder_ret(int); void draw_preheat_message(int); void init_scr(int); void start_condition(int); void stop_condition(int); void display_char(unsigned char); void dispbig_char(unsigned char); void large_number_print(unsigned char); void number_print(unsigned char); void ack_bit(int); int calculate_regression(float); int store_time(int); int AI_preheat(int); int byte_transmit(int); int byte_expandH(int); int byte_expandH(int); int debouncing_la_actionare_rotire(int); int debouncing_la_revenire_rotire(int); int debouncing_but(int); void main(void){ WDTCTL = WDTPW + WDTHOLD; // disable watch dog timer DCOCTL = CALDCO_16MHZ; // set internal oscillator at 16MHz BCSCTL1 = CALBC1_16MHZ; // set internal oscillator at 16MHz P1OUT = Clear; P2OUT = 0xFF; P3OUT = Clear; P1DIR = 0x83; // 1000 0011 P2DIR = 0xFF; // 1111 1111 P3DIR = 0xF8; // 1111 1000 delay_time(5000); //--------------------config ADC ADC10CTL1 |= INCH_2; //continuous sample mode, CH2 // CONSEQ1 + INCH_2 ADC10CTL0 |= ADC10SHT_2 + ADC10ON + MSC; //sample and hold time, adc on, cont. sample ADC10AE0 |= 0x04; // select channel A2 ADC10CTL0 |= ADC10SC + ENC; // start conversions read_flash_data(0); err = 0; menu = 1; //--------------------config PWM P3SEL |= (BIT3); // P3.3 Select as TA1 output TA1CCR0 = 5000; TA1CCR2 = (50 * light_preset); TA1CCTL2 |= OUTMOD_7; //toggle TA1CTL |= TASSEL_2 + MC_1 +ID_3; //smclk div/8 upmode. init_scr(0); cls(0); draw_Logo(0); beep_lf(100,1000); beep_lf(100,1200); beep_lf(100,1500); beep_lf(100,1800); for(n=0;n<6;n++){ ADC_sampling(0); ADC_convert(0); ADC_average(0); } ADC_div_mod(0); for(;;) { do{ //============================================================ select menu loop ================ if (menu == 0){ draw_main_menu_screen(0); } if (menu == 1){ draw_solder_screen(0); } if (menu == 2){ draw_hi_temp_screen(0); } if (menu == 3){ draw_low_temp_screen(0); } if (menu == 4){ draw_time_hot_screen(0); } if (menu == 5){ draw_sound_screen(0); } if (menu == 6){ draw_light_screen(0); } if (menu == 7){ draw_info_screen(0); } if (menu == 8){ draw_default(0); } rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (menu < 8)){ menu++; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (menu > 1)){ menu--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ); //========================================== select menu loop END ================ buton = debouncing_but(buton); menumem = menu; if(menu == 1){ //=========================================== Solder menu 1 ========================= for(ni=0;ni<20;ni++){ // pre test temp ADC_sampling(0); ADC_convert(0); ADC_average(0); } draw_sub_solder(0); m = temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(25,0); //---display target shortly large_number_print(array_div_mod[0]); large_number_print(array_div_mod[1]); large_number_print(array_div_mod[2]); st_by_timer = 80*time_hot_preset; match = 0; AI_preheat(0); do{ if(PWM_test == 0){ PWM_test = 1; n = 36; //30 } else{ PWM_test = 0; n = 12; //10 } //------------------------------------------ temp regulating loop do{ ADC_sampling(0); ADC_convert(0); ADC_average(0); //------------------------------------------------check for errors if((cur_val < tip_ol_value)or(cur_val > tip_sc_value)){ err |= ERR_DT; beep_lf(100,100); delay_time(1000); } else{ err &= ~(ERR_DT); } if(volt_val > over_voltage_value){ err |= ERR_OV; beep_lf(100,100); delay_time(1000); } else{ err &= ~(ERR_OV); } if(ttemp_val > (tip_range_temp/10)){ err |= ERR_OL; beep_lf(100,100); delay_time(1000); } else{ err &= ~(ERR_OL); } if(btemp_val > th_shut_down){ err |= ERR_OT; beep_lf(100,100); delay_time(1000); } else{ err &= ~(ERR_OT); } //-------------------------------reset handle timer acording to moovement temp2 = P1IN; buton = (temp2 &= 0x40); // 0100 0000 mask if (buton == 0){ st_by_timer = 104*time_hot_preset; } if(st_by_timer > 1){ temp_reference = temp_preset; match_low = 0; st_by_timer--; } else{ temp_reference = low_temp_preset; match=0; } if((match == 1) or (match_low == 1)){ ttemp_val_disp = ((ttemp_val + (temp_reference/5)) / 3); //this average function makes the displayed value les flickery } else{ ttemp_val_disp = ttemp_val; } //---------------------------------- adjusting temp acording to feedback if((ttemp_val < (temp_reference/10))and(PWM_test == 1)){ P1OUT |= EN_heater; // Enable heater = 1 move_cursor_xy(0,0); number_print(0x0A); if ((match == 0) and (match_low == 0)){ time_learn++;} } else{ P1OUT &= ~(EN_heater); // Heater = 0 move_cursor_xy(0,0); dispbig_char(' '); } if((match == 0)and((ttemp_val*10) > (temp_preset+110))){ beep_lf(100,1800); // beep when reach temperature beep_lf(100,1500); beep_lf(100,1200); beep_lf(100,1000); match = 1; if((first_heat == 0)and(time_learn > 50)){ store_time(time_learn); } first_heat = 0; time_learn = 0; } if((match_low == 0)and((ttemp_val*10) < (low_temp_preset))){ match_low = 1; } n--; }while (n != 0); //-------------------------------End of temp regulating loop ADC_div_mod(0); //------------------------------------------------------ display values move_cursor_xy(25,0); large_number_print(tenthstt); large_number_print(unitstt); large_number_print(decimal1tt); if(err > 0){ move_cursor_xy(7,6); if(err == 1){ for(i=0;i<8;i++){ dispbig_char(err_plug[i]); } } if(err == 2){ for(i=0;i<8;i++){ dispbig_char(err_tip[i]); } } if(err == 4){ for(i=0;i<8;i++){ dispbig_char(err_over_heat[i]); } } if(err == 8){ for(i=0;i<8;i++){ dispbig_char(err_over_volt[i]); } } if((err == 3)or(err == 5)or(err == 6)or(err == 7)or(err > 8)){ move_cursor_xy(7,6); for(i=0;i<8;i++){ dispbig_char(errors_multiple[i]); } } } else{ move_cursor_xy(7,6); number_print(tenthsp); number_print(unitsp); dispbig_char('W'); dispbig_char(' '); number_print(tenthsbt); number_print(unitsbt); dispbig_char('*'); dispbig_char('C'); } //---------------------------------------------------------------------- submenu loop - temp2 = P3IN; buton = (temp2 &= 0x01); if (buton == 0){ P1OUT &= ~(EN_heater); // Heater = 0 move_cursor_xy(0,0); dispbig_char(' '); menu_ps = 1; draw_sub_solder_mm(0); beep_lf(100,1000); buton = debouncing_but(buton); do{ rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (menu_ps < 2)){ menu_ps++; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (menu_ps > 1)){ menu_ps--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); if (menu_ps == 1){ draw_sub_solder_mm(0); } if (menu_ps == 2){ draw_sub_solder_ret(0); } temp2 = P3IN; buton = (temp2 &= 0x01); }while(buton != 0); } if((menu_ps == 2)and(buton == 0)){ //----------------submenu Return buton = debouncing_but(buton); beep_lf(100,1000); menu = menumem; draw_sub_solder(0); } if((menu_ps == 1)and(buton == 0)){ //--------submenu Return to main menu buton = debouncing_but(buton); cls(0); beep_lf(100,1000); menu = 0; } }while ( menu == menumem ) ; } // ==================================================================== Solder menu 1 END ========== if(menu == 2){ //=============================================== Hi temp menu 2 ============= do{ m = temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(30,3); number_print(array_div_mod[0]); number_print(array_div_mod[1]); number_print(array_div_mod[2]); dispbig_char('*'); dispbig_char('C'); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (temp_preset < max_solder_temp)){ temp_preset = temp_preset+5; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (temp_preset > min_solder_temp)){ temp_preset = temp_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; write_flash_data(0); buton = debouncing_but(buton); cls(0); beep_lf(100,1000); } //=============================================== Hi temp menu 2 END ============= if(menu == 3){ //=============================================== Low temp menu 3 ============= do{ m = low_temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(30,3); number_print(array_div_mod[0]); number_print(array_div_mod[1]); number_print(array_div_mod[2]); dispbig_char('*'); dispbig_char('C'); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (low_temp_preset < max_sb_temp)){ low_temp_preset = low_temp_preset+5; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (low_temp_preset > min_sb_temp)){ low_temp_preset = low_temp_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; cls(0); beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== low temp menu 3 END ============= if(menu == 4){ //=============================================== Time hot menu 4 ============= do{ m = time_hot_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(30,3); number_print(array_div_mod[0]); number_print(array_div_mod[1]); number_print(array_div_mod[2]); dispbig_char('s'); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (time_hot_preset < max_time)){ time_hot_preset = time_hot_preset+5; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (time_hot_preset > min_time)){ time_hot_preset = time_hot_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; cls(0); beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Time hot menu 4 END ============= if(menu == 5){ //=============================================== Sound menu 5 ============= do{ m = sound_preset; bucla_div_mod(m); move_cursor_xy(40,3); number_print(array_div_mod[1]); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (sound_preset < 5)){ sound_preset++; } if((rotE == (2+(encoder_revert*2))) and (sound_preset > 0)){ sound_preset--; } beep_lf(100,1000); rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; cls(0); beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Sound menu 5 END ============= if(menu == 6){ //=============================================== Back light menu 6 ============= do{ m = light_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(30,3); number_print(array_div_mod[0]); number_print(array_div_mod[1]); number_print(array_div_mod[2]); dispbig_char(' '); dispbig_char('%'); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (light_preset < 100)){ light_preset = light_preset+5; } if((rotE == (2+(encoder_revert*2))) and (light_preset > 0)){ light_preset = light_preset-5; } TA1CCR2 = (50 * light_preset); beep_lf(100,1000); rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; cls(0); beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Back light menu 6 END ============= if(menu == 7){ //=============================================== Info menu 7 =============== info = 1; do{ if(info == 1){ m = firmware_version; bucla_div_mod(m); move_cursor_xy(7,3); dispbig_char(' '); dispbig_char('S'); dispbig_char('W'); dispbig_char('-'); dispbig_char('V'); number_print(array_div_mod[1]); dispbig_char('.'); number_print(array_div_mod[2]); } if(info == 2){ m = hardware_version; bucla_div_mod(m); move_cursor_xy(7,3); dispbig_char(' '); dispbig_char('H'); dispbig_char('W'); dispbig_char('-'); dispbig_char('V'); number_print(array_div_mod[1]); dispbig_char('.'); number_print(array_div_mod[2]); } if(info == 3){ move_cursor_xy(7,3); dispbig_char(' '); dispbig_char('U'); dispbig_char('='); number_print(tenthsv); number_print(unitsv); dispbig_char('.'); number_print(decimal1v); dispbig_char('V'); } if(info == 4){ move_cursor_xy(7,3); dispbig_char('P'); dispbig_char('C'); dispbig_char('B'); dispbig_char('='); number_print(tenthsbt); number_print(unitsbt); dispbig_char('*'); dispbig_char('C'); } if(info == 5){ move_cursor_xy(7,3); dispbig_char('T'); dispbig_char('i'); dispbig_char('p'); number_print(tenthstt); number_print(unitstt); number_print(decimal1tt); dispbig_char('*'); dispbig_char('C'); } rotE = debouncing_la_actionare_rotire(rotE); if((rotE == (4-(encoder_revert*2))) and (info < 5)){ info++; beep_lf(100,1000); } if((rotE == (2+(encoder_revert*2))) and (info > 1)){ info--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; cls(0); beep_lf(100,1000); buton = debouncing_but(buton); } //=============================================== Info menu 7 END ============= if(menu == 8){ //============================================== Default menu 8 ============= move_cursor_xy(14,3); for(i=8;i<16;i++){ dispbig_char(bck_ground_default[i]); } beep_lf(100,1000); delay_extra_long(0); cls(0); temp_preset = default_solder_temp; low_temp_preset = default_st_by_temp; time_hot_preset = default_time; sound_preset = default_sound; light_preset = default_light; for(ni=0;ni<10;ni++){ machine_learning_volt[ni] = default_learning_stack[ni + 10]; // default values machine_learning_time[ni] = default_learning_stack[ni]; // default values } write_flash_data(0); TA1CCR2 = (50 * light_preset); buton = debouncing_but(buton); } //=========================================== Default menu 8 END ============= } } //--------------------------------------------------------------------------------------------------------------------------------------- //----------------- FUNCTIONS ----------- PROCEDURES ----------- FUNCTIONS ----------- PROCEDURES ----------- FUNCTIONS ------- //--------------------------------------------------------------------------------------------------------------------------------------- void start_condition(int){ // -------------------------------------- I2C start condition --------- P2OUT &= ~(SDA); delay_time(10); P2OUT &= ~(SCL); delay_time(40); byte_transmit(SLAVE_ADDR); } void stop_condition(int){ // --------------------------------------- I2C stop condition --------- P2OUT |= SCL; delay_time(10); P2OUT |= SDA; delay_time(40); } void ack_bit(int){ // ------------------------------------------ ACK bit ---------------- P2DIR = 0xFE; // 1111 1110 P2OUT |= SCL; delay_time(10); P2OUT &= ~(SCL); P2DIR = 0xFF; } int byte_transmit(int t_byte){ // ------------------------Byte Transmit (transmit a single byte to I2C)-- for(l=0;l<8;l++){ byte = t_byte; if((byte &= mask[l]) > 0){ P2OUT |= SDA; } else{ P2OUT &= ~(SDA); } P2OUT |= SCL; delay_time(10); P2OUT &= ~(SCL); P2OUT &= ~(SDA); delay_time(10); } ack_bit(0); return (0); } int byte_expandH(int t_byte){ // ----------------------------- Byte expand Higher half ------- for(l=4;l<8;l++){ for(j=0;j<2;j++){ byte = t_byte; if((byte &= mask[l]) > 0){ P2OUT |= SDA; } else{ P2OUT &= ~(SDA); } P2OUT |= SCL; delay_time(10); P2OUT &= ~(SCL); P2OUT &= ~(SDA); delay_time(10); } } ack_bit(0); return (0); } int byte_expandL(int t_byte){ // ------------------------------- Byte expand Lower half ------- for(l=0;l<4;l++){ for(j=0;j<2;j++){ byte = t_byte; if((byte &= mask[l]) > 0){ P2OUT |= SDA; } else{ P2OUT &= ~(SDA); } P2OUT |= SCL; delay_time(10); P2OUT &= ~(SCL); P2OUT &= ~(SDA); delay_time(10); } } ack_bit(0); return (0); } void init_scr(int){ //-------------------------------------- Init Screen --------------------- start_condition(0); for(c=0;c<27;c++){ byte_transmit(Init[c]); } stop_condition(0); } void move_cursor_xy(int col, int row){ // ----------------------- Go to screen coordinates ------- int col_H, col_L; x = col; y = row; col_H = col; col_L = col; col_H = col_H >> 4; col_H &= ~(0xF0); col_L &= ~(0xF0); start_condition(0); byte_transmit(COMMAND_STR); byte_transmit(MEMORYMODE); byte_transmit(0x00); byte_transmit(0xB0 + row); byte_transmit(col_L); byte_transmit(col_H |= 0x10); stop_condition(0); } void cls(int){ //-------------------------------------- Clear Screen --------------------- start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(c=0;c<1024;c++){ byte_transmit(0x00); } stop_condition(0); } void display_char(unsigned char txt){ //------------------------ Display small font char ------------- start_condition(0); byte_transmit(DATA_STR); //Command for data stream byte_transmit(0x00); //blank column space for(c=0;c<5;c++){ byte_transmit(ascii_chart[(txt*5) + c]); } byte_transmit(0x00); //blank column space stop_condition(0); } void dispbig_char(unsigned char txt){ //---------------------------- Display large char ------------- start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=0;c<5;c++){ for(k=0;k<2;k++){ byte_expandH(ascii_chart[(txt*5) + c]); } } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); y++; move_cursor_xy(x,y); start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=0;c<5;c++){ for(k=0;k<2;k++){ byte_expandL(ascii_chart[(txt*5) + c]); } } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); x = x+14; y--; move_cursor_xy(x,y); } void number_print(unsigned char txt){ //-------------------- Display a two line number ------------- start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=0;c<10;c++){ byte_transmit(large_number_chart[(txt*20) + c]); } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); y++; move_cursor_xy(x,y); start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=10;c<20;c++){ byte_transmit(large_number_chart[(txt*20) + c]); } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); x = x+14; y = y-1; move_cursor_xy(x,y); } void large_number_print(unsigned char txt){ //-------------------- Display a large number ------------- for(half=0;half<2;half++){ start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=(10*half);c<(10*(half+1));c++){ for(k=0;k<2;k++){ byte_expandH(large_number_chart[(txt*20) + c]); } } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); y++; move_cursor_xy(x,y); start_condition(0); byte_transmit(DATA_STR); //Command for data stream for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } for(c=(10*half);c<(10*(half+1));c++){ for(k=0;k<2;k++){ byte_expandL(large_number_chart[(txt*20) + c]); } } for(k=0;k<2;k++){ byte_transmit(0x00); //blank column space } stop_condition(0); y++; move_cursor_xy(x,y); } x = x+24; y = y-4; move_cursor_xy(x,y); } void ADC_sampling(int){ //--------------------------------- Sample the ADC ports for values //-------------------------------------------------read board temp ADC10CTL1 &= ~(INCH_2); //disable continuous sample mode, CH2 ADC10CTL1 |= INCH_5; //continuous sample mode, CH5 ADC10AE0 |= 0x20; // select channel A5 //0010 0000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntBtemp = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read tip temp ADC10CTL1 &= ~(INCH_5); //disable continuous sample mode, CH5 ADC10CTL1 |= INCH_4; //continuous sample mode, CH4 ADC10AE0 |= 0x10; // select channel A4 //0001 0000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntTtemp = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read current ADC10CTL1 &= ~(INCH_4); //disable continuous sample mode, CH4 ADC10CTL1 |= INCH_3; //continuous sample mode, CH3 ADC10AE0 |= 0x08; // select channel A3 //0000 1000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntCur = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read voltage ADC10CTL1 &= ~(INCH_3); //disable continuous sample mode, CH3 ADC10CTL1 |= INCH_2; //continuous sample mode, CH2 ADC10AE0 |= 0x04; // select channel A2 //0000 0100 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntVolt = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions } void ADC_convert(int){ //---------------------------------- Convert the sampled values btemp_val_c = convert_btemp (IntBtemp); if(PWM_test == 0){ ttemp_val_c = convert_ttemp (IntTtemp); volt_val_c = convert_volt (IntVolt); } if((IntCur > 0x05)and(PWM_test == 1)){ cur_val_c = convert_cur (IntCur); } d_power = ((volt_val*cur_val*0.75) * (ttemp_val/43)); //d_power = cur_val; // replace the line above with this for //reading the current on the screen instead of power - for calibration } void ADC_average(int){ //----------------------------- Average last 5 samples for all measurements if (IntVolt > 0x00){ for(i=0; i<4; i++){ medv[i] = medv[i+1]; medc[i] = medc[i+1]; medbt[i] = medbt[i+1]; medtt[i] = medtt[i+1]; } medv[4] = volt_val_c; medc[4] = cur_val_c; medbt[4] = btemp_val_c; medtt[4] = ttemp_val_c; } volt_val = ((medv[0]+medv[1]+medv[2]+medv[3]+medv[4])/5); cur_val = ((medc[0]+medc[1]+medc[2]+medc[3]+medc[4])/5); btemp_val = ((medbt[0]+medbt[1]+medbt[2]+medbt[3]+medbt[4])/5); ttemp_val = ((medtt[0]+medtt[1]+medtt[2]+medtt[3]+medtt[4])/5); //ttemp_val_disp = ttemp_val; //((ttemp_val + (temp_reference/10)) / 2); //this average function makes the displayed value les flickery } void ADC_div_mod(int){ //------------------------------ Loop for div/mod voltage Values bucla_div_mod(volt_val); tenthsv = array_div_mod[0]; unitsv = array_div_mod[1]; decimal1v = array_div_mod[2]; //------------------------------ Loop for div/mod Power Values bucla_div_mod(d_power); tenthsp = array_div_mod[0]; unitsp = array_div_mod[1]; //----------------------------- Loop for div/mod Board temp Values bucla_div_mod(btemp_val); tenthsbt = array_div_mod[0]; unitsbt = array_div_mod[1]; //---------------------------- Loop for div/mod Tip temp values Values bucla_div_mod(ttemp_val_disp); tenthstt = array_div_mod[0]; unitstt = array_div_mod[1]; decimal1tt = array_div_mod[2]; } void delay_time (int delay){ //----------------------------------------- Delay--------------------- do delay--; while (delay != 0); } void delay_long (int){ //--------------------------------------- long Delay ------------------ int j; j = 200; do{ delay_time(5000); j--; }while (j != 0); } void delay_extra_long (int){ //------------------------------extra long Delay ------------------ count_m = 6; do{ delay_long(0); count_m --; }while(count_m !=0); } float convert_volt (float IntVolt){ // ------------------------Voltage conversion float voltage,ua2,raport_divizor,r2,r1; r1 = 10000; r2 = 1000; ua2 = (3.33/1024*IntVolt); raport_divizor = ((r1+r2)/r2); voltage = ((ua2*raport_divizor) + 0.4); //0.4 means diode dropout return (float)(voltage); } float convert_cur (float IntCur){ // ------------------------Current conversion float current,Usunt,factor_op_amp,r2_op,r1_op,rs; r1_op = 1000; r2_op = 10000; rs = 0.020; factor_op_amp = (1+(r2_op/r1_op)); Usunt = ((3.33/1024*IntCur)/factor_op_amp); current = ((Usunt/rs)-0.03); if (current < 0.1) { current = 0.01; } return (float)(current); } float convert_btemp (float IntBtemp){ // ------------------------Board temp conversion float temperature,Ua1,r1_tb,r2_tb,t2k,rdiv; rdiv = 10500; r1_tb = 9900; Ua1 = (3.3/1024*IntBtemp); r2_tb = (3.3*rdiv/Ua1-rdiv); //r2 = vcc*rdiv/uADCin -rdiv if (r2_tb == r1_tb ){ r2_tb++;} // prevents log(1) t2k= ( (298.16*3380)/log(r1_tb/r2_tb) ) / (3380/log(r1_tb/r2_tb)-298.16); //T2= T1*B/ln(R1/R2) / ( B/ln(R1/R2) - T1 ) in Kelvin temperature = t2k - 273.16 ; return (float)(temperature); } float convert_ttemp (float IntTtemp){ // ------------------------ Tip temp conversion float Ttemp,r1_opt,r2_opt,factor_op_temp,Ut_2; r1_opt = 500; r2_opt = 47000; factor_op_temp = (1+(r2_opt/r1_opt)); Ut_2 = ((3.33/1024)*IntTtemp); Ttemp = (((Ut_2/factor_op_temp)/0.000021)/10); // C Type Thermocouple has about 21uV/*C at 1000*C return (float)(Ttemp); } int debouncing_but (int){ //------------------------debouncing for sw release delay_time(500); do{ temp2 = P3IN; buton = (temp2 &= 0x01); }while (buton == 0); return(int)( buton ); } int debouncing_la_actionare_rotire(int rotE){ //------------debouncing for encoder rotation begin delay_time(500); do { temp2 = P3IN; rotE = (temp2 &= (BIT1 + BIT2)); temp2 = P3IN; buton = (temp2 &= 0x01); }while ((rotE == 6) and (buton != 0)); return (int)(rotE); } int debouncing_la_revenire_rotire(int rotE){ //-------debouncing for encoder rotation end delay_time(500); do { temp2 = P3IN; rotE = (temp2 &= (BIT1 + BIT2)); temp2 = P3IN; buton = (temp2 &= 0x01); }while ((rotE != 6) and (buton != 0)); return (int)(rotE); } int store_time(int){ // ----------- Store heating time at resective voltages for machine learning ----------- for(ni=0;ni<10;ni++){ machine_learning_time[ni] = machine_learning_time[ni+1]; machine_learning_volt[ni] = machine_learning_volt[ni+1]; } machine_learning_time[9] = time_learn; machine_learning_volt[9] = volt_val; // time_learn = 0x00; return(0); } int AI_preheat(int){ calculate_regression(volt_val); draw_preheat_message(0); // followed by the rule of three for calculating the //time according to delta *C time_do = ((estimated_time * (temp_preset - (ttemp_val*10))) / (temp_preset - low_temp_preset)); for (ni=0;ni 0){ ref_temp_val = ref_temp_val*10; } for(i=0; i<10; i++){ if ( ref_temp_val >= 10 ){ ref_temp_val = ref_temp_val - 10; array_div_mod[j] ++; } } } return (int)(array_div_mod); } void draw_Logo(int){ // -------------------- Logo intro------------- move_cursor_xy(20,2); for(i=0;i<9;i++){ display_char(bck_ground_logo1[i]); } move_cursor_xy(20,4); for(i=9;i<19;i++){ display_char(bck_ground_logo1[i]); } delay_extra_long(0); cls(0); move_cursor_xy(22,2); for(i=19;i<28;i++){ display_char(bck_ground_logo1[i]); } delay_extra_long(0); cls(0); } void draw_preheat_message(int){ // -----------------draw preheat message------------- move_cursor_xy(26,6); for(i=0;i<10;i++){ display_char(AI_preheat_txt[i]); } move_cursor_xy(0,0); number_print(0x0A); } void draw_main_menu_screen(int){ // --------------------------draw main menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_main[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_main[i]); } } void draw_solder_screen(int){ // -----------------draw the solder menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_solder[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_solder[i]); } } void draw_low_temp_screen(int){ // --------------draw stand by temperature adjust menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_low[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_hi_temp_screen(int){ // --------------draw stand by temperature adjust menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_up[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_time_hot_screen(int){ //-----------draw adjusting time before entering stand by menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_time[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_sound_screen(int){ // -------------------draw sound menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_sound[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_light_screen(int){ // ----------------draw back light menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_light[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_default(int){ // -----------------------draw default menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_default[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_info[i]); } } void draw_info_screen(int){ // ------------------draw info screen menu------------- move_cursor_xy(7,0); for(i=0;i<8;i++){ dispbig_char(bck_ground_info[i]); } move_cursor_xy(7,6); for(i=8;i<16;i++){ dispbig_char(bck_ground_up[i]); } } void draw_sub_solder(int){ // -------------------draw sub solder menu------------- cls(0); move_cursor_xy(12,2); for(i=0;i<8;i++){ dispbig_char(bck_ground_subsolder[i]); } } void draw_sub_solder_mm(int){ // ----------------------draw return to Main Menu------------- move_cursor_xy(7,6); for(i=0;i<8;i++){ dispbig_char(bck_ground_retmain[i]); } } void draw_sub_solder_ret(int){ // ---------------------draw return to sub solder------------- move_cursor_xy(7,6); for(i=0;i<8;i++){ dispbig_char(bck_ground_retsol[i]); } } void beep_lf(int beep_l,int beep_f){ // --------------------beep procedure------------- if (sound_preset > 0){ beep_l = (beep_l*sound_preset); beep_f = (beep_f/sound_preset); do{ P1OUT |= BIT7; // beeper = 1 delay_time(beep_f); P1OUT &= ~(BIT7); // beeper = 0 delay_time(beep_f); beep_l--; }while(beep_l != 0); } }