G
Guest
----snip
#define POSITIVE_INTEGRATOR_SATURATION 0x03000000L //
#define NEGATIVE_INTEGRATOR_SATURATION 0xFD000000L //
long integrator;
integrator=0;
if (integrator>POSITIVE_INTEGRATOR_SATURATION)
integrator=POSITIVE_INTEGRATOR_SATURATION;
if (integrator<NEGATIVE_INTEGRATOR_SATURATION)
integrator=NEGATIVE_INTEGRATOR_SATURATION;
1. Why does the executable always assign
NEGATIVE_INTEGRATOR_SATURATION to integrator?
-I assume that long declaration means the value is signed (the most
significant bit indicates sign)
------------
#define INTEGRATOR_SATURATION 0x03000000L // 3
long integrator;
integrator=0;
if (integrator>INTEGRATOR_SATURATION)
integrator=POSITIVE_INTEGRATOR_SATURATION;
if (integrator<(0-INTEGRATOR_SATURATION))
integrator=NEGATIVE_INTEGRATOR_SATURATION;
This code leaves integrator at 0, as intended.
-------------
2. Why does the second snippet work, while the first does not.
Additional Info- My machine uses four bytes for long.
I would be happy to learn how to make this portable as soon as I stop
the limit cycles in my control system.
#define POSITIVE_INTEGRATOR_SATURATION 0x03000000L //
#define NEGATIVE_INTEGRATOR_SATURATION 0xFD000000L //
long integrator;
integrator=0;
if (integrator>POSITIVE_INTEGRATOR_SATURATION)
integrator=POSITIVE_INTEGRATOR_SATURATION;
if (integrator<NEGATIVE_INTEGRATOR_SATURATION)
integrator=NEGATIVE_INTEGRATOR_SATURATION;
1. Why does the executable always assign
NEGATIVE_INTEGRATOR_SATURATION to integrator?
-I assume that long declaration means the value is signed (the most
significant bit indicates sign)
------------
#define INTEGRATOR_SATURATION 0x03000000L // 3
long integrator;
integrator=0;
if (integrator>INTEGRATOR_SATURATION)
integrator=POSITIVE_INTEGRATOR_SATURATION;
if (integrator<(0-INTEGRATOR_SATURATION))
integrator=NEGATIVE_INTEGRATOR_SATURATION;
This code leaves integrator at 0, as intended.
-------------
2. Why does the second snippet work, while the first does not.
Additional Info- My machine uses four bytes for long.
I would be happy to learn how to make this portable as soon as I stop
the limit cycles in my control system.