Go Down

Topic: TB6612FNG STBY problem (Read 1 time) previous topic - next topic

MadProf

Hello, I've already started this topic in an inapropriate place (software/interfacing), so I retype it here.
I use a TB6612FNG driver motor and a cheap RF device to communicate.
I want to control my little tank.
I've tried to change the motor library, the RF link library (I first use virtualWire, It work great, then I use serialSoftware, it work great too).
If the STBY pin is high I can't receive any data, same issue with both library.
I've tried to link directly the stby pin on logic vcc, but still the same...

here is the code:

Code: [Select]
#include <VirtualWire.h>

//declaration des pins du controleur de moteurs

#define out_A_PWM 3
#define out_A_IN2 2
#define out_A_IN1 4
#define out_STBY 5
#define out_B_PWM 6
#define out_B_IN2 7
#define out_B_IN1 8

int ordrePrecedent = 0;
int ordre = 0;

void setup()
{
  //pins configuration
  pinMode(out_STBY,OUTPUT);
  pinMode(out_A_PWM,OUTPUT);
  pinMode(out_A_IN1,OUTPUT);
  pinMode(out_A_IN2,OUTPUT);
  pinMode(out_B_PWM,OUTPUT);
  pinMode(out_B_IN1,OUTPUT);
  pinMode(out_B_IN2,OUTPUT);
 
  vw_setup(2400); // Bits per sec
  vw_set_rx_pin(9);
  vw_rx_start(); // Start the receiver PLL running
  analogWrite (out_A_PWM, 80);//set motors speed
  analogWrite (out_B_PWM, 80);
  Serial.begin(9600);
  Serial.println("setup");
}

void loop()
{
   
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
   
    // PB: while digitalWrite(out_STBY,HIGH), no reception possible.
    // out_STBY must be set to LOW in order to get new message, so I can't have a continuous move...
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
      int i;
      // Message with a good checksum received, dump HEX
      Serial.print("Got: ");
      for (i = 0; i < buflen; i++)
      {
        Serial.println(buf[i]);
        ordre = buf[i];
      }
     
      if(ordre!=ordrePrecedent){
        switch (ordre) {
          case 'A':
            avancer();
            break;
           
          case 'B':
            reculer();
            break;
           
          case 'C':
            tournerDroite();
            break;
           
          case 'D':
            tournerGauche();
            break;
           
          case 'E':
            //mode = 1;
            break;
           
          case 'F':
            //mode = 0;
            break;
           
          case 'S':
            stopper();
            break;
          }
          ordrePrecedent=ordre;
      }
  }
}


void avancer()
{
  digitalWrite(out_STBY,HIGH);
  digitalWrite(out_A_IN2, LOW);
  digitalWrite(out_A_IN1, HIGH);
  digitalWrite(out_B_IN2, LOW);
  digitalWrite(out_B_IN1, HIGH);
}

void reculer()
{
  digitalWrite(out_STBY,HIGH);
  digitalWrite(out_A_IN2, HIGH);
  digitalWrite(out_A_IN1, LOW);
  digitalWrite(out_B_IN2, HIGH);
  digitalWrite(out_B_IN1, LOW);
}

void stopper()
{
  digitalWrite(out_STBY,LOW);
}

void tournerGauche()
{
  digitalWrite(out_STBY,HIGH);
  digitalWrite(out_A_IN2, HIGH);
  digitalWrite(out_A_IN1, LOW);
  digitalWrite(out_B_IN2, LOW);
  digitalWrite(out_B_IN1, HIGH);
}

void tournerDroite()
{
  digitalWrite(out_STBY,HIGH);
  digitalWrite(out_A_IN2, LOW);
  digitalWrite(out_A_IN1, HIGH);
  digitalWrite(out_B_IN2, HIGH);
  digitalWrite(out_B_IN1, LOW);
}


I really don't know what to do, I've tried lot of things.
The only time it worked was when I replace "if (vw_get_message(buf, &buflen))" with "if(serial.read())" to receive order directly from my PC with the USB cable, but never with RF link...
There must have an issue cause I've seen some projects using this motor driver with the same RF device. Why motor standby set to HIGH stop RF link ?

Thx in advance and sry for my bad english,

MadProf


Brad Needham

I suspect an electrical problem.  Try unplugging the motors; does the RF link work then?  ...with motor standby set to HIGH?

What motors are you using?

MadProf

Hello Brad,
I use a cheap IR tank, +-15€ on ebay. It as 2 very little motors :
IR Tank
I will try to unplugged the motors as you suggest, I will post my feedback tomorrow.
Thx,
MadProf

MadProf

You were right Brad, with motors unplugged, it works great, RF link doesn't interrupt.
I've tested with motors plugged, when the RF doesn't receive anymore, if I unplugged motors the program resume.
Don't know if this problem can be solve, and how...

MadProf

bill2009

Could you be overrunning your power-supply? what are you using?

MadProf

I use only one battery (7,2V 180mAh) to power arduino board and motors.

bill2009

I'd bet that's the problem.  The motors draw a ferocious amount of power and that's a pretty small battery.

Is the lipo battery what the tank originally ran on?  You could supply the arduino from a 9v and use the lipo for the motors.

MadProf

It's not a Lipo Battery but a nimh. The original was a 150mAh 3,6V.
I didn't use separates batteries cause I wanted a very small tank. 9V battery is nearly the same size...
Image
I will try with separates batteries.

MadProf

MadProf

It works great now with 2 separates batteries. One 180mAh 7,4V for Arduino and 280mAh 3,6V for motors.
Thx for your help Bill and Brad.
MadProf

Go Up