PDA

View Full Version : eprom memory location



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

aratti
- 27th March 2010, 22:45
Malcolm, you can start from location 150 with your RTC code, but you will need to add 150 to all the read instructions in the RTC code, otherwise it will not work.

Al.



EEPROM Locations
' ----------------
Data @150,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

malc-c
- 27th March 2010, 23:08
Thank you for the prompt reply,

There is only one lookup section in the rtc code



FindDays:
LookUp SetMonth-1,[31,28,31,30,31,30,31,31,30,31,30,31],CounterA


I assume I change this to



FindDays:
LookUp SetMonth-150,[31,28,31,30,31,30,31,31,30,31,30,31],CounterA


EDIT: Tried that, and which the PID code now runs fine, the month is shown as hieroglyphics 27 hieroglyphics 2010

I also have this code which I gather would read the values



DisplayMonth:
CounterB=CounterB*3-3 ' Convert BCD Month to EEPROM Start Address
DisplaySequence:
For CounterA=CounterB to CounterB+2
' Read and Display Month
Read CounterA,CounterD
LCDOut CounterD
Next CounterA
Return


What would I need to change ?

aratti
- 27th March 2010, 23:52
Add just 150 to :

Read (CounterA + 150),CounterD



... and see if it works.

Al.

malc-c
- 28th March 2010, 10:22
Thankypu, works a treat....

I guess it was obvious really... but it had been a long day !