Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

control dc motor with dual motor driver


  • Please log in to reply
20 replies to this topic

#1 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 23 August 2011 - 09:31 PM

Hello, it's me again :)

This time I tried to control an dc motor with an TB6612FNG dual motor driver.

I am not sure if I connected the motor in the right way. Maybe one of you could check that.

List of connections:
- OutputPort (true) on AIn1
- OutputPort (true) on AIn2
- PWM (setdutycicle = 100) on PWMA
- OutputPort (true) on STBY
- 5V on VCC (or VIn of Netduino)
- GND on GND ;)
- Motor 5V on AO1
- Motor GND on A02

It seems that there is anything wrong. If I connect my VIn from my battery pack with VCC the chip of the motor driver gets very hot :(

Would be nice if any of you could help me ;)

Attached Files



#2 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 24 August 2011 - 02:07 AM

I can't see if you have anything connected to VM or the 3rd ground. Also, I'm unable to see if you have the GND of the Netduino tied to the GND on the TB6612. All grounds should be connected together. Here is a link to the TB6612 on Pololu.com (http://www.pololu.co...log/product/713) that has really good diagrams.

I believe the issue that you have might be the fact that the chip requires two separate power inputs. The first should be for the logic on the TB6612 - 5volts is within spec according to the datasheet and you can use the same line that is used for powering the Netduino. The second is the motor voltage (or battery) to power the motors. This should be connected to VM - remember the GND of the motors source should be connected to the GND of everything else.

I hope this helps. I use this chip for my motor driving and I love it. I have a C# class that I have written for the Netduino if you are interested I can send it to you once you get the hardware side working. Let me know if you have any more questions.

When you do end up getting the motors turning, the chip itself can still get hot depending on the load (which is true with most motor driver ICs) but the nice thing about the TB6612 is it has an internal thermal shut down circuit. ---AJB

#3 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 24 August 2011 - 05:13 AM

AJB is correct.
I would add a couple of things about the power supplies:
  • consider to power the chip (Vcc) with +3.3V instead of +5V. This allow much more compatibility for the input levels. If you take a look at the chip specs, they show as +3.5V (min) for the high-level, when powered at +5V. Since Netduino cannot reach output levels over +3.3V, that would be at limit. Another way is keep Vcc=+5V, and configure the Netduino outputs as open-drain.
  • Vm must be connected as AJB stated. DO NOT feed that power from the Netduino board, because the motor could require too much current, and the Netduino regulator could overheat. Use an external supply, a battery or whatever else. Also remember to connect all the grounds together.
Cheers
Biggest fault of Netduino? It runs by electricity.

#4 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 24 August 2011 - 07:15 AM

Oh I see, just to stupid ;) I connected the 9.6V 1.1A on VCC instead of VM. That's the problem why it was getting this hot! Ok I will try that this afternoon :) Hope this helps, thank you for your replies :) @AJB: I found already a class for that motor driver, I will try that first (seems to be very easy), if that doesn't work, would it be really nice if you can help me ;) I already thought about publishing an motor api on the wiki. A few days ago I connected a brushless motor via esc on netduino and that works great :) The wiki is not that big yet. Interesting for me is also connecting an expansion board with more pins on netduino and connecting a touch display :)

#5 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 24 August 2011 - 07:31 AM

I already thought about publishing an motor api on the wiki. A few days ago I connected a brushless motor via esc on netduino and that works great :) The wiki is not that big yet.

Feel free to do so! A wiki is always depending on user contributions :)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#6 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 24 August 2011 - 07:03 PM

