aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AT91SAM7S256/Source/c_cmd.c8
-rw-r--r--AT91SAM7S256/Source/c_cmd.h4
-rw-r--r--AT91SAM7S256/Source/c_output.c1
-rw-r--r--AT91SAM7S256/Source/c_output.iom4
-rw-r--r--AT91SAM7S256/Source/d_output.c12
-rw-r--r--AT91SAM7S256/Source/d_output.h1
6 files changed, 25 insertions, 5 deletions
diff --git a/AT91SAM7S256/Source/c_cmd.c b/AT91SAM7S256/Source/c_cmd.c
index 5370652..87b3e24 100644
--- a/AT91SAM7S256/Source/c_cmd.c
+++ b/AT91SAM7S256/Source/c_cmd.c
@@ -267,6 +267,8 @@ TYPE_CODE IO_TYPES_OUT[IO_OUT_FIELD_COUNT] =
TC_SLONG, //IO_OUT_BLOCK_TACH_COUNT
TC_SLONG, //IO_OUT_ROTATION_COUNT
TC_UBYTE, //IO_OUT_OPTIONS
+ TC_SBYTE, //IO_OUT_MAX_SPEED
+ TC_SBYTE, //IO_OUT_MAX_ACCELERATION
//IO_OUT1
TC_UBYTE, //IO_OUT_FLAGS
@@ -285,6 +287,8 @@ TYPE_CODE IO_TYPES_OUT[IO_OUT_FIELD_COUNT] =
TC_SLONG, //IO_OUT_BLOCK_TACH_COUNT
TC_SLONG, //IO_OUT_ROTATION_COUNT
TC_UBYTE, //IO_OUT_OPTIONS
+ TC_SBYTE, //IO_OUT_MAX_SPEED
+ TC_SBYTE, //IO_OUT_MAX_ACCELERATION
//IO_OUT2
TC_UBYTE, //IO_OUT_FLAGS
@@ -303,6 +307,8 @@ TYPE_CODE IO_TYPES_OUT[IO_OUT_FIELD_COUNT] =
TC_SLONG, //IO_OUT_BLOCK_TACH_COUNT
TC_SLONG, //IO_OUT_ROTATION_COUNT
TC_UBYTE, //IO_OUT_OPTIONS
+ TC_SBYTE, //IO_OUT_MAX_SPEED
+ TC_SBYTE, //IO_OUT_MAX_ACCELERATION
};
@@ -1112,6 +1118,8 @@ void cCmdInit(void* pHeader)
IO_PTRS_OUT[IO_OUT_BLOCK_TACH_COUNT + i * IO_OUT_FPP] = (void*)&(pOut->BlockTachoCount);
IO_PTRS_OUT[IO_OUT_ROTATION_COUNT + i * IO_OUT_FPP] = (void*)&(pOut->RotationCount);
IO_PTRS_OUT[IO_OUT_OPTIONS + i * IO_OUT_FPP] = (void*)&(pOut->Options);
+ IO_PTRS_OUT[IO_OUT_MAX_SPEED + i * IO_OUT_FPP] = (void*)&(pOut->MaxSpeed);
+ IO_PTRS_OUT[IO_OUT_MAX_ACCELERATION + i * IO_OUT_FPP] = (void*)&(pOut->MaxAcceleration);
}
//Initialize IO_PTRS_IN
diff --git a/AT91SAM7S256/Source/c_cmd.h b/AT91SAM7S256/Source/c_cmd.h
index 0b65764..c6e5267 100644
--- a/AT91SAM7S256/Source/c_cmd.h
+++ b/AT91SAM7S256/Source/c_cmd.h
@@ -196,9 +196,11 @@ enum
IO_OUT_BLOCK_TACH_COUNT,
IO_OUT_ROTATION_COUNT,
IO_OUT_OPTIONS,
+ IO_OUT_MAX_SPEED,
+ IO_OUT_MAX_ACCELERATION,
};
-#define IO_OUT_FPP 16
+#define IO_OUT_FPP 18
#define IO_OUT_FIELD_COUNT (IO_OUT_FPP * NO_OF_OUTPUTS)
//
diff --git a/AT91SAM7S256/Source/c_output.c b/AT91SAM7S256/Source/c_output.c
index a016361..52f7b31 100644
--- a/AT91SAM7S256/Source/c_output.c
+++ b/AT91SAM7S256/Source/c_output.c
@@ -134,6 +134,7 @@ void cOutputCtrl(void)
{
pOut->Flags &= ~UPDATE_PID_VALUES;
dOutputSetPIDParameters(Tmp, pOut->RegPParameter, pOut->RegIParameter, pOut->RegDParameter);
+ dOutputSetMax(Tmp, pOut->MaxSpeed, pOut->MaxAcceleration);
}
}
}
diff --git a/AT91SAM7S256/Source/c_output.iom b/AT91SAM7S256/Source/c_output.iom
index 09b935e..2255b9f 100644
--- a/AT91SAM7S256/Source/c_output.iom
+++ b/AT91SAM7S256/Source/c_output.iom
@@ -74,8 +74,8 @@ typedef struct
UBYTE Overloaded; /* R - True if the motor has been overloaded within speed control regulation */
SBYTE SyncTurnParameter; /* RW - Holds the turning parameter need within MoveBlock */
UBYTE Options;
- UBYTE SpareTwo;
- UBYTE SpareThree;
+ UBYTE MaxSpeed; /* RW - Maximum speed for absolute regulation, or 0 for no limit */
+ UBYTE MaxAcceleration; /* RW - Maximum acceleration for absolute regulation, or 0 for no limit */
}OUTPUT;
diff --git a/AT91SAM7S256/Source/d_output.c b/AT91SAM7S256/Source/d_output.c
index b244e8e..ca16cab 100644
--- a/AT91SAM7S256/Source/d_output.c
+++ b/AT91SAM7S256/Source/d_output.c
@@ -74,8 +74,8 @@ typedef struct
SLONG MotorRampTachoCountStart; // Used to hold position when Ramp-up started
SLONG RotationCaptureCount; // Counter for additional rotation counter
SLONG MotorTachoCountTarget; // For absolute regulation, position on which regulation is done
- SLONG MotorMaxSpeed; // For absolute regulation, maximum motor speed
- SLONG MotorMaxAcceleration; // For absolute regulation, maximum motor acceleration
+ SBYTE MotorMaxSpeed; // For absolute regulation, maximum motor speed
+ SBYTE MotorMaxAcceleration; // For absolute regulation, maximum motor acceleration
}MOTORDATA;
typedef struct
@@ -290,6 +290,14 @@ void dOutputSetPIDParameters(UBYTE MotorNr, UBYTE NewRegPParameter, UBYTE NewReg
pMD->RegDParameter = NewRegDParameter;
}
+/* Set maximum speed and acceleration */
+void dOutputSetMax(UBYTE MotorNr, SBYTE NewMaxSpeed, SBYTE NewMaxAcceleration)
+{
+ MOTORDATA * pMD = &(MotorData[MotorNr]);
+ pMD->MotorMaxSpeed = NewMaxSpeed;
+ pMD->MotorMaxAcceleration = NewMaxAcceleration;
+}
+
/* Set new regulation time */
void dOutputSetRegulationTime(UBYTE NewRegulationTime)
{
diff --git a/AT91SAM7S256/Source/d_output.h b/AT91SAM7S256/Source/d_output.h
index ca81ecf..f27204b 100644
--- a/AT91SAM7S256/Source/d_output.h
+++ b/AT91SAM7S256/Source/d_output.h
@@ -79,6 +79,7 @@ void dOutputResetTachoLimit(UBYTE MotorNr);
void dOutputResetBlockTachoLimit(UBYTE MotorNr);
void dOutputResetRotationCaptureCount(UBYTE MotorNr);
void dOutputSetPIDParameters(UBYTE MotorNr, UBYTE NewRegPParameter, UBYTE NewRegIParameter, UBYTE NewRegDParameter);
+void dOutputSetMax(UBYTE MotorNr, SBYTE NewMaxSpeed, SBYTE NewMaxAcceleration);
void dOutputSetRegulationTime(UBYTE NewRegulationTime);
void dOutputSetRegulationOptions(UBYTE NewRegulationOptions);