PDA

View Full Version : Unable to fit variable



lerameur
- 25th November 2010, 13:26
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

cncmachineguy
- 25th November 2010, 13:31
And not having my PBP manual handy, do those declares try and allocate 8 arrays , 250 elements big? so 2k just for the vars?

lerameur
- 25th November 2010, 13:38
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

HenrikOlsson
- 25th November 2010, 13:50
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.

cncmachineguy
- 25th November 2010, 15:18
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.

lerameur
- 25th November 2010, 15:31
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

mackrackit
- 25th November 2010, 16:47
How can I keep the time for 150 cycles ?
Write to the EEPROM?

lerameur
- 25th November 2010, 17:24
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

lerameur
- 25th November 2010, 17:52
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

mackrackit
- 25th November 2010, 18:08
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.

lerameur
- 25th November 2010, 19:47
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

lerameur
- 25th November 2010, 20:24
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!!

mackrackit
- 26th November 2010, 03:18
This might be the ticket if your code is not too large.
http://www.picbasic.co.uk/forum/showthread.php?t=137&highlight=playground

Dave
- 27th November 2010, 22:11
Dave, "Making code space your playground"...... Play nice now kids....

Dave Purola,
N8NTA

languer
- 29th November 2010, 20:34
Look for external serial memory (http://www.picbasic.co.uk/forum/showthread.php?t=12766).

In particular look at serial (SPI or I2C) EEPs (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2697), SRAM (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2698), or FRAM (http://www.ramtron.com/products/nonvolatile-memory/serial.aspx).