Re-Worked exercise 3
This commit is contained in:
21
src/APP/Aufgabe3/ps7/core0/cfg/pid.h
Normal file
21
src/APP/Aufgabe3/ps7/core0/cfg/pid.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* pid.h
|
||||||
|
*
|
||||||
|
* Created on: Jan 28, 2019
|
||||||
|
* Author: laurenzb
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_
|
||||||
|
#define SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_
|
||||||
|
|
||||||
|
#define PID_BOUND 1000 //Restrict PID Value in [-1000,1000]
|
||||||
|
#define PI 3.14159265
|
||||||
|
|
||||||
|
int pid_Init(void *pdata);
|
||||||
|
int16_t pid_Constrain(int16_t value, int16_t lowerBorder, int16_t higherBorder);
|
||||||
|
int pid_Task(void *pdata);
|
||||||
|
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_ */
|
||||||
@@ -10,10 +10,19 @@
|
|||||||
#ifndef SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_
|
#ifndef SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_
|
||||||
#define SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_
|
#define SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_
|
||||||
|
|
||||||
|
#define MIN_PWM_FREQ 20
|
||||||
|
#define MOTOR_ID_LEFT 0
|
||||||
|
#define MOTOR_ID_RIGHT 1
|
||||||
|
#define MOTOR_MIN_SPEED 12345
|
||||||
|
#define MOTOR_MAX_SPEED 12345
|
||||||
|
|
||||||
//Dummy-Define for Excercise 3 only, there is no PID yet
|
//Dummy-Define for Excercise 3 only, there is no PID yet
|
||||||
#ifndef PID_BOUND
|
#ifndef PID_BOUND
|
||||||
#define PID_BOUND 1000
|
#define PID_BOUND 1000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int timer_Task(void *pdata);
|
||||||
|
int timer_Init();
|
||||||
|
|
||||||
#endif /* SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_ */
|
#endif /* SRC_APP_AUFGABE3_PS7_CORE0_CFG_TTC_TIMER_H_ */
|
||||||
|
|||||||
@@ -12,26 +12,66 @@
|
|||||||
#include "ucos_int.h"
|
#include "ucos_int.h"
|
||||||
#include "ttc_timer.h"
|
#include "ttc_timer.h"
|
||||||
#include "xgpiops.h"
|
#include "xgpiops.h"
|
||||||
|
#include "pid.h"
|
||||||
|
|
||||||
|
|
||||||
#define TTC_PWM_INTR_ID XPAR_XTTCPS_0_INTR
|
|
||||||
|
|
||||||
|
|
||||||
int timer_Init(void *pdata);
|
static void timer_Start(uint32_t Id);
|
||||||
|
static void timer_Stop(uint32_t Id);
|
||||||
|
static void timer_Set_Interval_Length(uint32_t Id, uint16_t intervalLength);
|
||||||
|
static int timer_Dual_Timer_Setup(void);
|
||||||
|
static int timer_Setup(int DeviceID);
|
||||||
|
static void motor_Set_Steering_Direction(uint8_t steeringDirection, int16_t *motorPower);
|
||||||
|
static void motor_Set_Moving_Direction (u32 pin, int16_t value);
|
||||||
static void timer_gpio_Init();
|
static void timer_gpio_Init();
|
||||||
static void intervalHandler(void *CallBackRef);
|
|
||||||
|
|
||||||
|
int timer_Task(void *pdata) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * intializes and starts two timers with respective puls generation on gpio pins * * */
|
||||||
int timer_Init(void *pdata){
|
int timer_Init(void *pdata){
|
||||||
UCOS_Print("Setting up Timer!\r\n");
|
UCOS_Print("Setting up Timer!\r\n");
|
||||||
UCOS_Print("Done!\r\n");
|
UCOS_Print("Done!\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * checks the desired moving direction and sets the direction pin for the steppers * * */
|
||||||
|
static void motor_Set_Moving_Direction (uint32_t pin, int16_t value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * init gpio, connects IRQ to gpio * * */
|
||||||
static void timer_gpio_Init(){
|
static void timer_gpio_Init(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * * * * sets up two timers by calling timer_Setup() for each wheel, connects and activates an interrupt to one of timers * * */
|
||||||
|
static int timer_Dual_Timer_Setup(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * * * * sets up a timer counter device, initialize device, set options, set interval and prescaler value for given output frequency * * */
|
||||||
|
static int timer_Setup(int DeviceID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * starts timer number "Id" * * */
|
||||||
|
static void timer_Start(uint32_t Id){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* * * stops timer number "Id" * * */
|
||||||
|
static void timer_Stop(uint32_t Id){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void intervalHandler(void *CallBackRef){
|
/* * * sets new interval length and the correct matchvalue * * */
|
||||||
|
static void timer_Set_Interval_Length(uint32_t Id, uint16_t interval_length){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* pid.h
|
|
||||||
*
|
|
||||||
* Created on: Jan 28, 2019
|
|
||||||
* Author: laurenzb
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_
|
|
||||||
#define SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_
|
|
||||||
|
|
||||||
#define PID_BOUND 1000 //Restrict PID Value in [-1000,1000]
|
|
||||||
#define PI 3.14159265
|
|
||||||
|
|
||||||
int pid_Init(void *pdata);
|
|
||||||
int16_t pid_Constrain(int16_t value, int16_t lowerBorder, int16_t higherBorder);
|
|
||||||
int pid_Task(void *pdata);
|
|
||||||
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_APP_AUFGABE7_PS7_CORE0_CFG_PID_H_ */
|
|
||||||
1
src/APP/Aufgabe7/ps7/core0/cfg/pid.h
Symbolic link
1
src/APP/Aufgabe7/ps7/core0/cfg/pid.h
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../Aufgabe3/ps7/core0/cfg/pid.h
|
||||||
Reference in New Issue
Block a user