TW的硬件一直很强,这是难得的硬件创新比赛的优秀作品,资料非常完整理。
硬件设计,源码,项目计划书,甚至包含了事后的复盘总结文档。
是不可多得的好资料。
项目系统框架图
1. 硬件系统框架图 (请以方块图形式呈现)
2. 软件系统框架图 (以文字或方块图表示算法流程)
- 项目设计预计效果
- 六軸機械手臂運動控制
-
需使用六塊 Servo Motion controller
方塊圖如下:
-
使用PC 做為主控台, 在PC端產生各軸的位置透過RS-485 下達命令做多軸運動控制
PC 人機介面規劃如下:
-
VT100 terminal 報文輸出
系統會由COM1 (115200,n,8,1) 輸出 VT100 格式化文字如下畫面 - 多軸接線圖
部份代码:
#include <stdio.h>
#include <string.h>
#include "define.h"
#include "MultiTask.h"
#include "M451Series.h"
#include "sysclk.h"
#include "uart0.h"
#include "uart1.h"
#include "pwm.h"
#include "adc.h"
#include "eint.h"
#include "flash.h"
#include "adc_ctrl.h"
#include "TemFunction.h"
#include "VT100.H"enum {COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_YELLOW, COLOR_CYAN,COLOR_MAGENTA, COLOR_GRAY, COLOR_WHITE, COLOR_BLACK, COLOR_DGRAY,COLOR_DYELLOW, COLOR_DGREEN, COLOR_DRED,BCOLOR_YELLOW, BCOLOR_GREEN, BCOLOR_RED, COLOR_DBLUE};
typedef unsigned char* Uptr;
extern unsigned long g_ulFlags ;
//"FAULT xLINK oLINK SERVO_o CAN_o UART_o VCOMP_m CURRENTm SPEED_m POSITIONm";
// SP_ENC SP_iENC SP_qENC POS_ENC POS_POT POWERsts HALTED";
#define STATE_WAIT_FOR_LINK 0
#define STATE_RUN 1
#define STATE_FAULT 2
extern unsigned long g_ulControllerState;
//extern unsigned long g_ulMessageState;
extern long g_usEncoderCount; // encoder counter
extern unsigned long g_ulEncoderLines;
extern unsigned long MsgIdxNum;
//----------------------------------------------------------
extern void UART0IntHandler(void);
extern void CAN0IntHandler(void);
extern void ControllerIntHandler(void);
extern void TaskCanDataReceive(void);
extern unsigned long g_ulFlags;typedef struct
{ uint32_t id;uint8_t t1;uint8_t t2;uint8_t t3;uint8_t t4;
} STR_FLASH_T;STR_FLASH_T test;
void DiaplayInitial(void);
void DebugReport(void);
extern long g_lHBridgeV ;
int PwmCounter ;
void Initial_IoPort(void)
{// SETUP UARTUART0_Init(COM_485_BAUD);UART1_Init(COM_232_BAUD); // debug port // SETUP PWMPWM_Init_PA3_PWM1CH2();PF->bMODE.MODE2 = 1; // PF2 Output Mode Mode LED_GPF->bMODE.MODE1 = 1; // PF1 Output Mode Mode LED_RPB->bMODE.MODE6 = 1; // PB6 Output Mode Motor_CW PB->bMODE.MODE7 = 1; // PB7 Output Mode Motor_CCW PB->bMODE.MODE3 = 0; // PB3 input mode Limit switchPB->bMODE.MODE4 = 0; // PB4 input mode Limit switchPB->bMODE.MODE5 = 0; // PB5 input mode Config SwitchPC->bMODE.MODE1 = 0; // PC1 input mode Home switchPC->bMODE.MODE9 = 3; // Quasi-bidirectional Mode // SETUP ADCADC_Init_PB0PB1PB2();// SETUP EINTEINT_Init_PC0PF0(); pwm_out(0);
}
//-----------------------------------------------------------------------------------
void CallBootloader(void)
{}//-----------------------------------------------------------
//software Watch dog simulation
//-----------------------------------------------------------//-----------------------------------------------------------------------
//software watchdog for reset the linking status
//------------------------------------------------------------------------
unsigned int WatchDogCnt;
void WatchdogIntHandler(void)
{WatchDogCnt++;if (WatchDogCnt > 200) // for 100mS{WatchDogCnt = 0;ControllerLinkLost(LINK_TYPE_NONE);}
}
资源分享:
六轴机器手臂运动控制-直流伺服反馈系统设计(比赛项目计划书+设计总结+硬件+源代码+上位机等)