From ba78bd9ba834260d035a9830726afc34fdad2a15 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sun, 18 Oct 2009 23:32:54 +0200 Subject: import firmware from LEGO v1.05 --- AT91SAM7S256/Source/d_output.h | 90 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 AT91SAM7S256/Source/d_output.h (limited to 'AT91SAM7S256/Source/d_output.h') diff --git a/AT91SAM7S256/Source/d_output.h b/AT91SAM7S256/Source/d_output.h new file mode 100644 index 0000000..cb0de5e --- /dev/null +++ b/AT91SAM7S256/Source/d_output.h @@ -0,0 +1,90 @@ +// +// Date init 14.12.2004 +// +// Revision date $Date:: 16-05-06 12:13 $ +// +// Filename $Workfile:: d_output.h $ +// +// Version $Revision:: 48 $ +// +// Archive $Archive:: /LMS2006/Sys01/Main/Firmware/Source/d_output.h $ +// +// Platform C +// + +#ifndef D_OUTPUT +#define D_OUTPUT + +#define NEW_MOTOR + +#ifdef NEW_MOTOR + +//Constant reffering to new motor +#define REG_CONST_DIV 32 // Constant which the PID constants value will be divided with +#define DEFAULT_P_GAIN_FACTOR 96//3 +#define DEFAULT_I_GAIN_FACTOR 32//1 +#define DEFAULT_D_GAIN_FACTOR 32//1 +#define MIN_MOVEMENT_POWER 10 +#define MAX_CAPTURE_COUNT 100 + +#else + +//Constant reffering to Old motor +#define REG_CONST_DIV 1 // Constant which the PID constants value will be divided with +#define DEFAULT_P_GAIN_FACTOR 3 +#define DEFAULT_I_GAIN_FACTOR 1 +#define DEFAULT_D_GAIN_FACTOR 1 +#define MIN_MOVEMENT_POWER 30 +#define MAX_CAPTURE_COUNT 80 + +#endif + +//Constant reffering to RegMode parameter +#define REGSTATE_IDLE 0x00 +#define REGSTATE_REGULATED 0x01 +#define REGSTATE_SYNCHRONE 0x02 + +//Constant reffering to RunState parameter +#define MOTOR_RUN_STATE_IDLE 0x00 +#define MOTOR_RUN_STATE_RAMPUP 0x10 +#define MOTOR_RUN_STATE_RUNNING 0x20 +#define MOTOR_RUN_STATE_RAMPDOWN 0x40 +#define MOTOR_RUN_STATE_HOLD 0x60 + + +enum +{ + MOTOR_A, + MOTOR_B, + MOTOR_C +}; + +void dOutputInit(void); +void dOutputExit(void); + +void dOutputCtrl(void); +void dOutputGetMotorParameters(UBYTE *CurrentMotorSpeed, SLONG *TachoCount, SLONG *BlockTachoCount, UBYTE *RunState, UBYTE *MotorOverloaded, SLONG *RotationCount); +void dOutputSetMode(UBYTE Motor, UBYTE Mode); +void dOutputSetSpeed (UBYTE MotorNr, UBYTE NewMotorRunState, SBYTE Speed, SBYTE TurnParameter); +void dOutputEnableRegulation(UBYTE Motor, UBYTE RegulationMode); +void dOutputDisableRegulation(UBYTE Motor); +void dOutputSetTachoLimit(UBYTE Motor, ULONG TachoCntToTravel); +void dOutputResetTachoLimit(UBYTE Motor); +void dOutputResetBlockTachoLimit(UBYTE Motor); +void dOutputResetRotationCaptureCount(UBYTE MotorNr); +void dOutputSetPIDParameters(UBYTE Motor, UBYTE NewRegPParameter, UBYTE NewRegIParameter, UBYTE NewRegDParameter); + +void dOutputRegulateMotor(UBYTE MotorNr); +void dOutputCalculateRampUpParameter(UBYTE MotorNr, ULONG NewTachoLimit); +void dOutputRampDownFunction(UBYTE MotorNr); +void dOutputRampUpFunction(UBYTE MotorNr); +void dOutputTachoLimitControl(UBYTE MotorNr); +void dOutputCalculateMotorPosition(UBYTE MotorNr); +void dOutputSyncMotorPosition(UBYTE MotorOne, UBYTE MotorTwo); +void dOutputMotorReachedTachoLimit(UBYTE MotorNr); +void dOutputMotorIdleControl(UBYTE MotorNr); +void dOutputSyncTachoLimitControl(UBYTE MotorNr); +void dOutputMotorSyncStatus(UBYTE MotorNr, UBYTE *SyncMotorOne, UBYTE *SyncMotorTwo); +void dOutputResetSyncMotors(UBYTE MotorNr); + +#endif -- cgit v1.2.3