Damn it :( that driver isn't working :( maybe you could help me again, i attached a picture of my current connections, but the same problems. if i connect my battery pack on vm the chip gets very hot after seconds all grounds are connected, on vcc I connected 3.3V, on vm I connected VIn from netduino. motor is connected on ao1 and ao2. rest stays the same ^^ Attached File  WP_000074.jpg   135.52KB   76 downloads

#7 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 25 August 2011 - 04:49 AM

Damn it :( that driver isn't working :(

maybe you could help me again, i attached a picture of my current connections, but the same problems. if i connect my battery pack on vm the chip gets very hot after seconds

all grounds are connected, on vcc I connected 3.3V, on vm I connected VIn from netduino. motor is connected on ao1 and ao2. rest stays the same ^^

Attached File  WP_000074.jpg   135.52KB   76 downloads


Above you said that you connected the battery to VM and then you say you connected the Netduino VIN to VM. You can't do that! (I hope it is a typo)

How are you powering the Netduino? Are you using a battery? Are you using USB? Power plug?

For the most part when it comes to motors you want to isolate them as much as possible from the Netduino. While you can power the TB6612 chip (VCC) from the same voltage source as the Netduino you shouldn't power the motors from the same source otherwise it could cause unexpected behavior.

*one thing I wanted to point out as well is you need to make sure that the wiring that you have on the TB6612 isn't shorting between the pads. If some are the pins are shorted I can see the chip getting hot quick.


Here should be your set up:
Motor battery to VM (TB6612) and GND (TB6612)
STBY (TB6612) and VCC (TB6612) and the same source that you are using to power the Netduino on VIN all tied together.
All GNDs (TB6612) including motor battery connected together and then to GRN on Netduino (doesn't matter which one as they are all tied together - GRN closest to VIN preferred)
Netduino OutputPin to AIN1 (TB6612)
Netduino OutputPin to AIN2 (TB6612)
Netduino PWM to PWMA (TB6612)

Those are all the connections that are necessary for a single motor. As I said before I use this chip and I haven't had an issue. I don't have an active circuit set up now or I would take a picture for you to look at. I might get a circuit up this weekend if you are still having issues. If you can solder it would be much better to solder pins on the TB6612 carrier board and plug it into a breadboard and use jumpers to make the connections. I'm worried that all of your issues might be because of a loose connection or short on the TB6612.

Let me know if you need more help.

#8 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 25 August 2011 - 05:42 AM

STBY (TB6612) and VCC (TB6612) and the same source that you are using to power the Netduino on VIN all tied together.

I don't know whether it's me, but THAT'S NOT CORRECT!
The TB6612's Vcc (and rest of logic) CANNOT be tied above +6V (Read the the specs, page 3). Of sure the chip will get hot under this condition.
Instead, I would connect both the TB6612 Vcc and the STBY to the Netduino +3.3V, which make the logic levels compatible.
All the rest is totally correct.

@AJB: if I misunderstood your indication, please forget this post.

Also take a look at page 7 of the specs: there is a well-described schematic.
Cheers
Biggest fault of Netduino? It runs by electricity.

#9 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 25 August 2011 - 07:23 AM

At the moment I connected my battery pack to the netduino. VCC and STBY are on that 5V pin and VM is on VIn (9.6V) pin of netduino. GND are all connected to netduino. Maybe I solder this evening every wire to that board to avoid problems with shorting or loose connections.

#10 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 25 August 2011 - 10:58 AM

You should NOT supply the current for the motors over the netduino (e.g. by using connecting V_M to VIn), as Mario stated. One (the most important) reason is that Motors usually need more current than the netduino can safely supply (read: you can burn out your netduino), another reason is that motors produce glitches in the power that the netduino won't like. You should use a seperate power supply (a seperate battery pack) for the motor and the netduino - connect the motor battery pack to VM and one GND port of the breakout board, connect 3.3V (netduino) to VCC (board), connect GND (netduino) to another GND on the breakout board. (on a side note - you don't need to connect GND on the netduino to GND on the board 3 times ...) You probably should also add filtering capacitors across VM + GND and VCC + GND.

Edit: It seems that the driver already has builtin filtering capacitors, so you can ignore that bit.

Edited by Stefan W., 25 August 2011 - 11:01 AM.

I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#11 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 25 August 2011 - 02:50 PM

Ok I will try that. But I think that there should be no problem with supplying the motor over netduino. I connected my brushless motor in the same way (max. 47A) and it worked without problems and the motor for that current driver has only 0.06A ^^ But doesn't matter, I will try that like you described and solder the wires :) Hopefully it will work.

#12 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 25 August 2011 - 05:54 PM

I don't know whether it's me, but THAT'S NOT CORRECT!
The TB6612's Vcc (and rest of logic) CANNOT be tied above +6V (Read the the specs, page 3). Of sure the chip will get hot under this condition.
Instead, I would connect both the TB6612 Vcc and the STBY to the Netduino +3.3V, which make the logic levels compatible.
All the rest is totally correct.

@AJB: if I misunderstood your indication, please forget this post.

Also take a look at page 7 of the specs: there is a well-described schematic.
Cheers



Sorry, I keep forgetting that VIN on the Netduino goes to the regulators. I almost always use USB and pull the power from the Netduino. I should have been more clear about that. I need to get a diagram going this weekend to SHOW instead of TELL :) I think that would help with the pinout confusions. I was assuming (incorrectly) that VIN was clean regulated power going into the Netduino and that is what should be used to power the TB6612.---AJB

#13 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 26 August 2011 - 10:01 AM

Hey again ;)

I found a good instruction on that motor driver. It is all connected like on that diagram. But it won't work.

When I connect VCC with GND then the motor becomes faster or slower, but if I connect the motor with ao1 and ao2 nothing happens.

Attached File  Photo_76A7F664-8F4C-5A52-9DE1-66D8E6E98BF5.jpg   207.06KB   42 downloads

I am soooo frustrated :(

UPDATE: I missed to connect the GND to the netduino. Now it is done this way an now nothing works for me :( even on VCC and GND.

#14 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 26 August 2011 - 11:13 AM

- OutputPort (true) on AIn1
- OutputPort (true) on AIn2
- PWM (setdutycicle = 100) on PWMA
- OutputPort (true) on STBY

According to the state stable from the device datasheet, the output is in 'Short brake' when both AIn1 and AIn2 are logic high. To start the motor, you'd need to set one of the inputs to logic low (AIn1 = L and AIn2 = H -> CCW, AIn1 = H and AIn2 = L -> CW).

#15 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 26 August 2011 - 11:16 AM

everything is set in this way ;) that older post was wrong

#16 ajcg1973

ajcg1973

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts

Posted 27 August 2011 - 01:46 AM

Hey again ;)

I found a good instruction on that motor driver. It is all connected like on that diagram. But it won't work.

When I connect VCC with GND then the motor becomes faster or slower, but if I connect the motor with ao1 and ao2 nothing happens.

Attached File  Photo_76A7F664-8F4C-5A52-9DE1-66D8E6E98BF5.jpg   207.06KB   42 downloads

I am soooo frustrated :(

UPDATE: I missed to connect the GND to the netduino. Now it is done this way an now nothing works for me :( even on VCC and GND.


I'm starting to get a little concerned that the motor driver *might* be having an issue.

I'm still worried about ALL of the GNDs not being connected in your picture. I haven't tested if all of the GNDs on the TB6612 are connected internally by looking at the circuit diagram nor have I verified by using a Voltmeter. I'm also not sure about you connecting both the 3.3 and 5.0 to the TB6612 at different places at the same time - this is something else I haven't tested.

Please do the following:
1. Hook all of your grounds together.
2. Do you have a different battery source than the battery that you have pictured? Is that a 9v alkaline? Or something like a 7.2v rechargable? If so those have VERY little amperage to drive any kind of circuit much less an actual motor. Do you have the ability to use a battery with more juice like 4 AAs?
3. Can you post the source code that you are using to drive the motor?

I hopefully will have time to put a working circuit together this weekend so I can give you a good picture and code to work with.

#17 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 27 August 2011 - 02:06 AM

The picture looks like you connected 5V to VCC/STBY instead of 3.3V. As Mario said,

consider to power the chip (Vcc) with +3.3V instead of +5V. This allow much more compatibility for the input levels. If you take a look at the chip specs, they show as +3.5V (min) for the high-level, when powered at +5V. Since Netduino cannot reach output levels over +3.3V, that would be at limit. Another way is keep Vcc=+5V, and configure the Netduino outputs as open-drain.

What is the PWM frequency you are using?
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#18 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 27 August 2011 - 11:17 AM

I tried it with both 3.3V and 5V - made no difference. I use PWM setdutycicle = 100 or setpulse(10000,70 + i) and increased i all 2 sec 100 points all gnd are connected internally, i can use an empty gnd and vcc or vm ;) with different speed

#19 Freeman4gu

Freeman4gu

    Member

  • Members
  • PipPip
  • 17 posts

Posted 27 August 2011 - 11:37 AM

Ok a friend of me got that chip working on his fez panda 2, so i will try that with his motor driver, maybe my one is defect, i give you a response in the next days

#20 DanA

DanA

    Member

  • Members
  • PipPip
  • 26 posts

Posted 22 December 2011 - 07:50 AM

Hi,

I'm sure that this is covered somewhere in the conversation above, but it wasn't too clear for us - So we thought we should post in some detail what worked for us.

My son and I just did a similar project this evening (SparkFun "Magician" Chassis (http://www.sparkfun.com/products/10825) + SparkFun TB6612FNG Breakout (http://www.sparkfun.com/products/9457) + Netduino).

We wired it like so:

Netduino to TB6612FNG
DIO0 = Standby (This needs to be high (true))
DIO1 = AIN1
DIO2 = AIN2
DIO5 = PWMA
DIO6 = PWMB
DIO8 = BIN1
DIO9 = BIN2

TB6612FNG
VM = Motor power +
VCC = 5 volt on Netduino
AO1 = Red motor lead (Right)
AO2 = Black motor lead (Right)
BO2 = Black motor lead (Left)
BO1 = Red motor lead (Left)

(Its left/right when the front is the end with the wheels)

We connected all grounds (Netduino, motor power, TB6612FNG) together.

We started with ajcg1973's code (thanks!) from here: http://forums.netdui...tduino-tankbot/

Here's an example using his code with our pin selections.

OutputPort stby = new OutputPort(Pins.GPIO_PIN_D0, true);
AjbMotorTB6612FNG motors = new AjbMotorTB6612FNG(Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D1, Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9);
motors.Motor1Direction = AjbMotorTB6612FNG.MotorDirection.Forward;
motors.Motor1Speed = 100;  // Set the motor to 100% speed
motors.Motor2Direction = AjbMotorTB6612FNG.MotorDirection.Reverse;
motors.Motor2Speed = 100;  // Set the motor to 100% speed

Set like this, "A" will be motor1 and "B" will be motor2.

The motors on this chassis don't respond at 10%. 20% seems around the bottom.

We flipped "forward" and "reverse" from how it's set in ajcg1973's code (We might be driving backwards (round end front?) - but the ball seems to follow better then lead.).

This will race around in a tight circle. Keep this in mind if your debug USB is still connected. :)

If you are using this motor driver - this PDF is useful: http://www.pololu.co...df?file_id=0J86

This is what worked for us - and nothing caught on fire, but YMMV. :)

We hope this helps someone else.

Thanks
Dan

Attached File  robot.jpg   98.02KB   24 downloads




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.