立即注册 登录
返回首页

uid:241715的个人空间

日志

TB6612FNG电机驱动模块学习

热度 4已有 14788 次阅读2018-3-5 17:07 |个人分类:电机驱动

该模块相对于传统的L298N效率上提高很多,体积上也大幅度减少,在额定范围内,芯片基本不发热。


TB6612FNG每通道输出最高1.2 A的连续驱动电流,启动峰值电流达2A/3.2 A(连续脉冲/单脉冲);

4种电机控制模式:正转/反转/制动/停止;

PWM支持频率高达100 kHz;

待机状态;

片内低压检测电路与热停机保护电路;

工作温度:-20~85℃;

SSOP24小型贴片封装。

引脚说明

                A控制信号输入------PWMA               VM ------电机驱动电压输入端(4.5V-15V)

                   A电机输入端2 ------AIN2                VCC ------逻辑电平输入端(2.7V-5.5V)

                   A电机输入端1 ------AIN1                GND ------ 接地

正常工作/待机状态控制端------STBY                 AO1 ------- A电机输出端1

                    B电机输入端1------BIN1                AO2 ------ A电机输出端2

                    B电机输入端2------BIN2                BO2 ------ B电机输出端2

            B控制信号输入端------PWMB                BO1 ------ B电机输出端1

                                   接地------GND                GND ------- 接地


接线方式



程序实现



[objc] view plain copy
  1. //motor A connected between A01 and A02  
  2. //motor B connected between B01 and B02  
  3.   
  4. int STBY = 10//standby  
  5.   
  6. //Motor A  
  7. int PWMA = 3//Speed control   
  8. int AIN1 = 9//Direction  
  9. int AIN2 = 8//Direction  
  10.   
  11. //Motor B  
  12. int PWMB = 5//Speed control  
  13. int BIN1 = 11//Direction  
  14. int BIN2 = 12//Direction  
  15.   
  16. void setup(){  
  17.   pinMode(STBY, OUTPUT);  
  18.   
  19.   pinMode(PWMA, OUTPUT);  
  20.   pinMode(AIN1, OUTPUT);  
  21.   pinMode(AIN2, OUTPUT);  
  22.   
  23.   pinMode(PWMB, OUTPUT);  
  24.   pinMode(BIN1, OUTPUT);  
  25.   pinMode(BIN2, OUTPUT);  
  26. }  
  27.   
  28. void loop(){  
  29.   move(12551); //motor 1, full speed, left  
  30.   move(22551); //motor 2, full speed, left  
  31.   
  32.   delay(1000); //go for 1 second  
  33.   stop(); //stop  
  34.   delay(250); //hold for 250ms until move again  
  35.   
  36.   move(11280); //motor 1, half speed, right  
  37.   move(21280); //motor 2, half speed, right  
  38.   
  39.   delay(1000);  
  40.   stop();  
  41.   delay(250);  
  42. }  
  43.   
  44.   
  45. void move(int motor, int speed, int direction){  
  46. //Move specific motor at speed and direction  
  47. //motor: 0 for B 1 for A  
  48. //speed: 0 is off, and 255 is full speed  
  49. //direction: 0 clockwise, 1 counter-clockwise  
  50.   
  51.   digitalWrite(STBY, HIGH); //disable standby  
  52.   
  53.   boolean inPin1 = LOW;  
  54.   boolean inPin2 = HIGH;  
  55.   
  56.   if(direction == 1){  
  57.     inPin1 = HIGH;  
  58.     inPin2 = LOW;  
  59.   }  
  60.   
  61.   if(motor == 1){  
  62.     digitalWrite(AIN1, inPin1);  
  63.     digitalWrite(AIN2, inPin2);  
  64.     analogWrite(PWMA, speed);  
  65.   }else{  
  66.     digitalWrite(BIN1, inPin1);  
  67.     digitalWrite(BIN2, inPin2);  
  68.     analogWrite(PWMB, speed);  
  69.   }  
  70. }  
  71.   
  72. void stop(){  
  73. //enable standby    
  74.   digitalWrite(STBY, LOW);   
  75. }  


实例效果

通电,并测量马达A与B的输出电压,基本相同,电压差在正负0.03V,输出稳定。

想必能完美解决L9110S 和 L298N两路电机输出电压误差大导致的走不到直线。


路过
1

鸡蛋

鲜花
1

握手

雷人

刚表态过的朋友 (2 人)

发表评论 评论 (2 个评论)

回复 lhy1056705011 2018-11-5 19:42
TB6612FNG内部带不带死区保护?  需要软件保护死区吗??
回复 bengbai4 2020-5-7 14:33
有51的完整程序吗

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

返回顶部