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: main.c,v 1.4.4.2 2007-05-23 17:18:13 zer0 Exp $
25 #include <aversive/wait.h>
28 #include <control_system_manager.h>
34 #define MAX_SPEED 10000
35 static int32_t motor_speed=0;
36 static int32_t motor_pos=0;
38 /* try to simulate a motor (quick and dirty and wrong) */
39 void motor_set(void * dummy, int32_t in)
41 motor_speed = motor_speed - motor_speed/8 ;
45 int32_t motor_get_pos(void * dummy)
47 motor_pos += motor_speed;
54 struct pid_filter my_pid;
55 struct quadramp_filter my_qr;
61 pid_set_gains(&my_pid, 40, 1, 3);
62 pid_set_maximums(&my_pid, 0, 5000, 4095);
63 pid_set_out_shift(&my_pid, 10);
65 quadramp_init(&my_qr);
66 quadramp_set_1st_order_vars(&my_qr, 1000, 1000); /* set speed */
67 quadramp_set_2nd_order_vars(&my_qr, 100, 100); /* set accel */
70 cs_set_consign_filter(&my_cs, quadramp_do_filter, &my_qr);
71 cs_set_correct_filter(&my_cs, pid_do_filter, &my_pid);
72 cs_set_process_in(&my_cs, motor_set, NULL);
73 cs_set_process_out(&my_cs, motor_get_pos, NULL);
74 cs_set_consign(&my_cs, 0);
76 for ( i=0 ; i<10 ; i++) {
81 cs_set_consign(&my_cs, 100000);