malc-c
- 27th March 2010, 22:20
Further exploits of my trials with an 18F4580 has resulted in getting the two programs independantly migrated across and working. However when I merged the two together I was getting problems with the PID routines. I found that there was a conflict with the two codes as the both use the data comand to write to the EEprom area.
PID code uses this code
;----[EEPROM Data]----------------------------------------------------------
DATA @0,0
EE_spMode1 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint1 DATA WORD 260 ' 26.0 deg. after programming if not in manual mode
EE_pid_Kp1 DATA WORD $0700 ' PID constants
EE_pid_Ki1 DATA WORD $0080
EE_pid_Kd1 DATA WORD $0200
EE_pid_Ti1 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp1 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp1 DATA WORD 255 ' Clamp the final output to 255
EE_CH1PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 2 defaults)------
EE_spMode2 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint2 DATA WORD 260
EE_pid_Kp2 DATA WORD $0700 ' PID constants
EE_pid_Ki2 DATA WORD $0080
EE_pid_Kd2 DATA WORD $0200
EE_pid_Ti2 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp2 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp2 DATA WORD 255 ' Clamp the final output to 255
EE_CH2PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 3 defaults)------
EE_spMode3 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint3 DATA WORD 260
EE_pid_Kp3 DATA WORD $0700 ' PID constants
EE_pid_Ki3 DATA WORD $0080
EE_pid_Kd3 DATA WORD $0200
EE_pid_Ti3 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp3 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp3 DATA WORD 255 ' Clamp the final output to 255
EE_CH3PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 4 defaults)------
EE_spMode4 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint4 DATA WORD 260 ' 26.0 deg. after programming
EE_pid_Kp4 DATA WORD $0700 ' PID constants
EE_pid_Ki4 DATA WORD $0080
EE_pid_Kd4 DATA WORD $0125
EE_pid_Ti4 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp4 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp4 DATA WORD 255 ' Clamp the final output to 255
EE_CH4PWR DATA 1 ' this needs to be set to 1 to enable heater channel
The RTC code has this code
'EEPROM Locations
' ----------------
Data @0,74,97,110,70,101,98,77,97,114,65,112,114
' Jan Feb Mar Apr
Data 77,97,121,74,117,110,74,117,108,65,117,103
' May Jun Jul Aug
Data 83,101,112,79,99,116,78,111,118,68,101,99
' Sep Oct Nov Dec
Data 84,117,101,87,101,100,84,104,117,70,114,105
' Tue Wed Thu Fri
Data 83,97,116,83,117,110,77,111,110
' Sat Sun Mon
If I add just the latter to the PID code it causes the PID routine to incorrectly function. I've looked at the datasheet but my inexperience makes it as clear as mud.
Is there a way of using the two sets of data, but keeping them at separate memory locations so they don't clash
PID code uses this code
;----[EEPROM Data]----------------------------------------------------------
DATA @0,0
EE_spMode1 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint1 DATA WORD 260 ' 26.0 deg. after programming if not in manual mode
EE_pid_Kp1 DATA WORD $0700 ' PID constants
EE_pid_Ki1 DATA WORD $0080
EE_pid_Kd1 DATA WORD $0200
EE_pid_Ti1 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp1 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp1 DATA WORD 255 ' Clamp the final output to 255
EE_CH1PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 2 defaults)------
EE_spMode2 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint2 DATA WORD 260
EE_pid_Kp2 DATA WORD $0700 ' PID constants
EE_pid_Ki2 DATA WORD $0080
EE_pid_Kd2 DATA WORD $0200
EE_pid_Ti2 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp2 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp2 DATA WORD 255 ' Clamp the final output to 255
EE_CH2PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 3 defaults)------
EE_spMode3 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint3 DATA WORD 260
EE_pid_Kp3 DATA WORD $0700 ' PID constants
EE_pid_Ki3 DATA WORD $0080
EE_pid_Kd3 DATA WORD $0200
EE_pid_Ti3 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp3 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp3 DATA WORD 255 ' Clamp the final output to 255
EE_CH3PWR DATA 1 ' this needs to be set to 1 to enable heater channel
;---(PID channel 4 defaults)------
EE_spMode4 DATA 0 ' 0=Manual mode, temp is set by Pot.
EE_SetPoint4 DATA WORD 260 ' 26.0 deg. after programming
EE_pid_Kp4 DATA WORD $0700 ' PID constants
EE_pid_Ki4 DATA WORD $0080
EE_pid_Kd4 DATA WORD $0125
EE_pid_Ti4 DATA 8 ' Update I-term every 8th call to PID
EE_pid_I_Clamp4 DATA 125 ' Clamp I-term to max ±100
EE_pid_Out_Clamp4 DATA WORD 255 ' Clamp the final output to 255
EE_CH4PWR DATA 1 ' this needs to be set to 1 to enable heater channel
The RTC code has this code
'EEPROM Locations
' ----------------
Data @0,74,97,110,70,101,98,77,97,114,65,112,114
' Jan Feb Mar Apr
Data 77,97,121,74,117,110,74,117,108,65,117,103
' May Jun Jul Aug
Data 83,101,112,79,99,116,78,111,118,68,101,99
' Sep Oct Nov Dec
Data 84,117,101,87,101,100,84,104,117,70,114,105
' Tue Wed Thu Fri
Data 83,97,116,83,117,110,77,111,110
' Sat Sun Mon
If I add just the latter to the PID code it causes the PID routine to incorrectly function. I've looked at the datasheet but my inexperience makes it as clear as mud.
Is there a way of using the two sets of data, but keeping them at separate memory locations so they don't clash