Creating a Dead-Band or Filter around 0 "C"
Shawna
Posts: 508
I want to setup a dead-band or filter for a variable in my program. I wrote code that works, but I was wondering if there is a simpler, cleaner or faster way than what I've come up with.
Here's my code:
Edit: If my variable is less than 10 and greater than -10, I want to set my variable to 0. Otherwise I will keep the value of the variable.
Thanks
Shawn A
Here's my code:
temp = p_gx - p_gxOff;
if((temp < 10) && (temp > -10)) p_gx = 0;
else p_gx = temp;
Edit: If my variable is less than 10 and greater than -10, I want to set my variable to 0. Otherwise I will keep the value of the variable.
Thanks
Shawn A
Comments
C also has a ternary operator:
p_gx = abs(temp) < 10 ? 0 : temp;
-Phil