PDA

View Full Version : Cheapest MC that fulfills my needs?



Firestorm65
03-03-2009, 08:46 PM
Hi,

What is the cheapest MC that could be used to hold a program to control 1 motor, 2 servos, 2 IR or light sensors, 1 accelerometer, and 1 other sensor, so 3 out and 4 input. This is for a swarm bot, so nothing sophisticated is needed beyond this. Also, the smaller the better, I have a board to communicate through serial so it doesn't need to be on each chip.

Thanks

Adrenalynn
03-03-2009, 09:02 PM
Inadequate info. What kind of motor? I'm not aware of any microcontroller that has a motor controller. You'd need a board that has a microcontroller + a motor controller - or an external motor controller that the micro can talk to.

sthmck
03-03-2009, 09:08 PM
Get a boarduino, and a motor controller. That should be good enough.

Firestorm65
03-03-2009, 09:19 PM
Is there anything cheaper or anywhere I could get the parts necessary for around $10, especially if I go a direct solder route? I am shooting for a unit price of the entire bot at $20, $33 tops. Perhaps certain items on ebay that would be good for stripping for parts?

Edit: If I just get an ATmega168, would I be able to make what I need? What do I need for a motor controller?

darkback2
03-03-2009, 09:49 PM
Look for the Lego NXT brick. It can control lego servos, and with some bread boarding can support standard servos. You can also hack the cables to control standard motors. Not sure how cheap you can get an NXT brick for though. If you starting from scratch, and own nothing then $33 would be a stretch...

Depending on the strength needed in the motors you could use continuous rotation servos...or hacked standard servos and mount your own wheels...check out MG995s...you can pick them up for under $10 a piece...which would put you over your limit...

OK...I'll stop now.

DB

Adrenalynn
03-03-2009, 10:00 PM
Unless you're doing very large volumes, I think you'll have problems meeting that goal.

Sure - you could go with the ATMega168 - but you've still neglected to tell us what size motor you're looking at. Voltage, current draw, ... ? That effects what you need for driver transistors.

Plan on more than half of your goal price just going to print the board. Processor and discreet parts will be another half of your goal price. Motor and servos will exceed your entire goal price. Wheels probably half your goal price again. What are you going to mount it on? Plan on half your goal price there.

As you can see - that's not terribly realistic unless you're building at least 5000 unit quantity.

lnxfergy
03-03-2009, 10:29 PM
Hi,

What is the cheapest MC that could be used to hold a program to control 1 motor, 2 servos, 2 IR or light sensors, 1 accelerometer, and 1 other sensor, so 3 out and 4 input. This is for a swarm bot, so nothing sophisticated is needed beyond this. Also, the smaller the better, I have a board to communicate through serial so it doesn't need to be on each chip.

Is there anything cheaper or anywhere I could get the parts necessary for around $10, especially if I go a direct solder route? I am shooting for a unit price of the entire bot at $20, $33 tops. Perhaps certain items on ebay that would be good for stripping for parts?

Edit: If I just get an ATmega168, would I be able to make what I need? What do I need for a motor controller?

Have you sourced motors/wheels yet? I find the drivetrain of small robots typically cost 1-2x as much as the controller. For something about 4x4" these would be great : http://www.solarbotics.com/products/gmpw_deal/ but you will be at $16 in drivetrain. For something 2.5x2.5" or so, http://www.solarbotics.com/products/gm10w_deal/ but even more expensive, $20 for drivetrain. Either could be driven by a SN754410 quad-half-h-bridge (read: dual motor driver), Digikey sells them for about $1.65 (qty 10 i believe). If you don't want to add the cost of a 7404, you have to either do some funky code to use 4-IO-lines (see my SVN server for examples) or use 6 with simpler code. 2x motor = 1-bit timer/counter + 2 PWM channels.

