FOR Tstat5 LCD type //rev 38.1 //cc 02-11-2014 fixed in manual mode, on power on stage, relay5 does not work properly bug : RELAY_1TO5 = 0xff //cc 12-05-2013 add ID auto lock/unlock function //38.0 //cc 11-18-2013 fixed digital manual input function //37.9 //cc 10-28-2013 modify output formula of analog output2 when no airflow sensor present //cc 10-28-2013 modify responseData() routine to reduce ROM //37.8 //cc 10-21-2013 add PID3 input select function, AI1 to AI8 can be PID3 input //cc 10-21-2013 add PID3 off table //37.7 //cc 10-18-2013 add no airflow sensor function //cc 10-11-2013 add pid3 to control airflow //cc 10-09-2013 add dual max vav reheat function //37.6 for SANJAY(PM5E SIGEMA) //cc 09-26-2013 fixed after change to auto mode it back to manual mode problem //cc 09-26-2013 fixed heat hysterisis display error //cc 09-26-2013 fixed when hysterisis saving problem //37.6 //cc 09-22-2013 modify registers list so can be compatible with Tstat_AP product. //cc 09-22-2013 change serial number write method, after firmware flash/update, the serianl number can not be written //37.5 //cc 09-05-2013 fixed register lock function //cc 09-04-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-04-2013 modify pid2 selection, now can set any input as PID2 input //37.4 //cc 08-30-2013 when receive broadcast write command, not response, reduce write error. //cc 08-20-2013 //fixed when changing system to auto mode, it not triggered occupied bug //cc 08-20-2013 add ID write protect register to avoid change ID by wrong. //37.3 for SANJAY //cc 08-05-2013 fixed heating problem //37.2 for SANJAY //cc 07-02-2013 creat new branch for Sanjay project //cc add new menu system //modify default output table //modify default sequence //37.2 //cc 06-08-2013 add new keypad type -4C, fan down key modify to adjust out1 output table (on-off-cycle) on costing mode //and fan up key modify to adjust fan speed (off-heat-cool-gas-auto) //37.1 //cc fixed when input1 is selected as PID2 input, the value not give to analog_input[0] . //cc fixed bug that when update multiple units, ID and product model will be changed. //cc 06-04-2013 modify system sequency, add additional options sequency-2,sequency-3,sequency-4, use sequency-2 as default option and keep old factory default as sequency-1 //37.0 //cc 05-31-2013 remove test_pin, it will cause red LED flashing //cc 05-31-2013 modify checkdata routine to solve T3000 can not scan multiple untis problem(scan command not support well before ) //cc 05-21-2013 modify filter for each single analog input, set factory default value to 3 //36.9 //cc 03-28-2013 fixed decima blink function //cc 03-28-2013 add writing record test code to check which register will be written by wrong //cc 03-27-2013 modify relay pwm function, changed desire_time[], make sure it not overlap //cc 03-26-2013 modify digital input and digital interlock function, if define digital input, use reg546 to set the digital range on/off or off on //cc 03-22-2013 merge Tstat_AP with normal Tstat5_LCD code //modify keypad and display function //modify input function //modify modbus register address //36.8 //cc 03-06-2013 fixed temperature definition error in serail.c file //cc 02-25-2013 modify LCD rotate display function //36.7 //cc 01-19-2013 fixed after re-initial LCD, the DAY ICON will lost bug. //cc 01-16-2013 fixed GREEND LED, when system in coastingmode, it will turn on. //cc 11-23-2012 fixed sun/moon icon disappeared bug after reset LCD for Paul and Runar //36.6 //cc 11-19-2012 add new register to detect if register101 and register217 have been written by accident, each time do the write operation, the value in relative register will increase one //cc 11-12-2012 add LCD refresh function every 5 minutes for Runar //cc 10-17-2012 fixed i2c may not stop properly problem. //36.5 //cc 09-13-2012 take back setpoint() code //cc 09-13-2012 blank code in check_range() function to allow user adjust Pterm to any samll value //cc 09-12-2012 change eeprom initial function, set default state of info_byte, make sure ID not lock after back to factory default //cc 09-12-2012 fix bug when initial eeprom sometimes will lock the ID //cc 09-12-2012 add code to clear up the eeprom when version update //cc 09-07-2012 delete office mode in occupied mode, keep office mode in unoccupied mode to be compatible with previous version //cc 09-07-2012 merge 36.1 and 36.2 with 36.4 //cc 09-07-2012 add universal output off table and valve table(done by Robert, not noted in the reversion file) //36.4 //cc 09-07-2012 delete office mode in occupied mode, keep office mode in unoccupied mode to be compatible with previous version //cc 09-06-2012 change LCD display item number to 0: only display temperature when firmware version update or new eeprom //cc 09-06-2012 36.3 not used any more //cc 09-06-2012 remove 36.2 and 36.1 change, back it to 35.7 //TBD£º add new setpoint group and compatible with old version //36.3 //cc 08-08-2012 change night setpoint default value, now can use two bytes to store it //cc 08-08-2012 merge 36.1 and 36.2 function, include window interlock, LCD rotate display function //cc 08-02-2012 change setpoint_mode to day_setpoint_mode and night_setpoint_mode //cc 08-02-2012 get rid of hotel and office mode and re-write setpoint formula //36.2 //cc 06-19-2012 change window interlock function, when it is triggered, system not go into unoccupied mode //cc 06-20-2012 change setpoint display when window interlock is triggered rev36_1_lcd: make compatible with new and old pic protocol. rev35_9_lcd: route display . //35.8 //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 //cc 4-13-2012 fixed heating deadband when ocuupied office mode //REV 35.7 //mhf 03-19-2012 //Added shutdown interlock for all outputs and each input can be set as shutdown interlock //REV 35.6 //mhf 03-07-2012 //Added window interlock feature //Fixed problem turn wheel quickly will cause display crashed //Checked and found already ni filter for digital input //REV 35.5 //cc 12-20-2011 //Fixed in occupied mode,can not enter heating mode bug. //Fixed can not change device ID bug //REV 35.4 //cc 11-25-2011 //add eeprom read/write check routine, when read eeprom, read twice and compare the result to avoid interrupt error; //when write eeprom, read it first and compare with target value, check if need change. //MHF 11-25-2011 //Read E2 routine,when ever read ,will send full command to E2,from start signal,device address,data address //Short code in serial interrupt //Add stop signal in give_pic_ack routine in PIC.c //REV 35.3 //MHF 08-23-2011 Put analog output in one routine //REV 35.2 07-04-2011 BY CHARLEY : disable ALE pin to reduce EMI //REV 35.2 //MHF 06-27-2011 Recover heating register writable,added a new register 422 use for cooling setpoint, // register 135 is middle setpoint.Added anew register 423 for day setpoint option, // 1 = hotel and 0 = office.default is hotel mode. // Bit6 of register 184 (base bit is 0)used for write device ID disable/enable.0 = enable // 1 = disable,can not change device ID ,defualt is enable. //REV 35.1 //MHF 06-11-2011 Any output can be configured as PWM output // OUTPTU 6&7 be set at ON/OFF,OFF/ON,will put it in relay_routine function. // FIlter change to zero when input range is ON/OFF or OFF/ON //REV 35.0 //cc cc 06-14-2011 add deadmaster function //cc cc 06-14-2011 change output manual output to register108, combine to one byte //MHF 05-23-2011 Fixed analog output code,any analog output can be set as cooling output or heating output // Housekeeping: Renamed some parameters in the source code for clarity // Put output6 and 7 into same routine as outputs 1 thru 5 when they are configured as ON/OFF or OFF/ON // FIxed a bug,the LCD gets stuck in firmware notice, doesnt jump to normal display routine //REV 34.9 //MHF 04-20-2011 Filter bad pic readings (again), fixed a bug in this routine // Fixed floating mode code here, was missing some code from earlier versions. // PM_5E and Tstat5E can use the same code,no need to use defines //REV 34.8 //MHF 02-17-2011 Added outdoor air feature //add a new register 421 use to turn all fan off, 0 = turn off all fan icons, 1 = turn on fan icons. //fixed write register 184 will cause timeout problem,bit 5 of register 184 use to enable/disable RS485 . //But the register 184 also use for other features,other feature s will set bit5 of register 184 and cause communication problem. //Fixed it. //added a new define 5E_NEW for new version Tstat5E with new PIC //REV 34.7 //MHF 02-12-2011 Stop reset all parameters when change the units from c to f or back // Added a routine do the parameter convertation when Degree_C and Degree_F units changed //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