00001 /* 00002 * Copyright Droids Corporation, Microb Technology, Eirbot (2005) 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Revision : $Id: quadramp_derivate.h,v 1.3 2008-01-08 22:12:04 zer0 Exp $ 00019 * 00020 */ 00021 00022 #ifndef _QUADRAMP_DERIVATE_H_ 00023 #define _QUADRAMP_DERIVATE_H_ 00024 00025 #include <aversive.h> 00026 00027 struct quadramp_derivate_filter 00028 { 00029 uint32_t var_2nd_ord_pos; 00030 uint32_t var_2nd_ord_neg; 00031 uint32_t var_1st_ord_pos; 00032 uint32_t var_1st_ord_neg; 00033 00034 int32_t previous_in_position; 00035 int32_t previous_out_speed; 00036 00037 int32_t goal_window; 00038 int32_t gain_anticipation; /* fixed point value, * 1/256 */ 00039 00040 int32_t pivot; /* debug only */ 00041 00042 uint8_t divisor; 00043 uint8_t divisor_counter; 00044 }; 00045 00048 extern inline void quadramp_derivate_init(struct quadramp_derivate_filter * r); 00049 00055 extern inline void quadramp_derivate_set_gain_anticipation(struct quadramp_derivate_filter * q, uint16_t gain_anticipation); 00056 00059 extern inline void quadramp_derivate_set_goal_window(struct quadramp_derivate_filter * q, uint32_t goal_window); 00060 00063 extern inline void quadramp_derivate_set_2nd_order_vars(struct quadramp_derivate_filter * q, uint32_t var_2nd_ord_pos, uint32_t var_2nd_ord_neg); 00064 extern inline void quadramp_derivate_set_1st_order_vars(struct quadramp_derivate_filter * q, uint32_t var_1st_ord_pos, uint32_t var_1st_ord_neg); 00065 00075 extern inline void quadramp_derivate_set_divisor(struct quadramp_derivate_filter * q, uint8_t divisor); 00076 00077 00089 extern int32_t quadramp_derivate_do_filter(void * data, int32_t in); 00090 00091 #endif