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>
30 #define MAX_SPEED 10000
31 static int32_t motor_speed=0;
32 static int32_t motor_pos=0;
34 /* try to simulate a motor (quick and dirty and wrong) */
35 void motor_set(void * dummy, int32_t in)
37 motor_speed = motor_speed - motor_speed/8 ;
41 int32_t motor_get_pos(void * dummy)
43 motor_pos += motor_speed;
50 struct pid_filter my_pid;
51 struct quadramp_filter my_qr;
57 pid_set_gains(&my_pid, 40, 1, 3);
58 pid_set_maximums(&my_pid, 0, 5000, 4095);
59 pid_set_out_shift(&my_pid, 10);
61 quadramp_init(&my_qr);
62 quadramp_set_1st_order_vars(&my_qr, 1000, 1000); /* set speed */
63 quadramp_set_2nd_order_vars(&my_qr, 100, 100); /* set accel */
66 cs_set_consign_filter(&my_cs, quadramp_do_filter, &my_qr);
67 cs_set_correct_filter(&my_cs, pid_do_filter, &my_pid);
68 cs_set_process_in(&my_cs, motor_set, NULL);
69 cs_set_process_out(&my_cs, motor_get_pos, NULL);
70 cs_set_consign(&my_cs, 0);
72 for ( i=0 ; i<10 ; i++) {
77 cs_set_consign(&my_cs, 100000);