arduino tb6612fng怎么驱动

arduino tb6612fng怎么驱动,第1张

[objc] view plain copy
//motor A connected between A01 and A02
//motor B connected between B01 and B02

int STBY = 10; //standby

//Motor A
int PWMA = 3; //Speed control
int AIN1 = 9; //Direction
int AIN2 = 8; //Direction

//Motor B
int PWMB = 5; //Speed control
int BIN1 = 11; //Direction
int BIN2 = 12; //Direction

void setup(){
pinMode(STBY, OUTPUT);

pinMode(PWMA, OUTPUT);
pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);

pinMode(PWMB, OUTPUT);
pinMode(BIN1, OUTPUT);
pinMode(BIN2, OUTPUT);
}

void loop(){
move(1, 255, 1); //motor 1, full speed, left
move(2, 255, 1); //motor 2, full speed, left

delay(1000); //go for 1 second
stop(); //stop
delay(250); //hold for 250ms until move again

move(1, 128, 0); //motor 1, half speed, right
move(2, 128, 0); //motor 2, half speed, right

delay(1000);
stop();
delay(250);
}
void move(int motor, int speed, int direction){
//Move specific motor at speed and direction
//motor: 0 for B 1 for A
//speed: 0 is off, and 255 is full speed
//direction: 0 clockwise, 1 counter-clockwise

digitalWrite(STBY, HIGH); //disable standby

boolean inPin1 = LOW;
boolean inPin2 = HIGH;

if(direction == 1){
inPin1 = HIGH;
inPin2 = LOW;
}

if(motor == 1){
digitalWrite(AIN1, inPin1);
digitalWrite(AIN2, inPin2);
analogWrite(PWMA, speed);
}else{
digitalWrite(BIN1, inPin1);
digitalWrite(BIN2, inPin2);
analogWrite(PWMB, speed);
}
}

void stop(){
//enable standby
digitalWrite(STBY, LOW);
}
实例效果
通电,并测量马达A与B的输出电压,基本相同,电压差在正负003V,输出稳定。
想必能完美解决L9110S 和 L298N两路电机输出电压误差大导致的走不到直线。

进入微信,点通讯录,点右上角的加号,---发起群聊----选择一个群----选择你不想要的那个群,然后点进去,再点右上角的两个人并排的图像,拖到最下面,点删除并退出,请采纳
有可能是显卡问题
具体自测吧不然买过

你得看步进电机的功率,一般步进电机的电流是1A左右,电机大的能上到8A,极限了。一般用12V供电的,不用看了小功率小电流的,你就当电机走1-4A,12V电机,整套功率应该在20W-40W左右,不建议用电池来驱动电机,特别是用12V的电池,电流大了会发热就大,电池温度高就有一定安全风险。

proteus中的tb6612fng在哪?哪也不在,根本就没有,也不可能这东西。你以为proteus是万能的,要什么有什么吗?其实,它所有的元件是很有限的。不要什么东西都来仿真,还是老老实实地做实物吧。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13074731.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-30
下一篇 2023-05-30

发表评论

登录后才能评论

评论列表(0条)

保存