Unable to fit variable


Closed Thread
Results 1 to 15 of 15
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Unable to fit variable

    Hi,

    I a getting an error messages:

    C:\PBP>pbpw -p16f877a charge.bas
    PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
    All Rights Reserved.

    ERROR: Unable to fit variable Voltage_Charge_time_RTCDay
    ERROR: Unable to fit variable Voltage_Charge_time_RTCHour
    ERROR: Unable to fit variable Voltage_Charge_time_RTCMin
    ERROR: Unable to fit variable Voltage_Charge_time_RTCSec
    ERROR: Unable to fit variable Voltage_Discharge_time_RTCDay
    ERROR: Unable to fit variable Voltage_Discharge_time_RTCHour
    ERROR: Unable to fit variable Voltage_Discharge_time_RTCMin
    ERROR: Unable to fit variable Voltage_DisCharge_time_RTCSec

    where these are declare like this:
    Voltage_Charge_time_RTCSec var byte[250]
    Voltage_Charge_time_RTCMin var byte[250]
    Voltage_Charge_time_RTCHour var byte[250]
    Voltage_Charge_time_RTCDay var byte[250]

    Voltage_DisCharge_time_RTCSec var byte[250]
    Voltage_Discharge_time_RTCMin var byte[250]
    Voltage_Discharge_time_RTCHour var byte[250]
    Voltage_Discharge_time_RTCDay var byte[250]


    I have no idea where to direct myself to correct this. Any idea?
    thanks

    K

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Still a newbe

    And not having my PBP manual handy, do those declares try and allocate 8 arrays , 250 elements big? so 2k just for the vars?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    yep ok put this at ten and it now compile error free. Thanks for the cue really appreciate it.

    But with ten elements:
    Voltage_Charge_time_RTCSec var byte[10]
    does that mean I can have only ten values? like:
    Voltage_Charge_time_RTCSec var byte[0]
    Voltage_Charge_time_RTCSec var byte[1].....
    ......
    Voltage_Charge_time_RTCSec var byte[9]
    Voltage_Charge_time_RTCSec var byte[10] ?????

    Ken

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hello,

    The 16F877A has 368 bytes of RAM so trying to fit 8 arrays each 250 bytes long is simply impossible.

    On top of that, on 16F devices, the RAM is divided into banks (which PBP mostly handle transparantly for you) and each array has to fit in one RAM bank. Each bank is 128 bytes but the lower 32bytes of each bank is occupied by the special function registers (TMR0, INTCON, TXREG etc) so only the upper 96 bytes of each bank is available for "user RAM". So the longest array you can declare on a 16F device is 96 bytes.

    Not all banks will have the top 96 bytes available either, see the memory organization chapter in the datasheet for the particualr PIC details and the section about arrays in the PBP manual for more details.

    /Henrik.

    EDIT: Ah, was a little slow typing there. Anyway, hopefully the information will help.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    yep ok put this at ten and it now compile error free. Thanks for the cue really appreciate it.

    But with ten elements:
    Voltage_Charge_time_RTCSec var byte[10]
    does that mean I can have only ten values? like:
    Voltage_Charge_time_RTCSec var byte[0]
    Voltage_Charge_time_RTCSec var byte[1].....
    ......
    Voltage_Charge_time_RTCSec var byte[9]
    Voltage_Charge_time_RTCSec var byte[10] ?????

    Ken
    yes thats what it means, except it will go from 0 - 9, not 0 - 10. 0 - 10 is 11 elements. What are you trying to save here? sec and min should never need to be over 60 hours would never need to exceed 12 or 24 days would never need to be more than 31 add months for up to 12. but I may very well be thinking a whole different thing.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Humm yes I understand what you mean.
    Here is what i am attempting to do, for sure there is anothr way to do it much better then the one I am thinking. My battery will be charging and discharging automatically for an indefinit period of time. Lets say the longest would a month !! So there could be lets say 5 charge /discharge cycle a day..so 150 total. SO for the seconds I would have something like that:
    Voltage_Charge_time_RTCSec var byte[0] = First charge cycle time (ie. 02 seconds)
    Voltage_Charge_time_RTCSec var byte[1] = Second charge cycle time (ie. 42 seconds)
    etc...
    How can I keep the time for 150 cycles ?

    K
    Last edited by lerameur; - 25th November 2010 at 15:53.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    How can I keep the time for 150 cycles ?
    Write to the EEPROM?
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Guess thats a good idea. I will go ahead and read up on EEPROM in the F88.pdf meanwhhile if you have a tutorial of something interesting to read on programming to the EEPROM with pic basic, that will be very appreciate . I never programmed to the EEPROM before !!

    k

  9. #9
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Hi I can find a lot of stuff with external EEPROM, if I need to program the internal EEPROM, do I need to use wires to itself ? I have not seen any examples either !! so far

    K

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    http://melabs.com/resources/samples/pbp/eeword.htm
    And the manual are two good places to start.

    Work those examples and let us know how it goes.
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    ok from what I can read from the PIC16F88 manual, it write 8 bit at a time, so I suppose a number 255 is possible but not higher right ??
    So this should use 255 position in the memory ?
    if I put in a time in seconds , then I should increment by 255 ?

    This is what I make out from the example you gave me, they increment a 1000 in the memory bank everytime thay add a number in there.
    Is this how I should interpret?

    K

  12. #12
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Also, from the manual of the PIC16F88, there are 256 bytes allocated to EEPROM. I may need more. since I want to include 150 charge time and 150 discharge time.
    Each charge time has a memory position for the seconds, minutes, hours, and day:

    Voltage_Charge_time_RTCSec var byte[150]
    Voltage_Charge_time_RTCMin var byte[150]
    Voltage_Charge_time_RTCHour var byte[150]
    Voltage_Charge_time_RTCDay var byte[150]

    Voltage_DisCharge_time_RTCSec var byte[150]
    Voltage_Discharge_time_RTCMin var byte[150]
    Voltage_Discharge_time_RTCHour var byte[150]
    Voltage_Discharge_time_RTCDay var byte[150]

    so I need 1200 bytes OOOOO !! I guess!!
    Last edited by lerameur; - 25th November 2010 at 21:11.

  13. #13
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    This might be the ticket if your code is not too large.
    http://www.picbasic.co.uk/forum/show...ght=playground
    Dave
    Always wear safety glasses while programming.

  14. #14
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Dave, "Making code space your playground"...... Play nice now kids....

    Dave Purola,
    N8NTA

  15. #15
    Join Date
    Jul 2003
    Location
    USA - Arizona
    Posts
    156


    Did you find this post helpful? Yes | No

    Default Look for external serial memories


Members who have read this thread : 2

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