Added small fixes, also added beeber. Beeber dont seem to work needs fixing.
This commit is contained in:
parent
84b3a729e1
commit
7333665fc6
@ -122,8 +122,8 @@ typedef enum
|
|||||||
#if defined(BARO) || defined(SONAR)
|
#if defined(BARO) || defined(SONAR)
|
||||||
TASK_ALTITUDE,
|
TASK_ALTITUDE,
|
||||||
#endif
|
#endif
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
TASK_BEEPER
|
TASK_BEEPER,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Debug tasks, ONLY to be used when testing
|
//Debug tasks, ONLY to be used when testing
|
||||||
|
@ -174,7 +174,7 @@ typedef enum {
|
|||||||
#if defined(BARO) || defined(SONAR)
|
#if defined(BARO) || defined(SONAR)
|
||||||
EEPROM_PERIOD_ALTITUDE,
|
EEPROM_PERIOD_ALTITUDE,
|
||||||
#endif
|
#endif
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
EEPROM_PERIOD_BEEPER,
|
EEPROM_PERIOD_BEEPER,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
19
UAV-ControlSystem/inc/drivers/beeper.h
Normal file
19
UAV-ControlSystem/inc/drivers/beeper.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* beeper.h
|
||||||
|
*
|
||||||
|
* Created on: 14 nov. 2016
|
||||||
|
* Author: holmis
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DRIVERS_BEEPER_H_
|
||||||
|
#define DRIVERS_BEEPER_H_
|
||||||
|
|
||||||
|
#include "stm32f4xx_revo.h"
|
||||||
|
|
||||||
|
void initBeeper(uint16_t led_pin, GPIO_TypeDef* led_port);
|
||||||
|
|
||||||
|
void busyWaitBeep(uint16_t beepTimeMs);
|
||||||
|
|
||||||
|
#endif /* DRIVERS_BEEPER_H_ */
|
||||||
|
|
||||||
|
|
@ -156,8 +156,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Beeper */
|
/* Beeper */
|
||||||
//#define BEEPER
|
#define BEEPER
|
||||||
|
#define BEEPER_PIN 12
|
||||||
|
#define BEEPER_PORT GPIOB
|
||||||
|
|
||||||
|
|
||||||
/* Define all the moter of the system, servos + extra */
|
/* Define all the moter of the system, servos + extra */
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#ifndef SYSTEM_VARIABLES_H_
|
#ifndef SYSTEM_VARIABLES_H_
|
||||||
#define SYSTEM_VARIABLES_H_
|
#define SYSTEM_VARIABLES_H_
|
||||||
|
|
||||||
#define EEPROM_SYS_VERSION 109
|
#define EEPROM_SYS_VERSION 110
|
||||||
|
|
||||||
#define ADC_STATE
|
#define ADC_STATE
|
||||||
#include "stm32f4xx.h"
|
#include "stm32f4xx.h"
|
||||||
|
@ -359,7 +359,7 @@ void initSchedulerTasks(void)
|
|||||||
enableTask(TASK_ALTITUDE, true);
|
enableTask(TASK_ALTITUDE, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
enableTask(TASK_BEEPER, true);
|
enableTask(TASK_BEEPER, true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ typedef enum
|
|||||||
#if defined(BARO) || defined(SONAR)
|
#if defined(BARO) || defined(SONAR)
|
||||||
COMMAND_ID_PERIOD_ALTITUDE,
|
COMMAND_ID_PERIOD_ALTITUDE,
|
||||||
#endif
|
#endif
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
COMMAND_ID_PERIOD_BEEPER,
|
COMMAND_ID_PERIOD_BEEPER,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ const cliCommandConfig_t commandTable[COMMAND_ID_COUNT] = {
|
|||||||
"task_period_altitude", COMMAND_ID_PERIOD_ALTITUDE, EEPROM_PERIOD_ALTITUDE, EEPROM_VALUE_TYPE_SYSTEM, 0, VAL_UINT_32, .valueRange = {0, 1000000000}
|
"task_period_altitude", COMMAND_ID_PERIOD_ALTITUDE, EEPROM_PERIOD_ALTITUDE, EEPROM_VALUE_TYPE_SYSTEM, 0, VAL_UINT_32, .valueRange = {0, 1000000000}
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
[COMMAND_ID_PERIOD_BEEPER] =
|
[COMMAND_ID_PERIOD_BEEPER] =
|
||||||
{
|
{
|
||||||
"task_period_beeper", COMMAND_ID_PERIOD_BEEPER, EEPROM_PERIOD_BEEPER, EEPROM_VALUE_TYPE_SYSTEM, 0, VAL_UINT_32, .valueRange = {0, 1000000000}
|
"task_period_beeper", COMMAND_ID_PERIOD_BEEPER, EEPROM_PERIOD_BEEPER, EEPROM_VALUE_TYPE_SYSTEM, 0, VAL_UINT_32, .valueRange = {0, 1000000000}
|
||||||
|
@ -189,7 +189,7 @@ EEPROM_DATA_t eeprom_sys_Arr[EEPROM_SYS_COUNT] = {
|
|||||||
.dataPtr = &(SystemTasks[TASK_ALTITUDE].desiredPeriod),
|
.dataPtr = &(SystemTasks[TASK_ALTITUDE].desiredPeriod),
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
[EEPROM_PERIOD_BEEPER] =
|
[EEPROM_PERIOD_BEEPER] =
|
||||||
{
|
{
|
||||||
.size = sizeof(SystemTasks[TASK_BEEPER].desiredPeriod),
|
.size = sizeof(SystemTasks[TASK_BEEPER].desiredPeriod),
|
||||||
|
34
UAV-ControlSystem/src/drivers/beeper.c
Normal file
34
UAV-ControlSystem/src/drivers/beeper.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* beeper.c
|
||||||
|
*
|
||||||
|
* Created on: 14 nov. 2016
|
||||||
|
* Author: holmis
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "drivers/beeper.h"
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t beeperPin;
|
||||||
|
GPIO_TypeDef* beeperPort;
|
||||||
|
|
||||||
|
void initBeeper(uint16_t led_pin, GPIO_TypeDef* led_port)
|
||||||
|
{
|
||||||
|
beeperPin = led_pin;
|
||||||
|
beeperPort = led_port;
|
||||||
|
|
||||||
|
GPIO_InitTypeDef gpinit;
|
||||||
|
gpinit.Pin = led_pin;
|
||||||
|
gpinit.Mode = GPIO_MODE_OUTPUT_OD;
|
||||||
|
gpinit.Pull = GPIO_NOPULL;
|
||||||
|
gpinit.Speed = GPIO_SPEED_HIGH;
|
||||||
|
HAL_GPIO_Init(led_port, &gpinit);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void busyWaitBeep(uint16_t beepTimeMs)
|
||||||
|
{
|
||||||
|
/* If you use this in the scheduled part of the code, you might face a problem with a little bit of a crash ok? */
|
||||||
|
HAL_GPIO_WritePin(beeperPort, beeperPin, SET);
|
||||||
|
HAL_Delay(beepTimeMs);
|
||||||
|
HAL_GPIO_WritePin(beeperPort, beeperPin, RESET);
|
||||||
|
}
|
@ -74,17 +74,30 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
static const motorMixer_s mixerUAV[] = {
|
static const motorMixer_s mixerUAV[] = {
|
||||||
/* Throttle, Roll, Pitch, Yaw */
|
/* Throttle, Roll, Pitch, Yaw */
|
||||||
|
//
|
||||||
|
// { 1.0f, 1.0f, 1.0f, -1.0f}, //M1
|
||||||
|
// { 1.0f, 1.0f, 1.0f, 1.0f}, //M2
|
||||||
|
// { 1.0f, 0.0f, 1.0f, 0.0f}, //M3
|
||||||
|
// { 1.0f, 0.0f, 1.0f, 0.0f}, //M4
|
||||||
|
// { 1.0f, -1.0f, 1.0f, 1.0f}, //M5
|
||||||
|
// { 1.0f, -1.0f, 1.0f, -1.0f}, //M6
|
||||||
|
// { 1.0f, 1.0f, -1.0f, 1.0f}, //M7
|
||||||
|
// { 1.0f, 1.0f, -1.0f, -1.0f}, //M8
|
||||||
|
// { 1.0f, -1.0f, -1.0f, -1.0f}, //M9
|
||||||
|
// { 1.0f, -1.0f, -1.0f, 1.0f}, //M10
|
||||||
|
|
||||||
{ 1.0f, 1.0f, 1.0f, -1.0f}, //M1
|
|
||||||
{ 1.0f, 1.0f, 1.0f, 1.0f}, //M2
|
|
||||||
{ 1.0f, 0.0f, 1.0f, 0.0f}, //M3
|
{ 1.0f, 1.0f, 1.0f, -1.0f}, //M1
|
||||||
{ 1.0f, 0.0f, 1.0f, 0.0f}, //M4
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M2
|
||||||
{ 1.0f, -1.0f, 1.0f, 1.0f}, //M5
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M3
|
||||||
{ 1.0f, -1.0f, 1.0f, -1.0f}, //M6
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M4
|
||||||
{ 1.0f, 1.0f, -1.0f, 1.0f}, //M7
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M5
|
||||||
{ 1.0f, 1.0f, -1.0f, -1.0f}, //M8
|
{ 1.0f, -1.0f, 1.0f, -1.0f}, //M6
|
||||||
{ 1.0f, -1.0f, -1.0f, -1.0f}, //M9
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M7
|
||||||
{ 1.0f, -1.0f, -1.0f, 1.0f}, //M10
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M8
|
||||||
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M9
|
||||||
|
{ 0.0f, 0.0f, 0.0f, 0.0f}, //M10
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -183,7 +196,11 @@ void mix()
|
|||||||
// Now we add desired throttle
|
// Now we add desired throttle
|
||||||
for (int i = 0; i < MOTOR_COUNT; i++)
|
for (int i = 0; i < MOTOR_COUNT; i++)
|
||||||
// Constrain in within the regulation of the mix - OBS. Constrain can be removed. Just to make sure
|
// Constrain in within the regulation of the mix - OBS. Constrain can be removed. Just to make sure
|
||||||
motor_output[i] = RPY_Mix[i] + constrain(throttle * mixerUAV[i].throttle, throttleMin, throttleMax);
|
|
||||||
|
// TODO: This line is backup as we discovered that motors could stop at times in airmode on M-UAV. But we have not seen this before
|
||||||
|
//motor_output[i] = RPY_Mix[i] + constrain(throttle * mixerUAV[i].throttle, throttleMin, throttleMax);
|
||||||
|
motor_output[i] = constrain(RPY_Mix[i] + constrain(throttle * mixerUAV[i].throttle, throttleMin, throttleMax), throttleMin, throttleMax);
|
||||||
|
|
||||||
}
|
}
|
||||||
else // Mixer full scale NOT active
|
else // Mixer full scale NOT active
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "drivers/motors.h"
|
#include "drivers/motors.h"
|
||||||
#include "Flight/pid.h"
|
#include "Flight/pid.h"
|
||||||
#include "drivers/barometer.h"#include "drivers/arduino_com.h"
|
#include "drivers/barometer.h"#include "drivers/arduino_com.h"
|
||||||
|
#include "drivers/beeper.h"
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* BRIEF: Should contain all the initializations of the system, needs to
|
* BRIEF: Should contain all the initializations of the system, needs to
|
||||||
@ -96,8 +97,8 @@ void init_system()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BEEPER
|
#ifdef BEEPER
|
||||||
|
initBeeper(BEEPER_PIN, BEEPER_PORT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -120,6 +121,9 @@ int main(void)
|
|||||||
//Light the yellow led
|
//Light the yellow led
|
||||||
ledOnInverted(Led1, Led1_GPIO_PORT);
|
ledOnInverted(Led1, Led1_GPIO_PORT);
|
||||||
|
|
||||||
|
//beep that it has been initialized
|
||||||
|
busyWaitBeep(1000);
|
||||||
|
|
||||||
//Initialize the scheduler, add all the tasks that should run to the ready queue of the scheduler
|
//Initialize the scheduler, add all the tasks that should run to the ready queue of the scheduler
|
||||||
initScheduler();
|
initScheduler();
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "drivers/motormix.h"
|
#include "drivers/motormix.h"
|
||||||
#include "Flight/pid.h"
|
#include "Flight/pid.h"
|
||||||
#include "drivers/barometer.h"
|
#include "drivers/barometer.h"
|
||||||
|
#include "drivers/beeper.h"
|
||||||
|
|
||||||
void systemTaskGyroPid(void)
|
void systemTaskGyroPid(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user