Difference between revisions of "Projets:Perso:2011:Motorshield"

From Electrolab
Jump to: navigation, search
(Testons une orga moins merdique...)
Line 1: Line 1:
{{Project
+
= Introduction =
|name= Motorshield
+
Please note that this is an ongoing project: this page itself is a work in progress. Use at your own risk :)
|author= Clément
+
You can also check [[FINDMEANAME|past versions]] of this project.
|proposal_date= 25/10/2011
+
|abstract1=So there's this cool Motorshield from Adafruit industries, but it handles such little currents !
+
|abstract2=And there's this chip, quite cool, which handles a bit more...
+
|abstract3=OpenHW is about commiting patches, right ? So here's mine !
+
|tags=arduino motor
+
|where=Anywhere
+
|for_who=Anyone using the motorshield and in need of a few more amps
+
|official_electrolab_project= not yet
+
|budget= 0 (perso)
+
|number_of_members= 1, on the shoulders of many others
+
|estimated_time= few nights of work for the first prototype
+
}}
+
  
TODO:
+
== About ==
Move those pics to a sub-page/download, or sort them.
+
So there's this cool Motorshield from Adafruit industries, but it handles such little currents ! And there's this chip, quite cool, which handles a bit more... OpenHW is about commiting patches, right ? So here's mine !
Add a true overview pic with the board and adapted motors/loads.
+
[[File:Motorshield_ALL.png|center|thumb]]
Create assembly sub-page
+
<center>The current prototype.</center>
Clean this page
+
Please check [http://ladyada.net/make/mshield/index.html|their own webpage] for further information and full credits.
Add history/release notes in an explicit way
+
  
[[File:Motorshield_ALL.png|thumb|overview]]
 
[[File:Motorshield_top.jpg|thumb|Top view of the current prototype]]
 
[[File:Motorshield_bot.jpg|thumb|Bottom view of the current prototype]]
 
[[File:Motorshield_SCH.png|thumb|Schematic]]
 
[[File:Motorshield_TOP.png|thumb|Top copper]]
 
[[File:Motorshield_BOT.png|thumb|Bottom copper]]
 
 
= Introduction =
 
 
== Design goals ==
 
== Design goals ==
The goal of this project is to '''replace the weak L293D''' of Adafruit's Motorshield with a stronger chip, a [http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MC33932&fsrch=1&sr=2|Freescale MC33932], which is a fully integrated dual H-bridge rated at 5.0A (vs 0.6A for the L293D).
+
* The goal of this project is to '''replace the weak L293D''' of Adafruit's Motorshield with a stronger chip, a [http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MC33932&fsrch=1&sr=2|Freescale MC33932], which is a fully integrated dual H-bridge rated at 5.0A (vs 0.6A for the L293D).
One major constraint is to '''keep a full pin/function compatibility''', so that this shield can be a drop-in replacement for Adafruit's version.
+
* One major constraint is to '''keep a full pin/function compatibility''', so that this shield can be a drop-in replacement for Adafruit's version.
I also chose to use mostly '''SMD components''', because I am fed up with all those thruhole resistors: people should live with their time, and in my opinion, those are a thing of the past.
+
* I also chose to use mostly '''SMD components''', because I am fed up with all those thruhole resistors: people should live with their time, and in my opinion, those are a thing of the past.
  
Because this project is intended as a patch/commit for adafruit's motorshield, I've decided to follow the organization of their webpage documenting their version. Please check [http://ladyada.net/make/mshield/index.html|their own webpage] for further information and full credits.
 
  
 
Note that I might call this shield "the Arduino sHHHHield - an Arduino shield with four H bridges" and am presently claiming full fame and credits and everything for such a lame joke name :-)
 
Note that I might call this shield "the Arduino sHHHHield - an Arduino shield with four H bridges" and am presently claiming full fame and credits and everything for such a lame joke name :-)
Line 82: Line 60:
 
Hint: having 8 half bridge on a board means you could control, like, 8 lamps. Or whatever requires few amps.
 
Hint: having 8 half bridge on a board means you could control, like, 8 lamps. Or whatever requires few amps.
  
 +
More info on the [[Projets:Perso:2011:Motorshield:use|related sub-page]].
 
== Things you should know ==
 
== Things you should know ==
 
Remember, YMMV: this is a prototype, not a commercial product.
 
Remember, YMMV: this is a prototype, not a commercial product.
Line 198: Line 177:
 
</nowiki>
 
</nowiki>
  
= Download =
+
 
 +
= Resources =
 +
== Download ==
 
Check adafruit version of the library required to use this shield. It works okay. See previous section for limitations and some example code.
 
Check adafruit version of the library required to use this shield. It works okay. See previous section for limitations and some example code.
  
 
Come back later for full eagle files of this design, I'm still trying to figure out a way to upload any kind of file on this wiki ! Contact me directly if the images on this page aren't enough for you. As soon as I figure a way to upload the Eagle design files on here, I will.
 
Come back later for full eagle files of this design, I'm still trying to figure out a way to upload any kind of file on this wiki ! Contact me directly if the images on this page aren't enough for you. As soon as I figure a way to upload the Eagle design files on here, I will.
  
= Resources =
+
== Links ==
 
* http://www.adafruit.com/products/81
 
* http://www.adafruit.com/products/81
 
* http://www.ladyada.net/make/mshield/
 
* http://www.ladyada.net/make/mshield/
 
* http://shop.snootlab.com/powerduino/87-rotoshield.html
 
* http://shop.snootlab.com/powerduino/87-rotoshield.html
  
= Buy Kit =
+
== Buy Kit ==
 
This is just a prototype at the moment. Check its smaller/older brother on adafruit, snootlab, or get in touch with contact@electrolab.fr if you ''really'' wanna buy one of the prototypes.
 
This is just a prototype at the moment. Check its smaller/older brother on adafruit, snootlab, or get in touch with contact@electrolab.fr if you ''really'' wanna buy one of the prototypes.
  
Line 217: Line 198:
 
* the prototype boards are assembled by hand. Even if I happily give some of my time to design stuff, assembling batches is boring and then my time isn't totally free (as in free beer). Somehow, we will never reach volumes similar to those of Adafruit, therefore a higher price would be inevitable.
 
* the prototype boards are assembled by hand. Even if I happily give some of my time to design stuff, assembling batches is boring and then my time isn't totally free (as in free beer). Somehow, we will never reach volumes similar to those of Adafruit, therefore a higher price would be inevitable.
  
= Forums/contact =
+
= More info =
 
Check all the ressources associated with the original version of this shield. For anything regarding this particular version, you can contact me directly through the electrolab mailing list, or on IRC: clmnt/#electrolab on freenode networks.
 
Check all the ressources associated with the original version of this shield. For anything regarding this particular version, you can contact me directly through the electrolab mailing list, or on IRC: clmnt/#electrolab on freenode networks.
 +
 +
You can check the [[Projets:Perso:2011:Motorshield:faq|Frequently Asked Questions]] sub page for more info & troubleshooting.
  
 
= FAQ =
 
= FAQ =
Line 254: Line 237:
 
It'd be way too easy if I document this for you ;)
 
It'd be way too easy if I document this for you ;)
  
= TODO/Wishlist for next revisions =
+
= TODOs =
 +
== Wishlist for next revisions ==
 
* check signal names (eg motor x forward should behave as expected)
 
* check signal names (eg motor x forward should behave as expected)
 
* protect reverse polarity on power plug
 
* protect reverse polarity on power plug
Line 274: Line 258:
 
* check/think about a small volume production price
 
* check/think about a small volume production price
 
* your wildest dream here ! :)
 
* your wildest dream here ! :)
 +
 +
== TODO for this page ==
 +
* Move those pics to a sub-page/download, or sort them.
 +
* Add a true overview pic with the board and adapted motors/loads.
 +
* Create assembly sub-page
 +
* Clean this page
 +
* Add history/release notes in an explicit way

Revision as of 00:53, 14 December 2011

Introduction

Please note that this is an ongoing project: this page itself is a work in progress. Use at your own risk :) You can also check past versions of this project.

About

So there's this cool Motorshield from Adafruit industries, but it handles such little currents ! And there's this chip, quite cool, which handles a bit more... OpenHW is about commiting patches, right ? So here's mine !

The current prototype.

Please check own webpage for further information and full credits.

Design goals

  • The goal of this project is to replace the weak L293D of Adafruit's Motorshield with a stronger chip, a MC33932, which is a fully integrated dual H-bridge rated at 5.0A (vs 0.6A for the L293D).
  • One major constraint is to keep a full pin/function compatibility, so that this shield can be a drop-in replacement for Adafruit's version.
  • I also chose to use mostly SMD components, because I am fed up with all those thruhole resistors: people should live with their time, and in my opinion, those are a thing of the past.


Note that I might call this shield "the Arduino sHHHHield - an Arduino shield with four H bridges" and am presently claiming full fame and credits and everything for such a lame joke name :-)

Features

As intended, this shield is very similar to Adafruit's current version:

  • 2 connections for 5V 'hobby' servos - still the huge drawback of pumping on the 5v regulators, which means you cannot expect to use torque-full servos.
  • Up to 4 bi-directional DC motors with individual 8-bit speed selection (so, about 0.5% resolution)
  • Up to 2 stepper motors (unipolar or bipolar) with single coil, double coil, interleaved or micro-stepping.
  • Pull down resistors keep motors disabled during power-up
  • Big terminal block connectors to easily hook up wires (10-22AWG) for motor and power supply
  • Arduino reset button brought up top
  • 2-pin terminal block to connect external power, for seperate logic/motor supplies
  • Tested compatible with Duemilanove & UNO. Not tested on Mega yet, but should work as the original shield. Not tested for steppers yet neither (see below: there might be issues with the current prototype, but it'll be corrected on final version).

There are some differences tho:

  • Max voltage is 28v for the H-bridge [1]
  • Mostly compatible with easy-to-use Arduino software libraries from Adafruit [2]
  • 4 H-Bridges: MC33932 chipset can provide 5.0A per bridge (at 6.5A overcurrent kicks in) [3]
  • Current feedback readable directly on four of the analog inputs of the Arduino [4]
  • Status flag for each chip on two other analog inputs [4]
  1. As I've done the design rather in a hurry for another project in a 12v environment, condensators have been chosen for this value (actually, 16v max if I remember well). Mount other values and you'll be able to get closer to the MC33932 max voltage rating. Be reasonable: at full amps, it'll get you close to 500w, even with high efficiency it'll fry the chip - or at least get it in thermal protection very fast - without additional cooling.
  2. Most notably, the enable (and thus PWM and speed control) works the opposite way at the moment, that is setspeed(255) will get stop and setspeed(0) will get fullspeed. See sections below for details.
  3. This is RMS (eg: mean over time). Actually depends on how well you cool it. This chipset implements a thermal shutdown protection and short circuit/over current protection. I've tested it for quite a quile at 2.5A per bridge "stock", eg without any additionnal heatsink, and it went hot but not too hot.
  4. Check below for details on how to use this

Yeah, I know, I hate those "see conditions below" things, but hey, this is only a prototype at the moment, so live with it :)

Make it!

As you can see, the board design wasn't really optimised for DIY processes:

  • 6 mil spacing (0.15mm), 12mil tracks: so to speak "class 5" (not sure this is an international thing ; the higher the class, the harder to manufacture. It is probably a french standard).
  • 0.3 mm vias

These are Pcb Pool standard process parameters - board house I went with for the first prototypes.

You can either:

  • go for a pro fab house
  • tweak the current design to adapt to your manufacturing abilities
  • come with us tweak the lab pcb fab equipment to achieve such results. Amusing fact: just for fun (like 3am on a wednesday stupid challenge ;), we tried to make the bottom layer with our not-yet-trimmed pcb-process at the lab, and it went out suprisingly well. It is highly probable that in a rather near future we will be able to actually manufacture such PCB directly at the lab (of course, without metal vias, soldermask and silkscreen: those are for quite later on ;)

Because there are quite a lot of pictures associated with that, check the sub-page describing the assembly process.

Use it!

There's no deep, thorough tutorial about this yet. Check what is done with the original adafruit version, and come back later to check what we are using this for - once I document the related projects ;) Spoiler alert: one of them is related to Physical Etoys/Squeakbot (STFW :) Hint: having 8 half bridge on a board means you could control, like, 8 lamps. Or whatever requires few amps.

More info on the related sub-page.

Things you should know

Remember, YMMV: this is a prototype, not a commercial product.

  • PWM frequency shall be under 11 kHz according to datasheet. It can be selected when you create a AF_DCMotor object: "AF_DCMotor motor_1_or_2(1,MOTOR12_2KHZ);" or "AF_DCMotor motor_3_or_4(3,MOTOR34_2KHZ);"
  • I think I ended up messing with signals, that is motor x forward/backward isn't 100% garanteed to be the same as for Adafruit's version. That's lame, but it seems okay to me, given that it is a prototype. One can still pilot all four DC motors, you just have to figure out which one is where and goes which way - or wait for the final HW revision, or the specific SW library.
  • because of previous issue, stepper support most probably won't work out of the box.
  • speed value is messed up, see below.
  • you can read each H-bridge status flags (see datasheet: indicates if everything's fine), if you have the right 0 ohm resistor soldered.

Setting speed for DC motors

The PWMing for speed is an active low on the MC33932 vs an active high on the L293D. I have been lazy to implement a HW thing to compensate for that. I suppose I'll have to decide what I end up doing: either keep the hw simple or respect full pin/sw compatibility. Anyway, on this prototype, speed values are inversed ! that means, "motorX.setSpeed(255);" will stop the motor and "motorX.setSpeed(0);" will have it go fullspeed.

Current feedback feature

To use the current feedback feature, you should:

  • have the right 0 ohm (eg, bridge) resistors in place (check schematic)
  • do something like "analogRead(MOTORX_FBPIN)" with "const int M1_FB = A0;//M1 current feedback","const int M2_FB = A1;//M2 current feedback","const int M3_FB = A3;//M3 current feedback","const int M4_FB = A4; //M4 current feedback".
  • use the datasheet, schematic and your brain to find the value ! Or read below.

How to find the right code to have a meaningful value:

  • The current mirror on feedback pin is 0.24% of load current.
  • The resistor in place has a value of 270 ohm (standard precision).
  • Therefore, a 5A current will achieve 5*0.0024*270 = 3.24 volts seen on the ADC
  • The ADC is 10bits with a 5v reference, so this 5A current will result in 3.24/5*1024 = 664 approx.
  • Then 5/664 (or 0.00753) is the factor to have a value in amps.
  • An almost correct code might be something like "value_miliamps = 8*analogRead(MOTORX_FBPIN);". Remember that the Arduino doesn't like floating point variables nor making divisions (no dedicated hw) and there are imprecisions here and there, so a x8 factor should be good enough.
  • Note that at 6.5A the overcurrent protection kicks in, so the ADC should be fine in any case.

Code example

formating sucks, sorry ! // Adafruit Motor shield library // copyright Adafruit Industries LLC, 2009 // this code is public domain, enjoy! // adapted for Electrolab Motorshield prototype #include <AFMotor.h> const int STATUS_FLAG_1 = A2;//H-bridge1 status flag const int STATUS_FLAG_2 = A5;//H-bridge2 status flag const int M1_FB = A0; //M1 current feedback const int M2_FB = A1; //M2 current feedback const int M3_FB = A3; //M3 current feedback const int M4_FB = A4; //M4 current feedback //we need PWM freq < 11kHz AF_DCMotor motor1(1,MOTOR12_8KHZ); AF_DCMotor motor2(2,MOTOR12_8KHZ); AF_DCMotor motor3(3,MOTOR34_8KHZ); AF_DCMotor motor4(4,MOTOR34_8KHZ); void setup() { Serial.begin(9600); Serial.println("Motor test! Everyone full forward !"); //enable status flag reading pinMode(STATUS_FLAG_1, INPUT);//Status flag1 pinMode(STATUS_FLAG_2, INPUT);//Status flag2 // turn off (!!) all motors motor1.setSpeed(255); motor2.setSpeed(255); motor3.setSpeed(255); motor4.setSpeed(255); motor1.run(RELEASE); motor2.run(RELEASE); motor3.run(RELEASE); motor4.run(RELEASE); // turn on (!!) all motors motor1.setSpeed(0); motor2.setSpeed(0); motor3.setSpeed(0); motor4.setSpeed(0); motor1.run(FORWARD); motor2.run(FORWARD); motor3.run(FORWARD); motor4.run(FORWARD); } void loop() { int tempval; Serial.print("motor1 current(mA):"); tempval = 3*analogRead(M1_FB);//check the datasheet & schematic, value in mA Serial.println(tempval); Serial.print("motor2 current(mA):"); tempval = 3*analogRead(M2_FB);//check the datasheet & schematic, value in mA Serial.println(tempval); Serial.print("motor3 current(mA):"); tempval = 3*analogRead(M3_FB);//check the datasheet & schematic, value in mA Serial.println(tempval); Serial.print("motor4 current(mA):"); tempval = 3*analogRead(M4_FB);//check the datasheet & schematic, value in mA Serial.println(tempval); Serial.print("status flag1:"); if(HIGH==digitalRead(STATUS_FLAG_1)) Serial.println("ok"); else Serial.println("nok"); Serial.print("status flag2:"); if(HIGH==digitalRead(STATUS_FLAG_2)) Serial.println("ok"); else Serial.println("nok"); Serial.println(""); delay(1000); }


Resources

Download

Check adafruit version of the library required to use this shield. It works okay. See previous section for limitations and some example code.

Come back later for full eagle files of this design, I'm still trying to figure out a way to upload any kind of file on this wiki ! Contact me directly if the images on this page aren't enough for you. As soon as I figure a way to upload the Eagle design files on here, I will.

Links

Buy Kit

This is just a prototype at the moment. Check its smaller/older brother on adafruit, snootlab, or get in touch with contact@electrolab.fr if you really wanna buy one of the prototypes.

Please note that price would be significantly higher than that of the Motorshield, like above 50€. That's because:

  • that's what they cost me right now
  • the MC33932 a stronger but more expensive than L293D: even in a production run, costs would be higher
  • these are still prototypes, with tiny volume (eg: more expensive pcb and components, because volume is what drives prices down)
  • the prototype boards are assembled by hand. Even if I happily give some of my time to design stuff, assembling batches is boring and then my time isn't totally free (as in free beer). Somehow, we will never reach volumes similar to those of Adafruit, therefore a higher price would be inevitable.

More info

Check all the ressources associated with the original version of this shield. For anything regarding this particular version, you can contact me directly through the electrolab mailing list, or on IRC: clmnt/#electrolab on freenode networks.

You can check the Frequently Asked Questions sub page for more info & troubleshooting.

FAQ

Please start with reading Adafruit own FAQ, here are only additionnal answers specific to this version.

What additionnal features does this version have to offer ?

  • More amps !
  • Less thru-holes !
  • a way to measure the current consumed on each of your motors
  • a way to get a feedback on the H-bridge status

Can I really use all bridges at full power ?

No. It'll hurt the chips by overheating if you dont take care of that. But at least, it wont self destroy (or less often ;) if you short the outputs, and at current levels which would destroy the L293D, the MC33932 is still rather cool. When people say "that many amps", it is usually in the best possible environment, so it is safe to assume in real life, it'll be less. Check the datasheet and design files if you wanna know more about that.

It makes annoying noises

Maybe that's because it is being PWMed at a rather low frequency. Change your setup in the lib. Live with it, because those chips cant handle a higher pwming frequency, or design a similar board with different, better chips :)

Suggested motors

we use bigger ones, like that thing, but any DC motor of an appropriate size/spec should work.

I wanna understand what's really going on inside/with this shield

Well... check with your local hackerspace, or come to visit us !

I wanna make some modifications to this design

Please do ! And document it. That's the very goal of the chosen licensing, and I really hope people will improve on this design.

Looks very similar to Adafruit's version

That's a compliment if you can't see the differences ! Being as similar as possible is actually a design goal. If your point is that this patch is small/irrelevant, then... check previous Q&A ;)

Will this shield be produced in volume

I've designed it because I needed it. If people ask for a production run, I/we (Electrolab) may consider it.

Troubleshooting

It'd be way too easy if I document this for you ;)

TODOs

Wishlist for next revisions

  • check signal names (eg motor x forward should behave as expected)
  • protect reverse polarity on power plug
  • do something about the poor servo power design (including move that 2pinheader that shorts on the USB connector... what a pitty !)
  • think about polyfuse on Vin jumper (protect arduino 5v reg)
  • bring led on D13 up
  • decide on high/low PWMing in HW (inverter, or other enable - even if not recomended by spec)
  • add revision info sticker on pcb (datecode, SN)
  • make the pcb easier to manufacture (DIY friendly)
  • add option for unused pins wire soldering
  • change led resistor value (maybe 5k or even less)
  • release a proper lib/code examples for specific features
  • design a better silkscreen (eg servo1 & servo1...)
  • add holes for heatsink mounting
  • check how hard it'd be to be able to chain two of such boards to drive 4 steppers (RAMPS style) : mostly connector issues to chain shift registers + SW to drive it, I suppose... even it'd be more clever to do an all in one platform directly.
  • experiment with paralleling outputs and max power
  • implement end of line testability in a more easy manner (eg testpoints)
  • try to mess with a current-loop mode firmware
  • check/think about a small volume production price
  • your wildest dream here ! :)

TODO for this page

  • Move those pics to a sub-page/download, or sort them.
  • Add a true overview pic with the board and adapted motors/loads.
  • Create assembly sub-page
  • Clean this page
  • Add history/release notes in an explicit way