2x servos = 1x16-bit timer/counter + 2 PWM (assuming we dont want to generate the pulses in software... which we probably almost certainly don't). Also note, cheap micro servos will run at least $5 each and more likely $10 for something that won't explode. Servos are also gonna constrain your choices for clock sources, external crystal adds 0.50$ to a dollar.

Accelerometer... this can be tricky.. cost is probably gonna be $20-30, and interfaces range from I2C to SPI. On the mega168, the I2C is on analog pins, so you lose 2/6 analog pins. 2x light sensor = 2xAnalog. 1 other sensor... what kind? I'm guessing a sharp IR/something else analog.. note price.. but also note there goes an analog. All of these sensors are gonna cost money, I typically figure a small wandering bot uses sensors = 2x drivetrain in cost (4x controller costs). Specialized sensors (fire fighting, more accurate localization, etc) can easily kill this rule...

So that means our micro needs I2C/SPI + 3channels of ADC (watch out, if I2C is on ADC ports, need a 6 port ADC), and one 8-bit and one 16-bit timer, each with 2 PWM. I think the ATTINY48 could do what you want.. but note it only has 4K of ROM, 256 ram... but its only 1.36$ QTY25 from Digi.

Remember, you're still gonna need a programmer (AVRISP2 or similar), plus headers for ISP. Swarms typically require communication between them.... note that the Tiny48/88 lacks a standard serial port, which brings you back to the mega168. And what exactly are you gonna use for communication, XBEE, or some other serial device?

-Fergs

Firestorm65
03-04-2009, 01:38 AM
So it is a GEV, aka a WIG etc. that will be randomly searching for something, let's say a cell signal for now. (plans have changed slightly) It will fly around avoid obstacles until it finds what it's looking for. Plans call for a converted balsa wood rubberband wingship with two motorized propellers for steering and propulsion, two IR rangefinders at 45 degrees off the nose in each direction, and one "main" sensor for whatever it's looking for. As a WIG, it doesn't need a lot of force to stay barely aloft, with a two foot wingspan it will only be a foot off the ground. It will be balanced enough that roll and pitch are set. It will carry instructions to turn away from obstructions closer than 5 feet and that is the only search algorithm. If it finds something, it will revert to a circling pattern unless it goes out of range, that is all. Cheap and dirty, relying on numbers to cover failures. Two $3 motors should cover each drone. If I only need a $5 microcontroller, a $1 rubberband plane kit, two IR or light sensors, and one main sensor, what else is needed?

Summing up, dump the servos for a second motor, no accelerometer, direct drive of propellers so no drive train, balsa so light and cheap, and a 6V lithium cell battery, 30 minutes would be wonderfully above expectations. What is the least I need to buy to control it, don't mind doing direct solder to MC's. Communication is simply they don't bump into each other and possibly a flashing LED in addition to the circling.

And it is only now I realize this is probably in the wrong section, sorry about that.

Edit: I realize I have yet again failed to provide all the necessary information in my OP; I guess I expected you to all read my mind :P

ScuD
03-04-2009, 01:55 AM
I suggest you go to either microchip.com or atmel.com with your requirements, and search the microcontroller tables for the cheapest controller that has what you need.

For driving the motors you don't need an H-bridge since they will only need to go in one direction, a simple FET might do.
With this size i guess you're going for something like a pager motor, so a 2n7002 (or 2 in parallel, stacked one on top of the other if needed) could do fine.

Basically you just need some electronics, so it can be done for this budget, but this is not going to be an easy project.

lnxfergy
03-04-2009, 07:17 AM
So it is a GEV, aka a WIG etc. that will be randomly searching for something, let's say a cell signal for now. (plans have changed slightly) It will fly around avoid obstacles until it finds what it's looking for. Plans call for a converted balsa wood rubberband wingship with two motorized propellers for steering and propulsion, two IR rangefinders at 45 degrees off the nose in each direction, and one "main" sensor for whatever it's looking for. As a WIG, it doesn't need a lot of force to stay barely aloft, with a two foot wingspan it will only be a foot off the ground. It will be balanced enough that roll and pitch are set. It will carry instructions to turn away from obstructions closer than 5 feet and that is the only search algorithm. If it finds something, it will revert to a circling pattern unless it goes out of range, that is all. Cheap and dirty, relying on numbers to cover failures. Two $3 motors should cover each drone. If I only need a $5 microcontroller, a $1 rubberband plane kit, two IR or light sensors, and one main sensor, what else is needed?

Summing up, dump the servos for a second motor, no accelerometer, direct drive of propellers so no drive train, balsa so light and cheap, and a 6V lithium cell battery, 30 minutes would be wonderfully above expectations. What is the least I need to buy to control it, don't mind doing direct solder to MC's. Communication is simply they don't bump into each other and possibly a flashing LED in addition to the circling.

And it is only now I realize this is probably in the wrong section, sorry about that.

Edit: I realize I have yet again failed to provide all the necessary information in my OP; I guess I expected you to all read my mind :P

I feel like the physics of this might be off. I'm by no means an expert on airpfoil design, but I feel like a "rubberband airplane kits" don't actually have any aero lift from their wing airfoil, the idea is that they just fall slowly due to light weight and because they go fast forwards they look like they go a long ways. If you can't generate any aero lift off the wings, you can't hold your altitude.

The next issue is "balanced enough that roll and pitch are set". Correct me if I'm wrong, but it seems this is infeasible. Without pitch feedback (via tilt switches or more likely an accelerometer) you can't possibly hope to keep your altitude... as battery voltage drops, the motor speed will too, until the plane falls out of the sky...

-Fergs

Firestorm65
03-04-2009, 08:24 AM
A WIG has a maximum altitude of approx. 1/2 wingspan. A balsa kit would need heavy modification to use, if it would work at all. So a 2' wingspan ship would fly at 1', despite having the angle of attack to go higher if it had enough lift. At this scale, it might actually be only 6", but that is fine for my purposes.

SteamBoat
03-09-2009, 08:29 PM
Use a foam RC Airplane instead of wood.
http://www.instructables.com/id/Foam_RC_Airplane/

http://www.metacafe.com/watch/973764/6_foot_epp_foam_rc_model_airplane_flying_wing/

Many more places to get info on that.

MArk B.

Firestorm65
04-05-2009, 02:33 PM
Can a microcontroller like the aurduino control the speed of a dc motor? If not, does anyone know a a one-board solution that can take one input and adjust the dc motor speed based on an on-board program (at 6V would be perfect) for less than $30?

Adrenalynn
04-05-2009, 04:38 PM
I was going to say "what size motor" - then I saw the < $30 and decided not to ask. ;)

