eprom memory location


Closed Thread
Results 1 to 5 of 5
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default eprom memory location

    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

    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

    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

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    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.

    Code:
    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
    All progress began with an idea

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thank you for the prompt reply,

    There is only one lookup section in the rtc code

    Code:
    FindDays:
    	LookUp SetMonth-1,[31,28,31,30,31,30,31,31,30,31,30,31],CounterA
    I assume I change this to

    Code:
    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

    Code:
    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 ?
    Last edited by malc-c; - 27th March 2010 at 23:20.

  4. #4
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Add just 150 to :

    Read (CounterA + 150),CounterD



    ... and see if it works.

    Al.
    Last edited by aratti; - 28th March 2010 at 00:05.
    All progress began with an idea

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thankypu, works a treat....

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

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts