Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » New Race of Robot Overlords

Credits go to Chris Katko, Crazy Photon, Don Freeman, Edgar Reynaldo, ixilom, jhuuskon, someone972, and Timorg for helping out!
This thread is locked; no one can reply to it. rss feed Print
New Race of Robot Overlords
Anomie
Member #9,403
January 2008
avatar

Okay, only kinda.

What kind of hardware would be required to run a small electric motor or two from a USB port, assuming I wanted to affect things like speed? How would I go about setting that up, assuming I had all the hardware? In case the device can't be powered by USB (or it wouldn't provide enough juice, whatever) what alternative would you suggest? My aim is to have as little hardware as necessary on the external device.

This means that I wouldn't like to have the USB port sending commands to a smaller module on the device, which then controlled things itself. I'd like to make a completely basic controlling connection between the USB connector and the hardware, the same way that the microprocessor(or something else, not an expert) has direct, low-level access to activating and disabling the attached devices.

Hope that was vague enough. Thanks.

[add]wallpower = no_good. Portability is important.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

someone972
Member #7,719
August 2006
avatar

If it can't be powered by the USB connector I would use a DC connection jack. Then you could buy one of the voltage converters from RadioShack or the like and plug it in. This way you could have steady power, such as 9V or 5V, that plugs into the wall, instead of the computer.

______________________________________
As long as it remains classified how long it took me to make I'll be deemed a computer game genius. - William Labbett
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why. -Unknown
I have recklessly set in motion a chain of events with the potential to so-drastically change the path of my life that I can only find it to be beautifully frightening.

Timorg
Member #2,028
March 2002

If you need to control exactly how fast the the motor turns, you should look into using a stepper motor.

Edit: The more power it consumes the bigger the battery it will need, and it depends on if you need high voltage or high current or both, to what kind of battery would be most suitable.

____________________________________________________________________________________________
"c is much better than c++ if you don't need OOP simply because it's smaller and requires less load time." - alethiophile
OMG my sides are hurting from laughing so hard... :D

ixilom
Member #7,167
April 2006
avatar

___________________________________________
Democracy in Sweden? Not since 2008-Jun-18.
<someone> The lesbians next door bought me a rolex for my birthday.
<someone> I think they misunderstood when I said I wanna watch...

Anomie
Member #9,403
January 2008
avatar

Quote:

this

That's looking like the USB port sending commands to a microcontroller, which then does stuff itself. This is how most people are handling it, but I'm looking to get rid of the external controller in the scheme.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

Crazy Photon
Member #2,588
July 2002
avatar

How do you intend to handle the USB packets at your device?

-----
Resistance is NEVER futile...

Anomie
Member #9,403
January 2008
avatar

I don't intend to send real 'information' to the device, just something like 'x pin on usb connector 1 is active - activate connection between device_part a and power source'...if that's at all possible in hardware alone.

[edit] But looking at what the pins actually do, it looks like I may only be able to send signals through one or two pins per port.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

Chris Katko
Member #1,881
January 2002
avatar

Simply? You can't. A USB connection requires a microcontroller to both recognize the device and transmit data.

Use a parallel port because you can turn the pins on/off individually. If you just want on/off control, flip transisters or relays with the control line (the parallel port) which then turns the power lines on or off.

If you want precise positions, use a microcontroller and convert the serial port data to pulse width modulation (which steppers use).

Either way, the USB port is useless for simple tasks.

Also, I wouldn't recommend powering it off the USB port. It's not built to power things like motors, save for small low-torque ones on hard drives. You can google for the current limit on the USB 1.1/2.0 specification if you like. But if it's a motor, I'd go for a 12-volt powersupply. You can even take it from your computer's powersupply (easy for desktop, less so but possible for a laptop).

Lastly, If you don't have serial, get a serial or parallel USB connector. I've never used one, but they sell them.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Don Freeman
Member #5,110
October 2004
avatar

If you want to do something like that, go with the parallel port or the serial port. You can easily program what each pin sends / receives.8-)

Edit:
Good to see you back Chris.:D

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

Anomie
Member #9,403
January 2008
avatar

I think I could get by with a simple on/off. Why is it that things like "convert[ing] the serial port data to pulse width modulation" invariably require a separate microcontroller? Is there no way that things like this can be done from the computer's processor? Or is it just a matter of having less clumsy output?

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Something else you might have to watch out for is voltage differentials - the stepper motor might be expecting a different voltage or amperage than a direct connection to the serial / parallel port might provide. This may be the reason for the microcontrollers, but I really don't know that much about this kind of stuff, so don't take my word on this as professional by any means.

Don Freeman
Member #5,110
October 2004
avatar

You shouldn't need a micro controller, you would be doing all the work in your code...hopefully. You can take a look at how Linux does this with it's serial port drivers in the kernel. You can use that as a basis for your study. The micro controller really only helps with the handshaking process: to let the computer know when the data was sent, if it arrived correctly, if the device is ready, etc. Since you are designing this, you must take this all into consideration. You WILL need to have transformers or another such mechanism to handle the extra current. I've seen things that where designed for this kind of work, but it's been a while since my last experimentations into such things.:-/ Here is some useful links to get you going. Serial port, Serial port and Parallel port and Parallel port. BeyondLogic is a good site with a lot of information on interfacing your computer with other things. What happened to the good old days when people could tinker around and create their own hardware relatively cheap...:-/ I'm glad to see there are still people like me out there.:D8-)

--
"Everyone tells me I should forget about you, you don’t deserve me. They’re right, you don’t deserve me, but I deserve you."
"It’s so simple to be wise. Just think of something stupid to say and then don’t say it."

jhuuskon
Member #302
April 2000
avatar

Hooking up motor directly to the serial or parallel port will invariably result in the receiver/transmitter chip frying, so don't. Same goes for relays. You should always use an external power supply and a Darlington, as serial and parallel ports arent meant for supplying peripheral power and even the USB bus supplies only a mere 200mA of current so if you power a relay or motor off USB, every time it's triggered there's a risk you get to reboot your computer to get your USB peripherals working again (the current drain of an engaged relay coil can be 50mA or more and for motors it can be anything really, usually too much, and the excess current drain causes the USB host controller to shut down).

What you should do is to hook up the motor via a Darlington array to a microcontroller, and program that microcontroller to do your bidding instead of a bulky computer.

You don't deserve my sig.

Anomie
Member #9,403
January 2008
avatar

Just to try and make this as clear as I can, my ideal situation (as I see it now) would be:

1. Incomplete circuit(s) between power source and device(s).
2. Manipulation of circuit(s) by attached computer, such that any recognizable activation of a certain pin would complete a certain circuit and activate a certain device.

It seems to me that my computer should be able to handle this task as well as any delegated microcontroller. I'm hoping there's just some construct in circuitry that completes a circuit on detecting an electrical signal from some other source (I assume any 'active' pin has some electrical activity...anyone care to verify that one for me?) And, well, I'm poor. My goal is to make this work with as little specialized equipment as possible. Gotta be resourceful!

Don said:

useful links

Thanks, those're definitely going to come in handy.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

jhuuskon
Member #302
April 2000
avatar

Simple. Connect the data pins from the parallel port to the input pins of a Darlington array, and connect your peripherals to the outputs of the Darlingtons. Just remember that parallel port only supplies +5v and source current can be anything from 6mA to 20mA, so you'll need to check the datasheets so you're not sinking more current the port provides (there is no spec on how much but you shouldn't expect it to be more than 6mA) or you can bet your ass the receiver/transmitter chip will fry.

If you want to do it accross serial or USB port you WILL need to hook up a microcontroller too and start drafting a communications protocol.

You don't deserve my sig.

Anomie
Member #9,403
January 2008
avatar

Okay, I found this, so I assume that by 'Darlington array' you just mean an array of these transistors. I'm not sure how it would work.

http://www.allegro.cc/files/attachment/597280

It seems like the power source would have a constant circuit with the device, and would just get a little boost if the pin was active. Should I cut down the flow from the power source, to the extent that it needs that boost to activate the device? That seems a little wasteful.

[edit] Or does the power-in break at those connections if the pin is inactive?
[edit2] Well, I guess what I've been looking for this whole time is the transistor. It's a neat little thing! Is the Darlington necessary here because the signal from a parallel pin is too weak to flip the connection on?

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

jhuuskon
Member #302
April 2000
avatar

It's a neat security measure. If whatever is at the output overloads the output stage and it burns into a shorted state, it has a smaller chance of frying whatever is at the input side as they are separate transistors. With a single transistor there is a risk that an overload shorts the transistor and the power source starts pumping current into the input, causing the receiver/transistor die a sudden, painful and foul smelling death.

You don't deserve my sig.

Anomie
Member #9,403
January 2008
avatar

Quote:

causing the receiver/transistor die a sudden, painful and foul smelling death.

That'd be...bad. So what else would I need to set this up? I've got a couple standard rechargeable 9v or 12v batteries for RC cars (can't remember which...they're packed away someplace...I might actually have one of each or something). Would a straight connection between the battery and the device be okay? (going through the transistors like that)

Is there some particular type of Darlington transistor that I need? I found a page with a bunch of different types, most of them being around $0.40, but some being as high as $1.50. Any particular motor anyone would suggest, being that the stepper motors are out?

[edit] Or...I could cannibalize the RC cars for motors?

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

someone972
Member #7,719
August 2006
avatar

A direct connection to the batteries should be fine. As for the transistors just make sure that they can handle the current and voltage of the batteries, most will.

EDIT: Make sure that the motor can support the maximum amount of voltage that you will be feeding it.

______________________________________
As long as it remains classified how long it took me to make I'll be deemed a computer game genius. - William Labbett
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why. -Unknown
I have recklessly set in motion a chain of events with the potential to so-drastically change the path of my life that I can only find it to be beautifully frightening.

jhuuskon
Member #302
April 2000
avatar

Well you need to make sure the switching semiconductors (transistors or darlingtons) are voltage compatible with the parallel port. Also make sure the power input and output can take the voltage you are supplying. Consult the datasheets.

You don't deserve my sig.

Anomie
Member #9,403
January 2008
avatar

My battery (could only find one of them) is an old 9.6V NiCd. I couldn't find any amperage information.

So just a couple more questions:
1. Do I need to worry about the voltage from the pin and the battery simultaneously getting at the device(s)?

2. How safe is it to flicker the power to the pin to simulate a slower speed on a motor? Would that work at all?

3. I have no parallel ports. Would you trust a USB-to-parallel converter, or could any other sort of output accomplish this?

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

jhuuskon
Member #302
April 2000
avatar

1.nope.
2. It's called pulse width modulation. It's not that dangerous.
3. If you can get it working.

You don't deserve my sig.

Anomie
Member #9,403
January 2008
avatar

1. Cool.
2. Awesome!
3. Wish me luck.

Thanks everybody. Cookie time.

______________
I am the Lorax. I speak for the trees. I speak for the trees for the trees have no tongues.

Go to: