离合初试

This commit is contained in:
ws 2025-03-14 23:57:48 +08:00
parent d56405a1ba
commit 83a9c93e16
7 changed files with 73 additions and 49 deletions

View File

@ -17,6 +17,8 @@
"shoot.h": "c",
"dji.h": "c",
"calc_lib.h": "c",
"odrive_shoot.h": "c"
"odrive_shoot.h": "c",
"remote_control.h": "c",
"dji_task.h": "c"
}
}

View File

@ -1,10 +1,3 @@
*** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
Build target 'mycode1'
compiling read_spi.c...
compiling odrive_shoot.c...
compiling shoot_task.c...
linking...
Program Size: Code=26528 RO-data=1904 RW-data=280 ZI-data=22496
FromELF: creating hex file...
"mycode1\mycode1.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:03
Load "mycode1\\mycode1.axf"
Erase Done.Programming Done.Verify OK.Application running ...
Flash Load finished at 22:03:22

View File

@ -1 +1 @@
2025/3/14 20:41:26
2025/3/14 22:03:23

View File

@ -208,37 +208,27 @@
<Ww>
<count>11</count>
<WinNumber>1</WinNumber>
<ItemText>angleo,0x0A</ItemText>
<ItemText>encoder,0x0A</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>shoot</ItemText>
<ItemText>mode,0x0A</ItemText>
</Ww>
<Ww>
<count>13</count>
<WinNumber>1</WinNumber>
<ItemText>multi_turn_angle,0x0A</ItemText>
<ItemText>m</ItemText>
</Ww>
<Ww>
<count>14</count>
<WinNumber>1</WinNumber>
<ItemText>angle_encoder</ItemText>
<ItemText>trigger_motor_data,0x0A</ItemText>
</Ww>
<Ww>
<count>15</count>
<WinNumber>1</WinNumber>
<ItemText>back_angle,0x0A</ItemText>
</Ww>
<Ww>
<count>16</count>
<WinNumber>1</WinNumber>
<ItemText>encoder,0x0A</ItemText>
</Ww>
<Ww>
<count>17</count>
<WinNumber>1</WinNumber>
<ItemText>angles</ItemText>
<ItemText>trigger_angle_o</ItemText>
</Ww>
</WatchWindow1>
<WatchWindow2>
@ -322,7 +312,7 @@
<Group>
<GroupName>Application/User/Core</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -5,22 +5,26 @@
#include <cmsis_os2.h>
#include "remote_control.h"
#include "dji.h"
#include "read_spi.h"
#include "vofa.h"
extern RC_mess_t RC_mess;
extern int16_t result;
extern int16_t t_result;
extern motor_measure_t *motor_3508_data;
extern motor_measure_t *trigger_motor_data;
Encoder_t encoder;
float vofa[8];
int speed=0;
float m=0;
float trigger_angle_o=0;
int mode=0;
/**
* \brief
*
* \param argument 使
*/
int speed=0;
float angle=0;
float m;
void Task_Motor(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
@ -28,6 +32,7 @@ void Task_Motor(void *argument)
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_CHASSIS;
motor_init();
Encoder_Init(&encoder);
uint32_t tick = osKernelGetTickCount();
@ -35,12 +40,28 @@ void Task_Motor(void *argument)
{
//收到消息队列新数据
//电机控制
//motor_speed(speed);
m=angle*(8191/360);
// motor_pos(m);
trigger_pos(m);
//CAN_cmd_200(result[MOTOR_UP],result[MOTOR_UP],result[MOTOR_UP],result[MOTOR_UP],&hcan1);
// 更新编码器数据
Update_Encoder(&encoder);
m=trigger_angle_o*(8191/360);
if( mode == THREE )
{
//当最高点时进入离合
if(encoder.round_cnt>=8)
{
trigger_angle_o=-1;
trigger_pos(m);
}
}
else if( mode == DZ )
{
//退出离合
trigger_angle_o=0;
trigger_pos(m);
}
CAN_cmd_200(t_result,0,0,0,&hcan1);
osDelay(2);

View File

@ -2,4 +2,7 @@
#define _DJI_TASK_H_
#define THREE 3
#define DZ 0
#endif

View File

@ -7,20 +7,27 @@
#include "shoot.h"
#include "odrive_shoot.h"
#include "read_spi.h"
#include "dji_task.h"
extern RC_mess_t RC_mess;
Encoder_t encoder;
double angles;
int32_t rounds;
int angleo = 0; //发射角度
extern Encoder_t encoder;
extern motor_measure_t *trigger_motor_data;//3508电机数据
extern int mode;
#define GO1_SHOOT 0
#define ODRIVE_SHOOT 1
//odrive发射
#define SHOOT3 12
#define TOP 8
#define MIDDLE 4
#define BOTTOM 0
void Task_Shoot(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
Encoder_Init(&encoder);
#if GO1_SHOOT == 1
shooterInit();
#endif
@ -34,12 +41,20 @@ void Task_Shoot(void *argument)
shoot_ball(0);
#elif ODRIVE_SHOOT == 1
shootStep();
//shoot_odrive(angleo);
#endif
// 更新编码器数据
Update_Encoder(&encoder);
if(mode == THREE)
{
shoot_odrive(SHOOT3);
}
else if(mode == DZ)
{
if(trigger_motor_data->total_angle ==0)//扳机已闭合
{
shoot_odrive(BOTTOM);
}
}
#endif
tick += delay_tick; /* 计算下一个唤醒时刻 */
osDelayUntil(tick); /* 运行结束,等待下一个周期唤醒 */
}