2 * Copyright Droids Corporation (2007)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: blocking_detection_manager.h,v 1.1.2.6 2008-05-09 08:25:10 zer0 Exp $
20 * Olivier MATZ <zer0@droids-corp.org>
23 /* blocking detection manager */
25 #ifndef BLOCKING_DETECTION_MANAGER_H_
26 #define BLOCKING_DETECTION_MANAGER_H_
28 /* display debug every 128 calls of manage if defined */
31 #include <control_system_manager.h>
33 /* detect blocking based on motor current.
34 * triggers the blocking if:
35 * - the current in the motor is a above a threshold
37 * - the speed is below the threshold (if specified)
39 * We suppose that i = k1.V - k2.w
40 * (V is the voltage applied on the motor, and w the current speed
44 struct blocking_detection {
61 /** init module, give the cs as parameter */
62 void bd_init(struct blocking_detection *bd);
64 /** thresholds for current-based blocking detection. If cpt_thres
65 * is 0, disable it. */
66 void bd_set_current_thresholds(struct blocking_detection *bd,
67 int32_t k1, int32_t k2,
68 uint32_t i_thres, uint16_t cpt_thres);
70 /** speed threshold: if speed is above it, disable
71 * blocking_detection. */
72 void bd_set_speed_threshold(struct blocking_detection *bd,
75 /** reset the blocking */
76 void bd_reset(struct blocking_detection *bd);
78 /** function to be called periodically, when we use cs structure */
79 void bd_manage_from_cs(struct blocking_detection *bd, struct cs *cs);
81 /** function to be called periodically, when we use values directly */
82 void bd_manage_from_pos_cmd(struct blocking_detection *bd,
83 int32_t pos, int32_t cmd);
85 /** function to be called periodically, when we use values directly */
86 void bd_manage_from_speed_cmd(struct blocking_detection *bd,
87 int32_t speed, int32_t cmd);
89 /** get value of blocking detection */
90 uint8_t bd_get(struct blocking_detection *bd);