Fraise
2.1
FRAmework for Interfacing Software and Electronics
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Typedefs
Groups
ramp.h
1
/*********************************************************************
2
*
3
* Ramp library for Fraise pic18f device
4
*
5
* Ramp generator with destination position, maxspeed/acceleration
6
*********************************************************************
7
* Author Date Comment
8
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
* Antoine Rousseau dec 2012 Original.
10
********************************************************************/
11
/*
12
# This program is free software; you can redistribute it and/or
13
# modify it under the terms of the GNU General Public License
14
# as published by the Free Software Foundation; either version 2
15
# of the License, or (at your option) any later version.
16
#
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
21
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25
# MA 02110-1301, USA.
26
*/
27
#ifndef _ramp_H_
28
#define _ramp_H_
29
30
#include <
fruit.h
>
31
32
#ifndef RAMP_UINCPOW
33
#define RAMP_UINCPOW 10 // 1 increment = 1024 milli-increments (mincs) = 1024x1024 micro-increments (uincs)
34
#endif
35
36
37
typedef
struct
{
38
int
destPos;
//Destination position, in incs
39
long
int
currentPos;
//Current position in mincs
40
int
maxSpeed;
//Maximum absolute speed allowed to ramp generator, in minc/ms
41
long
int
speed;
//Consign speed computed by ramp generator, in uinc/ms
42
int
maxAccel ;
//Maximum acceleration allowed to ramp generator, in uinc/ms/ms
43
*
44
//ex: RAMP_UINCPOW=10
45
// maxAccel=1 -> 1 uinc/ms/ms : during 1s, speed will be increased of 1000/1024 minc/ms :
46
// it will take about 1s for speed to increase of 1 maxSpeed unity.
47
// maxAccel=1024 -> 1uinc/ms/ms:1000(uinc/ms)/s: 1.024s to reach speed 1024 (=1 inc/s)
48
// max 65535-> about 1/16s to reach speed 1024
49
50
int
maxDecel ;
//Maximum acceleration allowed to trajectory generator, in uinc/ms/ms
51
}
t_ramp
;
52
53
void
rampInit(
t_ramp
*Ramp);
54
void
rampGoto(
t_ramp
*Ramp,
int
pos);
55
void
rampSetPos(
t_ramp
*Ramp,
int
pos);
56
#define rampGetPos(Ramp) ((Ramp)->currentPos>>(RAMP_UINCPOW))
57
void
rampCompute(
t_ramp
*Ramp);
58
void
rampInput(
t_ramp
*Ramp);
59
void
rampDeclareEE(
t_ramp
*Ramp);
60
61
#define RAMP_EESIZE 6 // 4 bytes of eeprom
62
63
#endif // _PID_H_
t_ramp
Definition:
ramp.h:37
fruit.h
ramp
ramp.h
Generated on Mon Jan 18 2016 00:28:53 for Fraise by
1.8.6