X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Falgo%2Framp.h;h=ad3c9197561331f0b35c63786e5b80801faca1d4;hb=f8e4f3c7c1fec67b18126ee082f964cf9ceb14c7;hp=f438dc5ebe1d7574566f85a16af5503731b745f5;hpb=791e167e053bdd9250d34a9a5ccae6ccde4d6679;p=bertos.git diff --git a/bertos/algo/ramp.h b/bertos/algo/ramp.h index f438dc5e..ad3c9197 100644 --- a/bertos/algo/ramp.h +++ b/bertos/algo/ramp.h @@ -1,4 +1,3 @@ - /** * \file * * - * \brief Compute, save and load ramps for stepper motors (interace) - * - * \version $Id$ - * - * \author Simone Zinanni - * \author Giovanni Bajo - * \author Daniele Basile + * \brief Compute, save and load ramps for stepper motors. * * The acceleration ramp is used to properly accelerate a stepper motor. The main * entry point is the function ramp_evaluate(), which must be called at every step @@ -44,54 +37,23 @@ * for DSP56000 (but a portable C version of it can be easily written, see the * comments in the code). * + * + * \author Simone Zinanni + * \author Giovanni Bajo + * \author Daniele Basile + * + * $WIZ$ module_name = "ramp" + * $WIZ$ module_configuration = "bertos/cfg/cfg_ramp.h" */ #ifndef ALGO_RAMP_H #define ALGO_RAMP_H -#include -#include "hw_stepper.h" - -/** - * Define whether the ramp will use floating point calculation within ramp_evaluate(). - * Otherwise, a less precise fixed point version will be used, which is faster on - * platforms which do no support floating point operations. - * - * \note Floating point operations will be always done within ramp_compute() to - * precalculate values, so there has to be at least a floating point emulation support. - */ -#define RAMP_USE_FLOATING_POINT 0 - - -#if !RAMP_USE_FLOATING_POINT - - /** - * Number of least-significant bits which are stripped away during ramp evaluation. - * This setting allows to specify larger ramps at the price of less precision. - * - * The maximum ramp size allowed is 2^(24 + RAMP_CLOCK_SHIFT_PRECISION), in clocks. - * For instance, using RAMP_CLOCK_SHIFT_PRECISION 1, and a 8x prescaler, the maximum - * length of a ramp is about 6.7 secs. Raising RAMP_CLOCK_SHIFT_PRECISION to 2 - * brings the maximum length to 13.4 secs, at the price of less precision. - * - * ramp_compute() will check that the length is below the maximum allowed through - * a runtime assertion. - * - * \note This macro is used only for the fixed-point version of the ramp. - */ - #define RAMP_CLOCK_SHIFT_PRECISION 2 -#endif +#include "hw/hw_stepper.h" +#include "cfg/cfg_ramp.h" -///< Negative pulse width for ramp -#define RAMP_PULSE_WIDTH 50 - -///< Default ramp -#define RAMP_DEF_TIME 6000000 ///< microsecs -#define RAMP_DEF_MAXFREQ 5000 ///< Hz -#define RAMP_DEF_MINFREQ 200 ///< Hz -#define RAMP_DEF_POWERRUN 10 ///< 10 deciampere (1 ampere) -#define RAMP_DEF_POWERIDLE 1 ///< 1 deciampere +#include /** @@ -114,7 +76,10 @@ */ #define FREQ2MICROS(hz) (1000000UL / ((uint32_t)(hz))) - +/** + * Multiply \p a and \p b two integer at 32 bit and extract the high 16 bit word. + */ +#define FIX_MULT32(a,b) (((uint64_t)(a)*(uint32_t)(b)) >> 16) /** * Structure holding pre-calculated data for speeding up real-time evaluation @@ -193,7 +158,9 @@ void ramp_default(struct Ramp *ramp); /** Self test */ -void ramp_test(void); +int ramp_testSetup(void); +int ramp_testRun(void); +int ramp_testTearDown(void); #endif /* ALGO_RAMP_H */