Shop OBEX P1 Docs P2 Docs Learn Events
Creating a Dead-Band or Filter around 0 "C" — Parallax Forums

Creating a Dead-Band or Filter around 0 "C"

ShawnaShawna Posts: 508
edited 2020-02-14 20:37 in Propeller 1
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:
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

Sign In or Register to comment.