Firestorm65
04-05-2009, 04:57 PM
We want to have a program that relates input from this sensor (http://www.trossenrobotics.com/sharp-ir-distance-sensor-gp2y0a02yk.aspx) to variable speed in this motor (http://www.trossenrobotics.com/store/p/4209-24-1-16mm-Spur-Gearmotor-FF-050.aspx). Anything that can be programed and fits the bill would work. Minor circuitry assembly acceptable. We were looking at this board (http://www.trossenrobotics.com/store/p/5932-Arduino-Pro-Mini-5V-16MHz.aspx), but I don't know enough about speed controllers to know if there is a way to make it work.

Adrenalynn
04-05-2009, 05:43 PM
That'd work. For a nanosecond or two. Have a fire extinguisher close by. ;)
Fergs has got a board, I believe, that might fit the bill at probably double that price.

Firestorm65
04-05-2009, 06:54 PM
The motor is rated for 6V, so if everything is put to 5V by the MC (I know enough not to overvolt that!), why would it fry? Sure, I lose some of the power of the motor, but not that much, right? I don't know. I only need a couple speeds, so if an analouge range is too tough, maybe a few "digital" settings? I know how to program them and use servos, but after that my knowledge is painfully limited.

How does a speed controller work? Can a few transistors and a MC get a similar effect?

lnxfergy
04-05-2009, 07:15 PM
Ok, you really need to google around and learn about transistors and h-bridges.... a quick overview:

1) Arduino can source/sink ~15-20mA of current from each pin - MAX - anymore, it fries.
2) Motor requires ~500-1000mA (possibly more, possibly less, depends on the motor, but thats a pretty good estimate I think for the small banebots).
3) You need to create 500-1000mA using just 15-20mA - use a transistor/mosfet/h-bridge. You basically use the arduino output to switch the current on/off to the motor (a small current switches the larger one on/off).
4) If you connect the leads of the transistor to +V (voltage of your battery), and then run the other lead through the motor to ground, when you turn it on, you get a full +V through the motor.
5) To get speed control, you pulse the arduino output on/off at a high speed -- PWM (pulse width modulation). 6) This has the effect of pulsing the transistor output on/off, because the motor doesn't start/stop immediatly (inductance at work), it appears that you have set the voltage at the motor to something less than +V - for instance, if your arduino output is on half the time, the motor gets about +V/2 through it.

7) You probably don't need a full h-bridge because you only need one direction on the motor. You'll have to size the transistor/mosfet based on the size of the motor's load.

-Fergs

lnxfergy
04-05-2009, 07:18 PM
That'd work. For a nanosecond or two. Have a fire extinguisher close by. ;)
Fergs has got a board, I believe, that might fit the bill at probably double that price.

An AVRRA Mini would be able to source about 1.1A per motor, you could tie all four channels together for a theoretical 4.4A, but that would require some serious heatsinking. These are the boards being used for the Mech Scoring/Mechdar unit.. you could talk to tybs to see if there are extras available, but mech contestants will get first dibs on them.

-Fergs

Adrenalynn
04-05-2009, 08:20 PM
Yeah, the motor he's looking at stalls at 1.8A.

I think Fergs answered your question, in case it wasn't clear enough though: The MC puts out around 15mA. You want to suck a hundred times that through it and more. Poof! Next!

Firestorm65
04-05-2009, 08:24 PM
So what do I need? I need off, on ~2/3, and full. I showed you the sensor and the motor, and the battery will be 5V Li-ion. I have $30 that I can spend on a "brain", maybe 8 lines of code if that. How can this be accomplished?

Adrenalynn
04-05-2009, 08:27 PM
Maybe time for a redesign. Toothpicks and rubberbands probably fit the price-point. With creative use and a popsicle stick frame, you can probably get it done.

Firestorm65
04-05-2009, 08:32 PM
$30 is just for the brain...

we already expanded the budget dramatically because we realized we didn't want to do that much work.

Adrenalynn
04-05-2009, 08:44 PM
I know. The "brain" and motor controller. Together. Nod.

I'll sell you a Make Controller with a SAM7 and dual 6A controller for $24.99 [+$199 s/h]

:eek::wink:

Firestorm65
04-05-2009, 10:42 PM
Why is it that expensive? RC cars have motor controllers for higher currents and a microcontroller instead of an r/c controller is $18. Taking an X-Mod as a HIGH estimate ($25 for the whole car gen1), how can the motor controller be worth more?

lnxfergy
04-05-2009, 10:50 PM
Why is it that expensive? RC cars have motor controllers for higher currents and a microcontroller instead of an r/c controller is $18. Taking an X-Mod as a HIGH estimate ($25 for the whole car gen1), how can the motor controller be worth more?

The primary problem here is quantity -- you are buying 1, they are buying 10 million. Companies give you a HUGE price break when you buy in HUGE qty. Just go look around digikey, a single ATMEGA168 is about ~$4.10, get 25 and it drops to ~$2.50, buy a million and its probably a $0.40 (tradeoff of course is leadtime, you buy a million avrs, its gonna take a few weeks to make em).

That micro also has the cost of a PCB, made maybe qty 100 at a time I would guess, as opposed to larger qty, that makes an even bigger difference in cost. A single prototype might be $500 for a board, but in a qty 5000 just be pennies.

-Fergs

Firestorm65
04-05-2009, 10:59 PM
I don't need a custom job prebuilt. If I knew where to find out how to DIY I would. I am not above using a breadboard etc. There is something wrong if you are telling me the only way to control a $13 dc motor is a $200 board.

lnxfergy
04-05-2009, 11:03 PM
I don't need a custom job prebuilt. If I knew where to find out how to DIY I would. I am not above using a breadboard etc. There is something wrong if you are telling me the only way to control a $13 dc motor is a $200 board.

I'm not saying you need a custom board, I'm simply explaining why that Arduino board, or anything you can buy out there, is more expensive than your X-mod.

Everything you see on Trossen, Sparkfun, etc, is all small qty compared to what you buy in Radio Shack. Thus, they pay more to produce, and engineering costs are not as widely distributed across a larger qty of sales.

-Fergs

Firestorm65
04-05-2009, 11:09 PM
The aurduino board is $18. I am looking for anything around or less than $12 to go from servo control to motor speed control in a very limited way. I only NEED 3 settings including off.

lnxfergy
04-05-2009, 11:15 PM
As for actually controlling motor: you need a motor controller (such as an AVR, or any other micro, clearly you probably already have a micro for a brain on the robot, just use the same one) and a motor driver (the thing that creates the high current needed by the motor, such as a transistor or H-bridge).

Possible motor driver candidates include:

1) a tip41 - probably gonna max out at about 1.125A though (given 15mA from AVR) (cost $1)
2) tip41 + signal transistor in darlington configuration (or a darlington transistor itself) -- probably gonna handle enough current. (cost $1.50)
3) 2x tip41 in a darlington configuration (or a tip111?) --- way more current than you need (cost $2)

all of the above will need appropriately sized resistors on the base current leg... you'll need to learn about transistors to control motors.

4) SN754410 - quad half h-bridge, if you tie all channels together, you could get 4.4A (each is 1.1A) -- but you probably need a good heatsink. (cost $2)

The reality of what I am telling you is this: in the world of electronics (and the world in general), time == money, you can either take the time to learn how to use the available circuits and save some money, or pay the money to buy something someone else has built that does the job for you (whether it be an off the shelf component, or a custom job) and save some time. There is no free lunch, you can't have your cupcake and eat it too*.

-Fergs

*unless you have a reprap, and it starts printing more cupcakes for you as soon as you eat one... hmm....

lnxfergy
04-05-2009, 11:19 PM
The aurduino board is $18. I am looking for anything around or less than $12 to go from servo control to motor speed control in a very limited way. I only NEED 3 settings including off.

You can easily build a motor driver on a protoboard for <$2.50. For your micro, use a smaller AVR (we already had that discussion above.....), skip the crystal, run it on the internal oscillator - $2-4 depending on variant chosen. You'll need a programmer though, thats $30, but you only need 1 for all the AVR-based bots you ever build... its just another tool

-Fergs

Firestorm65
04-05-2009, 11:56 PM
Is there any chance to get that in a rough diagram form? I am having trouble following.

ScuD
04-06-2009, 12:22 AM
Welcome to the jolly world of electronics.
If it's been built, you can't build it cheaper. period. There's capitalism for you.

Firestorm65
04-06-2009, 12:40 AM
If only I knew where to find a schematic or diagram or something...

Adrenalynn
04-06-2009, 01:31 AM
Make one! You can find a schematic where ScuD, Fergs, Jes, Me, etc find them. Start with a datasheet and work forward.

robologist
04-06-2009, 02:04 AM
There's a simple circuit pictured here, from Google :
http://www.neufeld.newton.ks.us/files/electronics/mosfet-motor/MOSFET-motor-driver.png

This is a bit screwy in that it will invert the PWM coming from the micro, and be somewhat slow in the frequency it can handle, in addition to the lack of a flyback diode across the motor terminals. What I would suggest is something like a TC4427 driver pushing an IRFZ44N MOSFET through maybe a 20 ohm resistor, and a 1N5817 Schottky as a flyback across the motor terminals. Think that sounds like about $5 worth of parts, plus shipping and a board to put them on.

Adrenalynn
04-06-2009, 02:07 AM
>> Think that sounds like about $5 worth of parts, plus shipping and a board to put them on.

And the micro. And the programmer. :)

robologist
04-06-2009, 02:25 AM
>> Think that sounds like about $5 worth of parts, plus shipping and a board to put them on.

And the micro. And the programmer. :)

Yeah, I remember, but he did say something about an $18 Arduino somewhere, so those bits should finish it off. If he can learn to program the Arduino to output PWM.

