单片机(8bit)的16路舵机调速分析与实现
时间:11-18
来源:互联网
点击:
- gle[g_readyBufferIndex][ROBOT_RIGHT_SHOULDER_VERTICAL];
- g_diffAngle[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_SHOULDER_HORIZEN]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_SHOULDER_HORIZEN];
- g_diffAngle[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_ELBOW]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_ELBOW];
- g_diffAngle[PIN_GROUP_1][ROBOT_PIN_INDEX_LEFT_HIP_VERTICAL]=g_angle[g_readyBufferIndex][ROBOT_LEFT_HIP_VERTICAL];
- g_diffAngle[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_HIP_VERTICAL]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_HIP_VERTICAL];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_HIP_HORIZEN]=g_angle[g_readyBufferIndex][ROBOT_LEFT_HIP_HORIZEN];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_KNEE]=g_angle[g_readyBufferIndex][ROBOT_LEFT_KNEE];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_ANKLE]=g_angle[g_readyBufferIndex][ROBOT_LEFT_ANKLE];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_FOOT]=g_angle[g_readyBufferIndex][ROBOT_LEFT_FOOT];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_HIP_HORIZEN]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_HIP_HORIZEN];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_KNEE]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_KNEE];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_ANKLE]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_ANKLE];
- g_diffAngle[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_FOOT]=g_angle[g_readyBufferIndex][ROBOT_RIGHT_FOOT];
- //复位舵机管脚索引
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_LEFT_SHOULDER_VERTICAL]=ROBOT_PIN_MASK_LEFT_SHOULDER_VERTICAL;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_LEFT_SHOULDER_HORIZEN]=ROBOT_PIN_MASK_LEFT_SHOULDER_HORIZEN;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_LEFT_ELBOW]=ROBOT_PIN_MASK_LEFT_ELBOW;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_SHOULDER_VERTICAL]=ROBOT_PIN_MASK_RIGHT_SHOULDER_VERTICAL;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_SHOULDER_HORIZEN]=ROBOT_PIN_MASK_RIGHT_SHOULDER_HORIZEN;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_ELBOW]=ROBOT_PIN_MASK_RIGHT_ELBOW;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_LEFT_HIP_VERTICAL]=ROBOT_PIN_MASK_LEFT_HIP_VERTICAL;
- g_diffAngleMask[PIN_GROUP_1][ROBOT_PIN_INDEX_RIGHT_HIP_VERTICAL]=ROBOT_PIN_MASK_RIGHT_HIP_VERTICAL;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_HIP_HORIZEN]=ROBOT_PIN_MASK_LEFT_HIP_HORIZEN;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_KNEE]=ROBOT_PIN_MASK_LEFT_KNEE;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_ANKLE]=ROBOT_PIN_MASK_LEFT_ANKLE;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_LEFT_FOOT]=ROBOT_PIN_MASK_LEFT_FOOT;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_HIP_HORIZEN]=ROBOT_PIN_MASK_RIGHT_HIP_HORIZEN;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_KNEE]=ROBOT_PIN_MASK_RIGHT_KNEE;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_ANKLE]=ROBOT_PIN_MASK_RIGHT_ANKLE;
- g_diffAngleMask[PIN_GROUP_2][ROBOT_PIN_INDEX_RIGHT_FOOT]=ROBOT_PIN_MASK_RIGHT_FOOT;
- }
- #definePWM_STEERING_ENGINE(group)\
- {\
- counter=STEERING_ENGINE_INIT_DELAY;\
- for(i=0;i<8;++i)\
- counter+=g_diffAngle[PIN_GROUP_##group][i];\
- \
- for(i=0;i<30;++i)\
- {\
- GROUP_##group##_CONTROL_PIN=0xFF;\
- Delay10us(STEERING_ENGINE_INIT_DELAY);\
- \
- for(j=0;j<8;++j)\
- {\
- Delay10us(g_diffAngle[PIN_GROUP_##group][j]);\
- GROUP_##group##_CONTROL_PIN&=~(g_diffAngleMask[PIN_GROUP_##group][j]);\
- }\
- \
- Delay10us(STEERING_ENGINE_CYCLE-counter);\
- }\
- }
- voidmain()
- {
- UCHAR8i;
- UCHAR8j;
- UINT16counter;
- InitSerialPort();
- P1=0xFF;
- //初始化舵机角度
- for(i=0;i
- {
- g_angle[0][i]=45;
- g_angle[1][i]=45;
- }
- for(i=0;i
- for(j=0;j<8;++j)
- g_diffAngle[i][j]=0;
- FillDiffAngle();
- InitPwmPollint();
- while(1)
- {
- #ifdefDEBUG_PROTOCOL
- if(g_fillingBufferIndex)
- {
- P11=0;
- P10=1;
- }
- else
- {
- P11=1;
- P10=0;
- }
- if(g_swapBuffer)
- P12=0;
- else
- P12=1;
- #endif
- if(g_swapBuffer)
- {
- FillDiffAngle();
- g_swapBuffer=FALSE;
- InitPwmPollint();
- }
单片机1舵机调 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)