Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. int hsgn(double input, double thresh){
  3.         int ret;
  4.         if(input > math.abs(thresh))
  5.                 ret = 1;
  6.         else if(input < math.abs(thresh))
  7.                 ret = -1;
  8.         else
  9.                 ret = 0;
  10.        
  11.         return ret;
  12. }
  13.  
  14.  
  15. zeroCrossCounter(double input, double thresh){
  16.     static int xzc;
  17.     static int xc;
  18.     if(abs(xzc) > 1)
  19.         xzc = 0;
  20.     if(abs(xc) > 1)
  21.         xc = 0;
  22.         int ysgn = hsgn(input, thresh);
  23.     int xzcn = kzc(ysgn, xzc);
  24.     xzc = xzcn;
  25.     int yzc = hzc(ysgn, xzc);
  26.     int xcn = kc(yzc, xc);
  27.     xc = xcn;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement