//rev445 //cc 07-07-2015 //fixed PID2 output table coasting register can not be read/write problem //fixed PID2 loop initial pid stage has wrong value when select different cool/heat stage //rev444 //cc 06-16-2015 //add co2 range register, if co2 value over the range for 5 minuts then show "OVERRANG" //add co2 self calibration function, if co2 value lower or higher than nature co2 value(400ppm), then set a offset base on lowest value and nature value //rev443 //cc 06-03-2015 fixed after firmware updated, old SN/PN/HW infomation do not copy to new position problem //rev442 06-02-2015 //ccadd new range for 0-20mA input //fixed input range can be set to used and 10K thermistor bug //rev441 05-28-2015 modify typedef struct temp, not use struct to define each array, use the typedef method //rev440 //cc 05-25-2015 modify reg120. use this to indicate rs485/zigbee mode //cc 05-25-2015 add setpoint unlimit function, before setpoint can not be negative value, use this function to disable setpoint limitation //rev439 //cc 04-03-2015 add type3 thermistor to all inputs range //cc 04-03-2015 add new range to analog inputs:occupied/unoccuped, unoccuped/occupied, close/open, open/close //cc 03-31-2015 fixed after setting to floating mode, other relays will be stuck problem: //1. need stop floating timer after change the mode //2. output_temp can not be bit operation by GetByteBit() or SetByteBit() routine, it's 16 bits variable. //rev438 //cc 03-24-2015 fixed bug: after change ID, tstat sometimes stuck in ISP mode //cc 03-17-2015 add average temperature options for AI1 to AI4 //cc 03-05-2015 modify transducer mode for analog output, add transducer range registers, max temperature and min temperature //rev437 //cc 03-04-2015 //---fixed multiple writes command, extend buffer to 16 bytes so can receive user dispaly data //---Add manual icons control registers: //Reg728: write 0: auto icon mode write 1: manual icon mode //Reg729:manual icon value: //0=not display 1=show //Bit0: spare //Bit1: cooling icon //Bit2: heating icon //Bit3: first fan icon //Bit4: second fan icon //Bit5: day icon //Bit6: night icon //Rev436 //cc 02-13-2015 modify CRC check routine to solve when receive braodcast command, sometimes not response on time. //rev435 //cc 01-19-2015 //---fixed when broadcast scan command, tstst will receive wrong command problem: // scan command dosen't do the CRC check in the serial interrupt, just set receive flag, then dealwith received data in main routine, if serial interrupt come before dealwith data routine, the buffer will be changed // this also has small chance in read/write command and will cause wrong operation //---add new register725 to show ID in a certain time //rev434 //cc 01-07-2015 get average temperature selection back //Rev433 //cc 12-27-2014 fixed when display co2/hum value, the heat/cool icon do not change problem : display_items() need to include StatusLeds() routine; //cc 12-26-2014 update firmware version to be different with REV432 test version //cc 12-22-2014 //modify temperature sensor selection, if co2 sensor is present, then use tmeperature of humdity sensor, because there is no internal sensor on tstat6-co2 board //Rev 432 //cc 12-19-2014 //modify hardware detect routine so can set the clock/hum/co2 manually, before may check them by wrong sometimes //delete communication detect task, this will affect the internal sensor calibration value(do not know why) //Rev431 //cc 11-11-2014 fixed PID only run once time error //cc 11-11-2014 modify when ID is not illegal, unlock the ID lock to allow change the ID. //cc 11-11-2014 fixed when power on, co2 manual mode variabe not intial error //REV430 //cc 11-06-2014 //modify setpoint display funtion to match different input. //rev429 //cc 11-05-2014 fixed co2 calibration function, when write calibration value, it should use "mul_analog_in_buffer[9]" not mul_analog_in_buffer[8] //cc 11-04-2014 modify init_PID_flag variable, each of pid loop now will be initialized by their own flag. //cc 11-01-2014 modify update_pid() routine, all pid loop use one calculation formula. //cc 10-30-2014 fixed when change temperature unit, the night setpoint and night cool/heat setpoint not change right issue.(reduce the local varible number, delete unit_temp varible) //rev428 //cc 10-22-2014 modify when it is in costing mode, pid value stuck in +/- 1 setpoint range //cc 10-16-2014 modify the setpoint routine, now it is not a .C file but be a library //cc 10-09-2014 fixed lookup table routine error, this will cause the temperature less than about 4 degree than before: index varible should be set to 18 //rev427 //cc 09-17-2014 //---modify rs485/wireless function, register120 after first writing operation, then lock it. //---delete the RS485/WIRELESS item from keypad menu //---add a limition to humidity and co2 value to avoid to show mess charactor in the display //rev426 //CC 09-02-2014 modify rs485 and wireless mode switch function, not use automatically detect method but use register120 and keypad to switch network mode. //cc 08-28-2014 when change address by keypad, if address locked, show "LOCK" on LCD, user need unlock by register639 then change the address. //kaiyinye add code for calibrate humidity sensor //rev42.5 //cc 06-26-2014 fixed show wrong sun ICONs problem when it is in night mode, the register629 which indicate occupancy sensor type, the default value is 255 which should be set to 0 if no occupancy present //cc 06-11-2014 fixed munal input function of internal sensor and AI1-AI8, add internal sensor manual register695 //06-10-2014 add humidity sensor calibration,use the registers from 2000 to 2030 //rev42.4 //cc 06-06-2014 modify lcd display more than 2 items, the items will screw too fast //cc 06-04-2014 fixed when set 1 stage only, it will no go into coasting stage problem (universal_pid[][] in pid.c is not initialized properly) //rev42.3 //cc 05-29-2014 fixed firmware version and addresss display bug when power up //cc 05-29-2014 modify customer table, so each input can use either cutomer table 1 or customer table2 at the same time //cc 05-05-2014 //modify pid initial flag after change the setpoint by keypad, so hat/cool states can change quickly //modify decimal point let it blinks fast //modify heat/cool mode register(101), when no heat or cool stage it will stay at costing //rev42.2 //cc 03-28-2014 fix serial number can be change problem //cc 03-27-2014 modify pir write function, do not clear the write command flag automatically but manually, this will make sure we have write the parameters sucessfully. //cc 03-26-2014 modify zigbee communication check routine, not use fixed time but check the mode every 2 seconds at beginning, if get right mode, then change the time to 60 seconds, this make the mode detect faster. //rev 42.1 //cc 03-05-2014 fixed clock function about week and day reverse error //cc 03-04-2014 modify read eeprom routine,when reading eeprom, if serial interrupt occur then re-read it again, this can reduce the serial timeout issue. //cc 02-20-2014 fixed PID2 Iterm issue: // when using customer table, it the value is big, it will make iterm summary increase very fast, so the Iterm will not work properly, add a limitation. //cc 01-26-2014 modify the PID int flag so after change the setpoint by keypad, the PID output will not change immediately //cc 01-26-2014 add RSSI and LQI registers //cc 01-19-2014 add wireless module watch dog period register and temperature alarm threshold register //cc 01-11-2014 modify wireless pire function and change occupied/unoccupied switch time. //rev420 //cc 12-04-2013 add wireless pir sensor function //cc 12-04-2013 modify keypad to fix fan up key will effect cool up key problem //cc 11-30-2013 block CLOCK function for wireless pir function, release RAM //cc 10-28-2013 modify output formula of analog output2 when no airflow sensor present //cc 10-25-2013 add VAV function //rev419 //cc 09-24-2013 modify checkcrc routine and checkdata routine, if crc check is wrong, not do the checkdata any more, so serial communication can be faster, note scan command has it's own CRC routine //cc 09-23-2013 change PID2 input items to 10 //cc 09-11-2013 add pir control routine to check schedule task. //TBD: add wireless pir sensor //rev418 //cc 09-03-2013 modify customer table for inputs, any input can be set to use customer sensor, but only two channels can be use at the same time. //cc 09-03-2013 modify pid2 selection, now can set any input as PID2 input //rev417 //cc 08-28-2013 MDF getIDNum() routine to solve bytemissing error //cc 08-27-2013 MDF communication check function, save the last config of communication //cc 08-22-2013 MDF RS485/wirless function, delete the rs485 config register, add two timers to detect which way is active //cc 08-16-2013 add ID write protect register to avoid change ID by wrong. //cc 08-16-2013 MDF temperature filter, avoid the first value showing too high. //cc 08-16-2013 fixed output manual problem when set output1 to manual other outputs will be affect //cc 08-08-2013 MDF display value routine, now AI1-AI8 can show negative value //rev416 //cc 08-01-2013 //fixed when changing system to auto mode, it not triggered occupied bug //REV 415 //cc 07-25-2013 fixed analog output bug: when set to 0-100% range, in cooling mode, the output voltage is not right.(formalar wrong since rev34.9) //REV 414 //cc 06-20-2013 modify output routine. all outputs use the same routine, include PWM, FLOATING mode. now any output can be floating and PWM mode. //cc 06-18-2013 change default serial communication way to RS485, not wireless //cc 06-18-2013 use new filter methoed for temperature, modify default value of temperature filter to 2. old way take too much RAM and sometimes it is crashed. //REV413 //cc 06-03-2013 modify humidity manual input function, now the manual input always can work, not depending on if there is a humidity sensor connected. //cc 05-30-2013 modify keypad adj function, now it'e confirm //cc modify humidity filter, now 0 means no filter //REV412 //cc 05-25-2013 disable PID1 pterm range limit when change it through modbus //cc 05-25-2013 add co2 manual input function and calibration function //cc 05-21-2013 add inputs filter factory default value to the default table //cc 05-20-2013 add seperated filter to each input and humidity and co2 input //cc 05-16-2013 fixed PID2 valve table //cc 05-16-2013 fixed humidity sensor calibration data address in eeprom //cc modify pic protocol to suit new humidity sensor (rev18 and up) //REV411 //cc 05-14-2013 add occ sensor and lingt sensor function //REV410 //cc 05-04-2013 modify internal sensor calibration, now reg121 and reg130 reg154 have the same function //rev409 //cc 04-08-2013 fixed scan command not response bug //rev408 //cc 03-04-2013 modify rotate display item, now can display humidity value in percent //cc 03-01-2013 add pid2 ON/OFF and valve off table //rev407 //cc 02-21-2013 modify lcd rotate display function, add co2 and humidity value items //cc 02-21-2013 fixed when display sequency error //rev406 //cc 02-04-2013 fixed relay5 pwm mode when system is in heating mode, change the varible define desire_time[2] to desire_time[3]. //cc 01-24-2013 add hum manual input enable and value registers //cc 01-24-2013 fixed heating/cooling icon bug. //---left key change to fan speed: auto-off-1-2-3 then recycle //---right key change to mode key: heating-cooling-auto and recycle //rev405 //cc 12-6-2012 //---add keypad clock menu items and function //---add keypad schedule menu items and function //change the day/night ICON display routine so can show them quickly. //---add clock and schedule menu items blink function //---change night setpoint and night heating/cooling deadband display format //rev404 //cc 11-22-2012 use varible instead of const key define, so can change key function in run time //cc 10-31-2012 add temperature sensor in hum board as external sensor, can switch internal sensor to this. //rev403 //cc 10-23-2012 change pic_relay() routine, now PIC chip will return relay state which it received, so can check if relay stata has been received properly. //cc 10-23-2012 fixed display item :night heating/cooling setpoint //cc 10-19-2012 change RH display limit when RH<0% or RH>100% when power up, 10 second later the limit will works. //rev 402 //cc 10-17-2012 add i2c_stop() routine to stop i2c communication properly in read_pic() routine. //rev 401 //cc 10-12-2012 //TBD: window interlock and window interlock setpoint //fixed after change setpoint through keypad, setpoint is chagned but cooling setpoint and heating setpoint are not changed //change day & night cooling/heating setpoint default value to two bytes //add new uniit conver routine, now after changing the unit(F to C) or (C to F), system not restart but change the all setpoint directly //get rid of hotel and office mode and re-write setpoint formula //change setpoint function: //A. no one setpoint and two setpoint mode any more. //B. when change setpoint, no matter day or night, setpoint, cooling/heating sp and cooling/heating deadband will move together. //C. when change cooling/heating sp, no matter which one, sp no change, according deadband will change. //move setpoint function to setpoint.c file, make it to lib. //fixed output table heating mode error(previous formular is not correct) //fixed night cooling/heating setpoint modbus display error //add schedule enable/disable function, so user can control occupied/unoccupied mode by manual //change user display function, now can set each item in the sequency //change night heating/cooling setpoint parameter display in menu mode //fixed clock register number shift issue //fixed deadmaster timer can not be write problem //add floating mode to relay1 and relay2 //relay1&2 relay4&5 work together, only one team can be chosen at the same time //Add input value limit when change input type to 10k thermistor //change register 121 and 130 display the same value of internal thermistor //added an additional confirmation byte to the protocol to solve relay wrong operation problem, also need compatible with previous version //REV 40.0 //change REV357 to REV40.0, to be different with 64K type chip SM5964, and this serie will start at 40.0 //REV357 //get NEW_COOLING_SETPOINT register back, so can change setpoint in 0.1 degree on occupied //office mode //cc 04-16-2012 add OUTPUT switch time jugement function, if time not set, than set to 0 //cc 04-12-2012 fixed occupied office mode heating setpoint //cc 04-12-2012 fixed fan off mode annalog output //fixed output delay time function //use perry's i2c code //fixed rotate display function, now can rotate display 12 items //fixed user information display function, user can set their owm name //change hum calibration points to two, not support three and up //change watchdog setting, sm59128 has very short watchdog time(MAX 262ms), so need change watchdog and delay function //add setwatchdog routine //combine two hex files to one,need BIN2HEX.EXE and HEX2BIN.EXE to project folder, change version need change Make.bat //rewrite humidity function,release RAM space //use perry's i2c code //REV35.6 arrange register list the same with tstat7 //get NEW_COOLING_SETPOINT register back, so can change setpoint in 0.1 degree on occupied //office mode //cc 04-16-2012 add OUTPUT switch time jugement function, if time not set, than set to 0 //cc 04-12-2012 fixed occupied office mode heating setpoint //cc 04-12-2012 fixed fan off mode annalog output //fixed output delay time function //use perry's i2c code //fixed rotate display function, now can rotate display 12 items //fixed user information display function, user can set their owm name //change multuple write registers function, max 16 bytes each time //REV35.5 charley 11-29-2011 //CC 01-16-2012 change hardware rev from 5 to 52 to flag the new keypads //CC 01-12-2012 initial hardware version to 5 to match haerdware, previous it was 12 as Tstat5E //CC 12-28-2011 fixed sop0, so can match tSTAT6 product model //12-27-2011 CC change keypad define for PCB Ver5 //CC merge modbus register list of Tstat6 and Tstat7 //REV 35.4 //CC add code to auto detect hardware such as hum,clock,etc, so do not need more hex files. //REV 35.3 //MHF 07-29-2011 Changed modbus register list,before port totally same as Tstat7,afer that add other new register Tstat7 do not have, //also changed some eprom chip storation position and add more bytes in E2 chip for analog input and output characters on LCD display //REV 35.2 //CC merge all t6 code to one, ver4 and upper //change hum rountine to relase ROM & RAM space //REV 35.1 //MHF 07-22-2011 Fixed scheduel,only change from unoccupied to occupied or reverse //at the edge when an event happen //REV 35.0 //MHF 07-15-2011 Use one riutine handle all digital outputs and analog output configure as DIGITAL //REV 34.9 //CHARLEY 07-06-2011 disable ALE for test of radio emissions //CHARLY 05-04-2011 add humidity function //REV 34.8 //MHF 03-16-2011 Add a new item called NETWORK on menu,to switch between RS485 and wireless //REV 34.7 Fixed bug for wireless,bit 7 of register 184 disable/enable RS485, // //REV 34.6 Redefine b.eeprom parameters to make the code easy to look through //REV 34.5 Redefine b.eeprom parameters to make the code easy to look through //REV 34.4 //MHF 01-17-2011 Use pwm control led to dim led //REV 34.3 //MHF 01-02-2011 add a bit to disable rs485 for wireless tstat //REV 34.2 //MHF 12-02-2010 Read multiple pic version when power up to avoid pic error display on LCD. //REV 34.1 //MHF 09-21-2010 Fixed a bug,the valve time be fixed 250 second,it is wrong,it should user adjustable //from 10 to 255 seconds.The defualt time has been changed to 90 seconds,before it was 25 seconds. //Improve floating valve code to separate it from the PID math and feed PID result to output table properly //Add feature to let us put the floating valve into manual mode by writing MAN to bit 310.7 and valve percent to register 285 //REV 34.0 //MHF 09-06-2010 Changed pins define for LED and knob button to match latest hardware rev4. //MHF 09-10-2010 Get rid of AI1,AI2 information from menu. //REV 33.9 //MHF 08-17-2010 Added LCD sleep feature for Tstat 5E,write 6 to register 203. //Fixed knob clockwise,make it more accurate,also changed schematic, will use external interrupt //capture pulse to improve accurate. //Fan icon will go OFF in off mode //REV 33.8 //MHF 06-21-2010 Add a flag make sure serial port communication //no pic communication //REV 33.7 //MHF 02-24-2010 Fixed filter arithmatic //REV 33.6 //MHF 01-21-2010 Sixth bit of info byte used for response delay,0 = right away respond,1 = 10ms delay //REV 33.5 //MHF 11-05-2009 Add one more screen shows parameters,ther eare two screens show parameters now and display rotatly. // Register 400 use for assign the first screen parameter,register 401 correspond to screen 2. // 0 = close current screen,1= temperature,2=setpoint,3= input1,4=input2 and so on. // the units for input 1 through 8 decided by the corresponding range setting.For now we support ON/FF // celsius,Fahrenheit,percentage. // Added register 402 for DAY icon control,403 for NIGHT icon control.0 = AUTO,1= OFF,2 = ON //REV 33.4 //MHF 08-18-2009 Add a register 14 for customer, store random data ,range is 0 through 255 //REV 33.3 //MHF 06-18-2009 Add PWM feature for 5E,borrow the code from 5D . //REV 33.2 //MHF 06-03-2009 5E has no digital input,so use analog input 3 instead of . //REV 33.1 //MHF 04-01-2009 Fix analog input1 range bug. //REV 33.0 //MHF 03-09-2009 Use register 188 ,189 store input 1 and 2 range information for compatible with Tstat 5c,d. //REV 32.9 //MHF 02-18-2009 Fixed LCD showing when power up.Now only shows VER XXX in first line and second line shows ADDR XXX. //REV 32.8 //MHF 01-12-2009 Add a register for LCD backlight turn off. //REV 32.7 //MHF 11-25-2008 Changed display as LCD //REV 32.6 //MHF 07-23-2007 Added default setpoint feature,added two register .One for default setpoint and another for setpoint control. //REV 32.5 //MHF 07-23-2007 Fixed interlock timer bug,The timer_flag should be set according to interlock set. //REV 32.4 //MHF 07-20-2007 Fixed the bug the relay with interlock will turn off after change the detpoint via serial port //REV 32.3 //MHF 07-18-2007 Fixed factory default ,now read data from flash when write 143 to register16. // Keep the c/f degree after write 143 to register 16,before fixed degree c. // Added a new keypad mode 6C for tstat with six buttons //REV 32.2 //MHF 07-04-2007 Fixed the temp flickering bug // Fixed the bug the tstat is unusable after loaded configuration file // Use gridpoint's output table as default output table after updated new firmware //REV 32.1 //MHF 07-03-2007 I Fixed the pid math in the attached hex file to resolve the flick bug. //REV 31.9 //MHF 06-13-2007 Fixed the initilization when HC mode is keypad. //REV 31.8 //MHF 06-12-2007 Fixed timer interlock //REV 31.7 //MHF 06-06-2007 Get rid of the limitation for cooling deadband and heating deadband. //REV 31.6 //MHF 05-24-2007 The tstat will take effect after the button be released // Fixed the bug the menu still on even do not operate it in 5 seconds // The hold LED will turn on you press the up and down temp button simultaneously 5 seconds. // Added a timer for interlock output.Please configure the following registers before you use this feature. //REV 31.5 //MHF 05-15-2007 Delay the button take effect after be pressed // Short the time enter or and exit HOLD mode // Make sure the HOLD mode take effect after the button be released //REV 31.4 //MHF 04-29-2007 Fixed issues about C/F converting //REV 31.3 //MHF 04-25-2007 Fixed the setpoint bug when change the C to F or back. // Keep the SOP and C/F same with configuration file when the users go to FAC at keypad. //REV 31.2 //MHF 04-10-2007 Keep the value of UTIL register when change C to F or back. //REV 31.1 //MHF 04-06-2007 Added a limitation to make sure the tstat not go to EMER mode when register 118 = 3. // Changed the e2 chip read routine and serial port communication routine for fixing the read error bug. //REV 31.0 //MHF 04-05-2007 Fixed e2 chip read routine //REV 30.9 //MHF 04-03-2007 Fixed nothing except version number,Checked a new version number will erase E2 chip. //REV 30.8 //MHF 03-29-2007 Fixed the two configuration files not match between before load and after loaded //REV 30.7 //MHF 03-28-2007 Fixed bug that registet 310 can not show the right value. // Fixed the bug the cool and heat mode can not switch if be changed from serail port. //REV 30.6 //MHF 03-26-2007 The SOP has only two values can be selected,1 and 3. // The register 321 and 322 can be write and read,before the wo register are read only. // Added a new register 326 for e2 chip type,0 = old and small e2 chip,1 = new and big e2 chip. //REV 30.4 //MHF 03-20-2007 Added two register for address limitation for gridpoint,Added sop == 3 item to use two config //REV 30.3 //MHF 03-19-2007 Fixed the C/F converter bug. //REV 30.2 //MHF 03-16-2007 Fixed the bugs about util can not read by serial port,hold can not exit from kepad //REV 30.1 //MHF 03-14-2007 Added FAC item in the gridpoint menu.deleted two register 321 and 322 used in util mode. // Added a register 323 for hold mode,write and read.Fixed a bug in mode transition. //REV 30.0 //MHF 03-14-2007 Added advanced menu for grispoint.added util mode and hold mode. //REV 29.9 //MHF 03-08-2007 Fixed the mode register 106 to show coasting when the mode be set OFF by using keypad //REV 29.8 //MHF 03-07-2007 Added two register 321 322 to show fan mode and work mode;fixed the LED to show the work mode // immediately when the user adjut the mode using button //REV 29.7 //MHF 03-06-2007 Fixed the right lower button use for decrease setpoint //REV 29.6 //MHF 03-05-2007 Fixed the write and read routine for e2 chip 24c08 //REV 29.5 //MHF 02-28-2007 Fixed the min and max address register address,fixed the button function,fixed the write and read routin for e2 chip 24c08 //REV 29.4 //MHF 02-01-2007 Fixed the pid arithmetic.The coasting is not as a stage number when caculte pid's switching point // just use cooling stage number plus heating stage number to caculte switching point. // Fixed the analog output state to corespond to the T3000.the analog output 0-100% = 2, // 50 - 100% = 3 ,100% = 1. //REV 29.3 //MHF 02-01-2007 Clear the MSB 4 bits of register 184; Fixed the formula caculating the cooling stage value //REV 29.2 //MHF 01-30-2007 Make sure the cooling deadband and heating deadband less than the cooling_pterm/2. //REV 29.1 //MHF 01-26-2007 Fixed the PI's algorithm //REV 29.0 //MHF 01-19-2007 Added a new range OFF/ON for each input.Fixed the part use DI1 for interlock // In auomode,the register 311 will show the state of DI1 //REV 28.9 //MHF 12-20-2006 In occupied mode,the tstat will go to unocuupied mode after the duration override timer time // if the occupancy sensor input changed.The tstat also go to unoccupied mode after the duration when power up and // the fan speed bigger than zero. //REV 28.8 //MHF 12-09-2006 Fixed the occupied bit make sure the bit can show the right status. //REV 28.7 //MHF 12-05-2006 Fixed occupency sensor mode.In office mode,the tstat will go to occupied mode when the input changing //MHF 11-30-2006 Changed the resolution of valve travel time from 0.1 second to 1 second. //MHF 11-30-2006 Added the averaging sensor feature. A new function setting for a temperature sensor input, it // can be assigned to average with the internal sensor and external sensor then feed back to the PID. //REV 28.6 //MHF 11-21-2006 Delay the tomeout for serila port receive and reset the watch dog when reply mutiple write // //MHF 11-21-2006 Added three functions for analog1,2 input,move the function in register 190 to register 300. // the register 190 only use for digital range.Expanded the digital input function in menu and the parameter // be stored into register 300. //REV 28.5 //MHF 11-07-2006 added a 10 second delay when the mode of operation is decreased //REV 28.4 //MHF 10-26-2006 Initilize the pidoutput array to determine the digital output controlled by which output table. //REV 28.3 //MHF 10-25-2006 Fixed PID2 bug.Can not get the right pid to control the output when the user select min and max funtion in pid control //MHF 09-30-2006 Adjust the involatile data structure because the data has extended the size of E2 chip //REV 28.2 //MHF 09-26-2006 Fixed the pid bug .The Pid will get wrong value as temperature nearby setpoint if set the cool statge equals to zero //REV 28.1 //MHF 09-15-2006 Fixed the code of PID2 part.the PID2 also can work if the range of corresponding inputs is 10K thermistor . // Before the PID2 work only when the range of inputs is customer sensor. //rev28.1 Added sendZero() routine to reduce code space, used by several routines. //REV 28.0 //MHF 08-23-2006 Added register 317 to store the value which determine how long time the Tstat will go occupied mode // after power on and see no serial communication.The value range of the registeris 0 to 255 and the units is minute. // If 0 is assigne din the register means that disable dead mater feature. //MHF 08-28-2006 Added register 318 for rounding display.There are three possible settings. 0 means round off the display to the neares digit. // 1 means round to the nearest 1/10 unit, this is the default;5 means round to the nearest 1/2 unit. //MHF 08-29-2006 Fixed keypad press counter feature.Counting up the value of register 294 from 1 instead of from 0 after any combination of // keys is pressed twice. // //REV 27.9 //MHF 6-25-2006 Added config tool feature.The tstat will transfer the configuration itself to another tstat by pressing // the lower right button.we realized this feature by a define predefine comamnd.So if the user need this // feature ,they have to tell us before we programm tstat. //MHF 7-12-2006 Fixed the keypad 2A mode.Before the user hit the button only one time the tstat will from unoccuipied mode // to occupied mode. And the fan speed also from OFF to AUTO.Later we fixed that,from unoccupied mode to // occpied mode,the user can ajust the fan speed but not just fixed AUTO mode.But this conflict with keypad mode // 2A,because 2A mode can not change the fan speed.So now at 2A mode.From unocucpied mode to occupied mode,the // fan speed is fixed AUTO.At others keypad mode,from unoccupied mode to occupied mode ,the user can changre the // fan speed. //MHF 07-24-2006 Added five register to operate relays when the corresond relay is set to manu mode. // 1,open the relay;0,close the relay. //MHF 07-26-2006 Added a register 15 to select the base address.0,Protocol Address.1,PLC Address //MHF 08-17-2006 Fixed a bug that the Tstat can not go to Cooling stage3 in some cases. //REV 27.8 //MHF 7-12-2006 Fixed the occupancy sensor feature for ShragaThere are two modes about using the feature. // one mode is in office mode and another mode is in hotel mode.Now we have only way to change the // tstat go to occupied mode ,that is write 1 to register 184.Before the tstat go to occupied mode ifthe user // change the fan speed from 0 to a value bigger than 0.Now we change the fan speed whatever mfrom keypad or // serial port,tstat will reset the override timer. //REV 27.7 //MHF 4-27-2006 Added a function item for each input.the function include "normal","freeze protect","occupancy sensor" //MHF 4-27-2006 Added auto/manu control bit for each input and output //REV 27.6 //MHF 3-27-2006 Added freeze protect feature //MHF 3-27-2006 Added timer ON feature,The corespond relay will turn on several minutes after TSTAT run some time //REV27.5 //MHF 03-01-2006 Changed the value range of filter .The filter can be set from 0 to 100. //RL:06-02-16 update documents for hotel/office deadband. document information were flipped. Office is setpoint. Hotel is Deadband //REV27.4 //RL:06-02-09 added LED table option Stage_1-2-3 and Stage_2-3 //MHF: 06-02-14 added fan speed change for Kevin in keypad 2B settings //REV27.3 //MHF:06-01-20 Fixed trigger override timer mode ,any key be pressed the Tstat enter override timer mode //REV27.2 //MHF:06-01-20 Fixed the tempetature display mode on LEDs //REV27.1 //MHF:06-01-20 Clear item zero when the temperature in deadband area //REV27-0 //RL:06-01-05 removed EA=0 lines from the pic read function. reduced flicker to the display // note that pic was left unchanged. May be possible that there are less pic reads // in the future may observe pic reads not as fast... //RL:06-01-06 placed back the code which now only enables writing to hardware-rev and Product-Model only once //REV26.9 //MHF:12-26-05 Fixed pid algorithm.change the pid_error arithmetic when at coating // mode to make iterm decrease and increase fast //MHF:12-27-05 Fixed the protocol of scan.Now read and write register 10 not Modbus protocol. // Because added serialnumber data in the data packet //MHF:12-29-05 Fixed occupied_trigger_handler() and related to make bit3 ofregister 184 can show // Digital input1 status at any time and any case //REV26.8 //MHF:11-14-05 fixed pid bug .expanded pterm greater than night_cooling_db + night_heating_db //ron:11-14-05 added flash_info function at code 0x100 //MHF:11-24-05 Added a register for last key pressed timer //MHF:12-15-05 Added serialnumber data when reply modbus function 25 //REV26.7 //MHF 10/25/05 Fixed the value range of 107 MODBUS_MODE_OPERATION register for compatible backward.Now use the following value: // coasting 0 cooling1 1 cooling2 2 cooling3 3 cooling4 14 cooling5 15 cooling6 16 // coasting 0 heating1 4 heating2 5 heating3 6 heating4 17 heating5 18 heating6 19 //MHF:10/28/05 Fixed pid bug ,the PID was winding up past 100, taking too long to wind down. // Also in the deadband region, made sure the I term can decay but will not incease. //MHF:10/28/05 Added 0---50% item for output table to determin how much the valve open.now the EEP_VALVE_OPER_TABLE_BEGIN register every bit is defined like this: // 7 : '0' heating valve(output7)not select 0---50% ; '1' heating valve(output7)select 0-----50% // 6 : '0' cooling valve(output6)not select 0---50% ; '1' cooling valve(output6)select 0-----50% // 5 4 : floating valve ,the range of valve open // 3 2 : heating valve(output7), the range of valve open // 1 0 : cooling valve(output6),the range of valve open //MHF:10/31/05 After a load of the configuration file or new hex file of the same rev number, the occupied state is left unchanged. // (if the hex file is a major update requiring the flash to be erased, // then the occupied stat is lost after a hex file s sent. ) // changed file :serial.c // fixed some code when POM == 1, in this mode,only when fan_speed_usee ==0 do something // changed file :tstat.c //MHF:11-07-05 when tstat at unoccupied status ,recaculate cooling_db and heating_db to make PID work correctly // changed setpoint() and update_pid() function //MHF:11-09-05 Fixed calibration bug which if TSS = 0,could not calibrate //MHF:11-10-05 Fixed LED status,turn all leds off except OFF led when the tstat working in the OFF mode, the left vertical row of status leds. //MHF:11-11-05 Fixed occupied status in REG184,if the fan speed goes greater than 0 from the keypad, then the occupied bit goes to 1 (TRUE) // if Fan speed goes to zero from the keypad, the occupied bit is 0 (False). // at night, if the fan goes on to maintain the night setpoint, // then the occupied bit stays at 0. // //MHF:11-11-05 limit TSS less than 2 if the tstat is 5A or 5B ,because the tstat 5A and 5B only have // temperature chip and external thermostor //REV26.6 //MHF 9/23/05 Add DDC mode in AUTO_ONLY regiser to make the user can not change setpoint and ON/OFF mode from keypad. // The user only can change these things from serial port. //MHF 9/23/05 Add interlock for each output.Add seven registers 285 to 293 to store the interlock, connected to inputs only (for now). //MHF 9/27/05 Added a new register to adjust the setpoint increment as a user variable. We store it as a user defined variable // in a one byte register, minimum value is 0.1, the maximum value could be set at 1.0.Now cooling setpoitn and // heatinng setpoint are stored in the E2 chip by using two bytes.Whatever the setpoint be set by keypad or serial port // the setpoint value should multiply 10. //MHF 9/28/05 Tss register is left unchanged when the user changes C to F or F to C. //MHF 9/28/05 Added a new item DEF which store current configuration into flash as new default in the menu //MHF 10/5/05 Tstat displays "---" when the tstat can not detect the pic chip though there is a pic chip //MHF:10/24/05 if the tstat is working on OFF mode,turn off cool and heat LED, lower row of status leds. //REV26.5 //MHF 9/6/05 shorten the delay between chatacters when tstat response .the tstat response should have a pause between two characrers, // but the maximum allowed pause is 1.5 character times or .83 ms * 1.5 or 1.245 ms at 9600 baud. //MHF 9/21/05 The baudrate does not change after changed C to F or back. //MHF 9/22/05 Fixed bug in TSS register.Because the TSS can not be set to zero even that the tstat has internal teperature // sensor when update the tstat's software from before revision 26.4 to after revision 26.4 . //REV26.4 //MHF 8/18/05 Added "floating valve" feature.Added five registers from 280 to 284 to determine relay1 to relay5 output mode. // Relay 4 and relay5 be used to control valve by pulse mode if MODE_OUTPUT4 AND MODE_OUTPUT5 be set '1'. // in this mode,the relays not be controled by PWM. //REV26.3 //MHF 8/18/05 fixed the original PID's Pterm = cooling_db+heating_db+10 to avoid always staying coasting mode // because of the user set the Pterm less than cooling_db plus heating_db //REV26.2 //MHF 7/12/05 Added PWM to pin ENABLE_2003, for decrease the current by using pulse control relays. // TODO allow writes to registers 180, 181, 215, 216 - automatically adjust calibration values when writing to these registers. //REV26.1 // MDF 6/23/05 Fixed bug in EEP location of UPDATE_STATUS register.. // tstat.c, serial.c, define.h // MDF 6/30/05 Got rid of LED_Init_table and function. LED defaults now stored same as the rest of the b.eeprom registers. // tstat.c, serial.c, define.h // MDF 6/30/05 Set Flash-stored address to 0 whenever writing to EEPROM-stored address. This invalidates the address stored in Flash. // tstat.c, serial1.c // MDF 6/30/05 Reset factory defaults to 0 at startup. // tstat.c // MDF 6/30/05 Added a prevention measure so that 0 or 255 cannot be written to the address. // serial.c // tbd... ask ron about the address initialisation... i wanna add some code but doesn't seem to work out... //REV25.7 // MDF 4/30/05 Added MODBUS_OVERRIDE_TIMER_LEFT to hold the remaining value on the override timer. // serial1.c // MDF 4/30/05 Implemented display blank option by setting MODBUS_DISPLAY = 2. // display.c // MDF 5/01/05 Created calibration terms for both the Analog In2 and for the Internal Thermistor . // modbus.h, define.h, tstat.c, serial1.c, output.c // MDF 5/01/05 Created registers to show the internal temperature sensor IC and the internal thermistor value at all times. // modbus.h, define.h, serial1.c, // MDF 5/01/05 Combined CAL and CAE into one menu item, making it automatically adjust the correct calibration term based on the TSS.. // LibDisplay.h, tstat.c // MDF 5/19/05 Fixed bug. 5Bs were not reading the temperature chip because they do not have analog inputs.. // output.c // MDF 5/24/05 Fixed bug in filtering algorithm.. // output.c, temperature.c // MHF 5/25/05 Added partial menu lock.. // tstat.c // MDF 5/30/05 Fixed bug in calibration implementation regarding degrees F. // tstat.c, serial1.c // MDF 6/3/05 Set Flash-stored address to 0 whenever writing to EEPROM-stored address. This invalidates the address stored in Flash. // output.c, temperature.c //REV25.6 // MDF 4/19/05 Adjusted HC setting so that when the external sensor is hotter, we are in heating mode, not cooling mode.. // control_logic.c // MDF 4/20/05 Rearraged location of many RAM variables to free up space in the data memory. // control_logic.c // MDF 4/20/05 Gave serial interrupt priority to reduce communication errors // tstat.c // MDF 4/25/05 Added a prevention measure so that 0 or 255 cannot be written to the address. // serial.c // MDF 4/28/05 Reset factory defaults to 0 at startup. // tstat.c // MDF 4/28/05 Fixed factory defaults bug when setting defaults from keypad. // tstat.c //REV25.5 // MDF 4/05/05 Made TEMPERATURE FILTER a variable rather than a constant. Set up new menu item, FIL, to control this variable. // serial1.c, tstat.c, LibDisplay.h, Temco.h, define.h, temperature.c // MDF 4/07/05 Added support for the Tstat5B2 // tstat.c // MDF 4/08/05 Change plug_n_play address to register 10. // modbus.h // MDF 4/14/05 Fixed bug that caused the iterm to rollover from a positive to a negative number. // PID.c // MDF 4/14/05 Adjusted filter so that the temperature does not jump when the new reading is very different. // temperature.c // REV25.4 // RL 03/25/05 update_status missing in the ISP update routine in Ver25.3 // update_status variable was missing when writting through modbus, therefore no update was possible given Tstat did not reset // MDF 4/01/05 Fixed bug in check hardware and model regarding 5A with rev0 hardware // tstat.c, // MDF 4/01/05 Made change to auto_plug_and_play check_data() routine. Now tstat will not respond if randval != 1; // serial1.c, //REV25.2 // MDF 1/27/05 Fixed bug in PID. // pid.c, // MDF 1/28/05 Fixed bug that prevented tstat from jumping into ISP mode.. // serial.c, // MDF 3/23/05 Changed PID so that iterm will continue to influence the tstat even when the temperature is between the deadbands // pid.c, //REV25.1 // MDF 12/30/04 Changed the function of occupied/unoccupied. It no longer has a correlation to fan speed. The mode can // only be changed by the digital input or by a command from the modbus. // tstat.c, keypad.c, serial.c // MDF 1/6/05 If there is an E2 error, the tstat no longer freezes. instead it simply does not start up any of the timers. // the serial communications will still work. This is to allow you to adjust the // product model and hardware rev registers // tstat.c // MDF 1/11/05 Added 2 more button configurations - 2b and 4b. 2b is the same as 2, except cooling and heating mode // can only be controlled via the serial interface. In 4b, the lower left button switches between cooling // and heating mode, while the lower right button scrolls through the fan speeds - off, 1, 2, 3, auto. // tstat.c, serial.c, control_logic.c, temco.h // MDF 1/14/05 Implemented blinking display whenever setpoint or fan speed is changed via the serial interface. // serial.c, //REV25.0 // MDF 7/14/04 Added display_integer() to show integers better in the menu // tstat.c // MDF 8/2/04 analog input is now raw the look_up_table now gets applied when checking temperature // output.c, pic.c // MDF 8/4/04 Added code to display setpoint instead of temperature according to menu item, dIS // temperature.c, temperature.h, define.h, modbus.h, serial1.c // MDF 8/4/02 added code to check for an analog module on Tstat5C boards // tstat.c // MDF 8/5/04 Added code to allow tstat5c to do analog out functions // output.c // MDF 8/5/04 Changed extern_operation_default table so that OUT4 and OUT5 correspond to table. // Temco.h, Output.c // MDF 8/5/04 Added code so that an Analog Tstat can fuction as ON/OFF // output.c // MDF 8/16/04 Added code to automatically switch between displays depending on the // hardware revision. // tstat.c, libdisplay.h // MDF 8/17/04 Setup PRODUCT_MODEL and HARDWARE_REV registers to keep track of // the hardware and model. // tstat.c, Temco.h, revision.h, serial1.c, define.h // MDF 8/18/04 changed default sop1 table for Fan OFF to match AUTO // now that we have the occupied/unoccupied settings working correctly // control_logic.h // MDF 9/16/04 Changed the default valve setting table for Heating2 and Cooling2. // control_logic,h // MDF 9/21/04 Added short cycle and changeover delays for the mode of operation. // control_logic.c, tstat.c // MDF 9/21/04 Increased max temperature and setpoint to allow tstat to function with boilers. // if the temperature/setpoint goes over 100, the decimal point gets shift in order to display properly. // tstat.c, define.h, temperature.c // MDF 10/20/04 Added 15ms delay anytime a relay switches to avoid reading or writing to the EEPROM during a switch. // output.c // MDF 10/20/04 Setup system of registers to control the functionality of the LEDs // modbus.h, serial1.c, tstat.c // MDF 10/24/04 Setup bit1 of info_byte to reflect a watchdog reset. SRS will be displayed on power-up // tstat.c // MDF 10/24/04 Setup bit2 of info_byte to prevent reset during serial writes. // serial.c // MDF 10/12/04 Added code to control zero-voltage crossing based on External Interrupt 1 // output.c, tstat.c // MDF 10/12/04 Added Low voltage test to prevent writing to the E2 chip if the voltage gets too low // tstat.c, TH_ee.c // RL 18/11/04 // - added memory storage when doing ISP. NOw only has laddress in it. If more data... need to do memory allocation // MDF 12/01/04 added a 2nd query of PIC on startup incase first one was missed. // pic.c // MDF 12/01/04 Changed routines of PIC slightly to fix small bugs in I2C communication. // pic.c // MDF 12/06/04 Added feature to tSS and DI1 to allow for 2-pipe operation. // Temco.h, control_logic.c // MDF 12/06/04 Added Ort - OVERRIDE_TIMER to allow user to override the unoccupied mode of the clock // Temco.h, define.h, LibDisplay.h, tstat.c // MDF 12/07/04 Fixed bug with changing the address from the keypad menu // tstat.c // MDF 12/08/04 Changed units of output delays from 0.1 seconds to 1.0 seconds // tstat.c, output.c // MDF 12/08/04 Modified the update_status register to allow for a complete erase of the eeprom by writing 0x8F // tstat.c, serial.c // MDF 12/10/04 Users now allowed to write to the COOL_HEAT_MODE register if tstat is in 6-button mode. // serial.c // MDF 12/14/04 Fixed eeprom erase function triggered by writing to register 16.. // tstat.c // MDF 12/14/04 Fixed serial write to AUTO_ONLY. // serial.c //REV24.4 // MDF 6/29/04 Added code to switch between occupied and unoccupied mode // upon trigger of digital input // tstat.c, Temco.h // MDF 6/30/04 Added menu items, night heating setpoint, night cooling setpoint. // tstat.c, define.h, temco.h, LibDisplay.h, modbus.h // MDF 7/1/04 Added response_data() before reset on certain serial com items so that tstat replies // before resetting. // serial1.c // MDF 7/5/04 Moved the addition of the calibration term to after the temperature filtering. // temperature.c // MDF 7/5/04 Changed code so that AUT=0 allows manual fan speeds. AUT=1 only allows off and auto // tstat.c, serial1.c //REV24.3 // MDF 6/21/04 TXEN pin needs to be set low immediately. This will prevent interference // on the 485 bus in case of E2 failure // tstat.c // MDF 6/24/04 Now make sure that the fan does not increase above the allowed level set by FAN_MODE // control_logic.c, Temco.h, tstat.c // MDF 6/25/04 changed the timing of responses to valid and invalid packets. // 4ms needed to recover from invalid packet. 10ms delay when responding to a valid packet. // serial1.c, tstat.c, serial.h //REV24.2 // MDF 6/1/04 Increased the EVENT_QUEUE_SIZE from 3 to 6 // define.h // MDF 6/1/04 Changed display of nHS and nCS parameter to nHd and nCd // tstat.c // MDF 6/7/04 Added REVT define to specify for various differences in the new tstat // define.h, Temco.h // MDF 6/7/04 Added EXTERNAL_SENSOR_1 // define.h, modbus.h, serial1.c //REV24.1 // MDF 5/3/04 Changed LED_r to look better when displayed. // LibDisplay.h // MDF 5/7/04 Added register 180 - EXTERNAL_SENSOR_0 register. now // it is possible to always read the external sensor reading regardless of TEMP_SELECT. // modbus.h, define.h, serial.c, output.c // MDF 5/31/04 - Changed default night heating and cooling setbacks from 3 to 10 // temco.h // 4/5/04-Rev.24 Added code to initialize_eeprom() to set the address to 1 as a default. // MF 4/13/04 when an on/off module is detected, MUX pins will also be used to drive relay4 and relay5 // MDF 4/29/04 re-wrote modbus routines to comply with modbus standards and to reduce error rate // serial1.c, tstat.c - COMDEALWITH