lnxfergy
04-06-2009, 07:07 AM
Seriously, if you understand how a transistor or an h-bridge work, creating a schematic is not difficult all (in fact, it's trivial using any of the parts I listed above as options). The problem with us just giving you a schematic is, when you end up putting it together, you have no idea how it really works -- how do you plan to debug something you don't understand!

http://tinyurl.com/dh7ar7

-Fergs

Firestorm65
04-06-2009, 11:12 AM
Will this work? http://www.robotshop.us/solarbotics-l293d-motor-driver-kit-2.html Is this what I should be looking at? Remember, I only need to control 1 motor with an aurdiuno. And as much as I would like to sit down and learn it first, this project requires that I need to know what to buy now.

lnxfergy
04-06-2009, 11:18 AM
Will this work? http://www.robotshop.us/solarbotics-l293d-motor-driver-kit-2.html Is this what I should be looking at? Remember, I only need to control 1 motor with an aurdiuno. And as much as I would like to sit down and learn it first, this project requires that I need to know what to buy now.

Your motor needs 1.8A, that gives 1.2 amps... explode!

Look at that SN754410 chip, its pin-for-pin compatible with the L293D, but can do 4.4A if you tie all the channels together.

-Fergs

Firestorm65
04-06-2009, 12:15 PM
So you can add the channels to get to the 1.8A required?

Are there any other components I will need besides wiring?
-IR Sensor
-6V camera battery
-DC Motor
-Aurduino Pro 5V
-5V button cell
-SN754410 chip

ScuD
04-06-2009, 02:34 PM
Typically you can add channels to distribute current flow, but be aware that any chip has a maximum power rating over all its outputs at any given time.

Here's a quote from the datasheet from the chip Fergs just recommended:

Continuous total power dissipation at (or below) 25&#176;C free-air temperature (see Note 2) . . . . . . . . 2075 mW.

2. For operation above 25&#176;C free-air temperature, derate linearly at the rate of 16.6 mW/&#176;C. To avoid exceeding the design maximum
virtual junction temperature, these ratings should not be exceeded. Due to variations in individual device electrical characteristics
and thermal resistance, the built-in thermal overload protection can be activated at power levels slightly above or below the rated
dissipation.

Reading further on in the datasheet, you'll see that the high-level output voltage at 1A, with a junction temperature of 25&#176; is typically VCC2−1.4.

So one might say you can have 1.4 * 1A = 1.4W per channel continuously, yet with two channels you've got 2.8W, which is already over the 2.075W rating.
Hah. I might be reading this wrong, but I've come across a lot more of these little discrepancies in datasheets before.

But guess what, that's where the PWM comes in. It'll prolly work fine as long as you cool it sufficiently, since you're not supplying a constant current, rather a chopped one, which lowers the average power dissipation.

Hm, guess i haven't helped much here. Back to the shed!

Firestorm65
04-06-2009, 02:53 PM
I have to put the order in soon. Is there anything besides wire and scematics that I am missing on my list? I have the connector for the Arduino already.

robologist
04-06-2009, 04:35 PM
The little h-bridges like the L293D and 754410 have been used in paralleling, but it is not a good practice. BJT based h-bridges have a negative temperature coefficient, that is, their resistance decreases when the temperature increases, causing the transistor to heat more, pushing more current, etc. to failure. These are internally protected a bit from this in that they try to go through a thermal cutoff, but may not make it. Additionally BJTs drop a volt or 2 across their internal collector emitter junctions.

MOSFETs have a positive temperature coefficient (http://en.wikipedia.org/wiki/Positive_temperature_coefficient), so they increase resistnance with greater heat, essentially self protecting, and allowing easier parallel usage. And they lose a lot less voltage across their Drain Source junction.

jes1510
04-10-2009, 11:31 AM
Buy a real RC ESC. If you don't then you are going to be asking for trouble in the future if you don't understand how this stuff works and throwing your money away.

For the airframe perhaps this thread will help:
http://www.rcgroups.com/forums/showthread.php?t=962523

Do you fly RC planes? This is an incredibly complicated project and the flight dynamics are not trivial.