Out of variable space + PID problems
Porcelina
Posts: 5
Hi all,
I am writing some code to control a mash tun as part of·a beer making process.
Output:
control of 220V heating element·with solid state relay
Input:
*Temperature readings (LM35)
*At start 5 temperature setpoints with the corresponding time to hold each temperature setpoint.
Example:
40°C for 15min
52°C for 30min
63°C for 30min
72°C for 30min
78°C for 1min
I am trying to use PID to control the temperature.
But soon after compiling my testcode, I received the message "Out of variable space".
I am using variables to read the temperature through the ADC, for loops (temperature and time) and·for the PID code.
I have 11 Word variables, 4 Byte variables and 1 bit variable.
The user-input for the temperatures and minutes are stored in the eeprom.
The code isn't very long so expanding it with extra features isn't an option I think because of the lack of space to store my variables. I already began to double use some variables but still it isn't enough.
What could I do to solve my problem?
Best regards
Post Edited (Porcelina) : 5/22/2007 8:57:33 PM GMT
I am writing some code to control a mash tun as part of·a beer making process.
Output:
control of 220V heating element·with solid state relay
Input:
*Temperature readings (LM35)
*At start 5 temperature setpoints with the corresponding time to hold each temperature setpoint.
Example:
40°C for 15min
52°C for 30min
63°C for 30min
72°C for 30min
78°C for 1min
I am trying to use PID to control the temperature.
But soon after compiling my testcode, I received the message "Out of variable space".
I am using variables to read the temperature through the ADC, for loops (temperature and time) and·for the PID code.
I have 11 Word variables, 4 Byte variables and 1 bit variable.
The user-input for the temperatures and minutes are stored in the eeprom.
The code isn't very long so expanding it with extra features isn't an option I think because of the lack of space to store my variables. I already began to double use some variables but still it isn't enough.
What could I do to solve my problem?
Best regards
Post Edited (Porcelina) : 5/22/2007 8:57:33 PM GMT
Comments
Please post your code so we can help determine what may be happening.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
It's usually quite possible to re-use 'temp' variables to reduce the memory space needed. But we'd have to see your code to be sure.
Thank you for responding!
Attached you can find my code.
There are still some problems with the PID part, I have difficulties with that.
I also realise that the code is far from finished.
Best Regards
See further for updated code
Post Edited (Porcelina) : 5/23/2007 7:55:21 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
It looks like you could do a little more analysis of the range of the various variables.
I'd suggest you use the "alias" VAR declaration for the sharing rather than just reusing the name. It makes the program clearer.
It does look like a few ('y', 'a') variables could be nibbles (since they only go from zero to 15 or less). That might save enough space.
One other possible problem -- your 'Main' loop doesn't have 'goto main' at the bottom (or a 'main:' label, for that matter). This means your code will 'run-off' the bottom of the 'main' loop into your subroutines.
Thank you all for responding!
Attached you can find my·new code.
I updated it with the suggestions you all gave me and I solved some small extra bugs.
At this moment I have a temperature overshoot of about 2°C for each temperature setpoint.
I think I have to finetune the·Kp, Ki and Kd·constants.
The following steps are to link the code with a visual basic application.
The VB program will only retrieve·temperature data and·should send the setpoints to the BS2 at the beginning.
As soon as I have more code I will post it.
Feel free to give suggestions·...
Best Regards
Post Edited (Porcelina) : 5/23/2007 8:00:00 PM GMT