电机的控制原理

上传人:xzh****18 文档编号:50621803 上传时间:2018-08-09 格式:PPT 页数:21 大小:1.70MB
返回 下载 相关 举报
电机的控制原理_第1页
第1页 / 共21页
电机的控制原理_第2页
第2页 / 共21页
电机的控制原理_第3页
第3页 / 共21页
电机的控制原理_第4页
第4页 / 共21页
电机的控制原理_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《电机的控制原理》由会员分享,可在线阅读,更多相关《电机的控制原理(21页珍藏版)》请在金锄头文库上搜索。

1、【君悦智控】http:/RobotC电机的控制原理【君悦智控】 http:/RobotC电机控制板【君悦智控】http:/RobotC【君悦智控】http:/RobotC0.5ms8; OCR1AL=SteeringMotor1Data; uiTimeCnt=SteeringMotor1Data; ucT1CompareCnt+; break; case 1: PWM1=0; PWM2=1; OCR1AH=SteeringMotor2Data8; OCR1AL=SteeringMotor2Data; uiTimeCnt+=SteeringMotor2Data; ucT1CompareCnt+;

2、 break;TCCR1B|=0x0A;TIMSK1|=0x02;【君悦智控】http:/RobotCcase 7: PWM7=0; OCR1AH=10008; OCR1AL=1000; uiTimeCnt+=1000; ucT1CompareCnt+; break; case 8: OCR1AH=(18432-uiTimeCnt)8; OCR1AL=(18432-uiTimeCnt) ucT1CompareCnt=0; T20ms_Routine(); break;default: ucT1CompareCnt=0; break; UpdatePWM();舵机【君悦智控】http:/Robo

3、tC串转并【君悦智控】http:/RobotCvoid UpdatePWM(void) L1 = 0; SDO = 0;SCK = 0;SCK = 1; SDO = PWM7;SCK = 0;SCK = 1; SDO = PWM6;SCK = 0;SCK = 1; SDO = PWM5;SCK = 0;SCK = 1; SDO = PWM4;SCK = 0;SCK = 1; SDO = PWM3;SCK = 0;SCK = 1; SDO = PWM2;SCK = 0;SCK = 1; SDO = PWM1;SCK = 0;SCK = 1; L1 = 1; L1 = 0;串转并#define S

4、CK PORTB.5 #define SDI PINB.4 #define L1 PORTB.0【君悦智控】http:/RobotC直流电机正电流:正转 反电流:反转【君悦智控】http:/RobotC直流电机驱动ENA1A2状态态0-不转100不转110正转101反转111制动【君悦智控】http:/RobotCOut1-EN1OUT2-DIR1Out3-EN2Out4-DIR2直流电机驱动ENA1A2状态态0-不转100不转110正转101反转111制动ENDIR状态态0-不转10正转11反转【君悦智控】http:/RobotCT=1ms f= 1kHz直流电机驱动ENDIR状态态0-不转

5、11正转10反转【君悦智控】http:/RobotCFAST PWM直流电机驱动【君悦智控】http:/RobotCvoid SetMotorSpeed (unsigned char ucChannel,char cSpeed) unsigned char ucLocalChannel; char cLocalSpeed; cLocalSpeed=cValueLimit(cSpeed,-100,100); switch (ucLocalChannel) case 1: #ifdef MOTOR1 if (cLocalSpeed0) OUT2=1; else OUT2=0; if (cLocal

6、Speed=0) /为零则关闭输出 TCCR0A M1Velocity=0; else if(cabs(cLocalSpeed)=100) /为100则全速输出 TCCR0A M1Velocity=1; else / PWM TCCR0A|=0x80; OCR0A=(float)cabs( TCCR0A|=0x80; OCR0A=(float)cabs(cLocalSpeedcLocalSpeed)*2.55; )*2.55; #endif break; UpdateOut();直流电机驱动#ifdef MOTOR1DDRM1V=1;TCCR0A|=0x83;TCCR0B=0x03;SetMo

7、torSpeed(1,0); #endif【君悦智控】http:/RobotC正转: A-B-nA-nB反转: A-nB-nA-B步进电机ABnAnBENDIRENA1A2状态态10110A10110B11101nA11101nB【君悦智控】http:/RobotCvoid SetStepMotor (unsigned char ucChannel,char cSpeed,int iStep) #ifdef STEPMOTOR1 if (ucLocalChannel=1) OCR0A=210 - 2*ucLocalSpeed; if (iStep=0) iStepMotor1Step=0; T

8、IMSK0 else iStepMotor1Step=iStep;TIMSK0|=0x02; #endif步进电机【君悦智控】http:/RobotCinterrupt TIM0_COMPA void timer0_compa_isr(void) static signed char ucIntCnt=1; unsigned char ucTotalStep = 4; switch (ucIntCnt) case 1:M1Velocity=1;OUT2=1;M2Velocity=0;OUT4=0; break; case 2:M1Velocity=0;OUT2=0;M2Velocity=1;O

9、UT4=0; break; case 3:M1Velocity=1;OUT2=0;M2Velocity=0;OUT4=0; break; case 4:M1Velocity=0;OUT2=0;M2Velocity=1;OUT4=1; break; default:M1Velocity=0;M2Velocity=0;break; #endif UpdateOut(); if (iStepMotor1Step=30000) ucIntCnt+; else if (iStepMotor1Step0) iStepMotor1Step-,ucIntCnt+; else if (iStepMotor1St

10、ep=0) TIMSK0 else if (iStepMotor1Step-30000) iStepMotor1Step+,ucIntCnt-; else ucIntCnt-; if(ucIntCnt=ucTotalStep+1) ucIntCnt=1;步进电机【君悦智控】http:/RobotC遥控器【君悦智控】http:/RobotCvoid GetRemoteKey(void) static unsigned char ucCnt=0; unsigned char ucKey=0; ucKey=ucSerialIn(); if (ucKey=0) ucCnt=0; else if (ucCnt=1) KeyProc(ucKey); ucCnt+; if (ucCnt=20) ucCnt=0; 遥控器void KeyProc(unsigned char ucKey) switch (ucKey) case 0b00000001: break; case 0b00000010: break; case 0b00000011: 12组合键break; case 0b00001100: 34组合键break;default:break; 【君悦智控】http:/RobotC直流电机测速【君悦智控】http:/RobotC参考Faulhaber空心杯直流减速电机码盘资料

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 计算机原理

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号