Ingo
17 Jun 09, 07:56 PM
I cannot figure out why I get different results for an arithmetic function from PICED and a PAC. Below is what I am trying to achieve.
LightLevelRear : Real;
if GetUnitParamStatus("Local Network", 16, ptLightLevel) then
begin
LightLevelRear := GetUnitParameter("Local Network", 16, ptLightLevel) / 13.2; { Get Light level in approximate CBUS level }
SetLightingLevel("Group 245 - LightLevel - Rear", Round(LightLevelRear), "0s");
Delay("00:02:10");
end;
What the above is supposed to do is take the Lux reading from the LightLevel meter, convert it to a CBus level of between 0 and 255. My max light level is 3370 and my minimum is 25. If I run through the arithmetic manually I get 255.3 as max and 1.9 as minimum.
Now, when I use the Round() function to populate Group 245 it ends up as either 255, for Max, and 2, for Min, which is absulutely what I intend.
When I download this code to the PAC it gives me 250 as max and not 255. As soon as I run PICED in simulation mode and run the logic code ONCE it changes Group 245 from 250 to 255. After a short while the PAC updates the counter back down to 250.
I have fried my brain trying to figure this out, and I will feel pretty stupid if I missed something, but why is this behaviour different between the two units?
Ingo
LightLevelRear : Real;
if GetUnitParamStatus("Local Network", 16, ptLightLevel) then
begin
LightLevelRear := GetUnitParameter("Local Network", 16, ptLightLevel) / 13.2; { Get Light level in approximate CBUS level }
SetLightingLevel("Group 245 - LightLevel - Rear", Round(LightLevelRear), "0s");
Delay("00:02:10");
end;
What the above is supposed to do is take the Lux reading from the LightLevel meter, convert it to a CBus level of between 0 and 255. My max light level is 3370 and my minimum is 25. If I run through the arithmetic manually I get 255.3 as max and 1.9 as minimum.
Now, when I use the Round() function to populate Group 245 it ends up as either 255, for Max, and 2, for Min, which is absulutely what I intend.
When I download this code to the PAC it gives me 250 as max and not 255. As soon as I run PICED in simulation mode and run the logic code ONCE it changes Group 245 from 250 to 255. After a short while the PAC updates the counter back down to 250.
I have fried my brain trying to figure this out, and I will feel pretty stupid if I missed something, but why is this behaviour different between the two units?
Ingo