Hi
I want to define a constant value by a mathematic operation using a predefined constant.
Something like this
#define cUmax 20000 ;constant to be given by user
#define cImax 3000 ;constant to be given by user
#define cT1 cUmax/19 ;const cT1 = CUmax/19
#define cT2 cUmax/100 + cT1 ;const cT2 = cUmax/100 + cT1
#define cT3 cT2 + cImax/100 ;const cT3 = cT2 + cImax/100
But the code (3 last lines) above is not possible in PicAxeBasic.
Currently I see only these 2 solutions:
1) Using Symbols and variables - calculate them with word/byte variables
=> As I need all variables for the rest of the program - I can't use this
2) Calculation as in 1) and store the results in the EEPROM.
=> But this needs later on also the word/byte variables for the code
and leads to a lot of Store/Load-procedures
Furthermore - I assume, that the read/write procedures to the EEPROM
are a little bit "longer" then those from the stack....
Is there an other solution ? (as I need the calculation only once a time and then
using the calculated values like constant)
I read several times the manuals - but I couldn't find any other solution/hint.
Any idea how to solve this ?
kind regards
Albatros
P.S: My current solution is to claclulate all the values by myself and put them into the code like below...
(which works ok - but that could be faulty...)
#define cUmax 20000 ;constant to be given by user
#define cT1 1052 ;const cT1 = CUmax/19
#define cT2 1252 ;const cT2 = cUmax/100 + cT1
...
I want to define a constant value by a mathematic operation using a predefined constant.
Something like this
#define cUmax 20000 ;constant to be given by user
#define cImax 3000 ;constant to be given by user
#define cT1 cUmax/19 ;const cT1 = CUmax/19
#define cT2 cUmax/100 + cT1 ;const cT2 = cUmax/100 + cT1
#define cT3 cT2 + cImax/100 ;const cT3 = cT2 + cImax/100
But the code (3 last lines) above is not possible in PicAxeBasic.
Currently I see only these 2 solutions:
1) Using Symbols and variables - calculate them with word/byte variables
=> As I need all variables for the rest of the program - I can't use this
2) Calculation as in 1) and store the results in the EEPROM.
=> But this needs later on also the word/byte variables for the code
and leads to a lot of Store/Load-procedures
Furthermore - I assume, that the read/write procedures to the EEPROM
are a little bit "longer" then those from the stack....
Is there an other solution ? (as I need the calculation only once a time and then
using the calculated values like constant)
I read several times the manuals - but I couldn't find any other solution/hint.
Any idea how to solve this ?
kind regards
Albatros
P.S: My current solution is to claclulate all the values by myself and put them into the code like below...
(which works ok - but that could be faulty...)
#define cUmax 20000 ;constant to be given by user
#define cT1 1052 ;const cT1 = CUmax/19
#define cT2 1252 ;const cT2 = cUmax/100 + cT1
...