2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
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: control_system_manager.h,v 1.7.4.5 2008-03-02 17:18:34 zer0 Exp $
22 /* Droids-corp, Eirbot, Microb Techology 2005
23 * Implementation for the control_system manager
26 /** \file control_system_manager.h
27 * \brief Interface for the control_system manager module.
29 * \todo Test the module on a real system.
31 * \test No test for the moment, only correct compilation.
33 * This module provide functions to control and regulate a system.
36 #ifndef _CONTROL_SYSTEM_MANAGER_
37 #define _CONTROL_SYSTEM_MANAGER_
41 /** The data structure used by the control_system_manager module */
44 int32_t (*consign_filter)(void *, int32_t);
45 void* consign_filter_params;
47 int32_t (*correct_filter)(void*, int32_t);
48 void* correct_filter_params;
50 int32_t (*feedback_filter)(void*, int32_t);
51 void* feedback_filter_params;
53 int32_t (*process_out)(void*);
54 void* process_out_params;
56 void (*process_in)(void*, int32_t);
57 void* process_in_params;
59 int32_t consign_value;
60 int32_t filtered_feedback_value;
61 int32_t filtered_consign_value;
66 /******* - Prototyping - *******/
68 /** Initiate the control_system structure by setting all fields to NULL */
69 void cs_init(struct cs* cs);
71 /** Set the cs consign_filter fields in the cs structure */
72 void cs_set_consign_filter(struct cs* cs,
73 int32_t (*consign_filter)(void*, int32_t),
74 void* consign_filter_params);
76 /** Set the cs correct_filter fields in the cs structure */
77 void cs_set_correct_filter(struct cs* cs,
78 int32_t (*correct_filter)(void*, int32_t),
79 void* correct_filer_params);
81 /** Set the cs feedback_filter fields in the cs structure */
82 void cs_set_feedback_filter(struct cs* cs,
83 int32_t (*feedback_filter)(void*, int32_t),
84 void* feedback_filer_params);
86 /** Set the cs process_in fields in the cs structure */
87 void cs_set_process_in(struct cs* cs,
88 void (*process_in)(void*, int32_t),
89 void* process_in_params);
91 /** Set the cs process_out fields in the cs structure */
92 void cs_set_process_out(struct cs* cs,
93 int32_t (*process_out)(void*),
94 void* process_out_params);
97 /** \brief This function do the main loop of the control system process.
99 * - Save the consign in the structure.
100 * - Apply the consign filter to the consign.
101 * - Read the process out
102 * - Apply the feedback filter to the process out
103 * - Substract filtered consign to filtered process out.
104 * - Save the result in error_value and apply the correct filter.
105 * - Save the filtered result and send it to process_in().
106 * - Return this result.
109 int32_t cs_do_process(struct cs* cs, int32_t consign);
111 /** Apply cs_do_process() to the structure cs
112 * \param cs should be a (struct cs*)
114 void cs_manage(void * cs);
116 /** Return the last output sent to process */
117 int32_t cs_get_out(struct cs* cs);
119 /** Return the last calculated error */
120 int32_t cs_get_error(struct cs* cs);
122 /** Return the current consign */
123 int32_t cs_get_consign(struct cs* cs);
125 /** Return the current consign, after filter */
126 int32_t cs_get_filtered_consign(struct cs* cs);
128 /** Return the last feedback value, after filter */
129 int32_t cs_get_filtered_feedback(struct cs* cs);
131 /** Change the consign without calculating control system */
132 void cs_set_consign(struct cs* cs, int32_t v);
135 #endif /* #ifndef _CONTROL_SYSTEM_MANAGER_ */