GPIO

Hi I bought an arm development board, there are some GPIO pins, one

3.3V pin and one 5V pin. I want to use it to drive 12V motor. So i have two problems now: 1) the voltage is not enough 2) the motor need 2.5a current, but i don't know my developmen board can give this or not.

I am a programmer, so i want to learn how to use the GPIO to drive something, what kind of electronic tutorial i should read to accomplish this mission?

thanks from Peter ( snipped-for-privacy@hotmail.com)

Reply to
cmk128
Loading thread data ...

Hi Peter,

I'm afraid I won't be able to answer all your questions, but maybe I could start you off, hopefully in the right direction. Hope someone else will fill the details.

First, when you say 12V motor I suppose it's some kind of a stepper motor. I was recently involved in a project where I saw the designs for an AVR microcontroller driving a stepper motor, so I suppose it's something similar to your request.

For the missing 12V P/S, I suggest you build one yourself using a

12-volt stabilizer IC (i.e. 7812). The basic circuit is extremely simple (only two additional capacitors required) and you should be able to find it in the chip's datasheet. You would need to share the GND between your board and the "motor module" and you will need an input of at least 15V to drive the stabilizer. Now you don't have to worry about how much current the motor needs since it has it's own P/S.

And for controlling the motor, I suppose you also need 12V. For this you will need a motor-driver IC which converts your signal (i.e. 5V) to 12V with enough current to drive the motor's controls. The design which I saw used some chip marked ULN 2003A. You should look for the datasheet and see if it suits your needs.

Hope this is what you were looking for.

As for this, I'm not really sure... Maybe you should start with Electronics For Dummies (NHF :)), just to get you started, and then check out some projects with microcontrollers (there are quite a few books on the subject). I'm primarilly a programmer myself but I have some formal education in electronics so I found this easy enough to understand. I'm not sure how it would work in your case but you should at least try to learn some basics including building a stabilized P/S, playing with LED's and 7-segment displays, working with basic gate (logic/buffers/drivers) chips (the 78xx series), buttons, switches, etc. Hopefully, you should be able at least to learn how your development board works without much trouble. After that, sky's the limit.

The best of luck!

Regards,

- R.

Reply to
Roland

There are way more than stepper motors out there for 12V. I'd never suppose it is a stepper motor from the info 12V.

Sure. For 2.3A Current? You bettre stop giving advice ...

WRONG. You have to worry. A lot. Given a 24V general power supply and your circuit it will give 12*2.3 W on losses. Unacceptable. Simply stupid idea.

Go to bed. It would be better for you. Take some pills and stop confusing.

For steppercontrol one usually uses an L297 [Controller] + L298 [driver] (Or similar)

ULN2003 is a transistor-array for low currents (for small steppers it can be used...)

formatting link

I suppose it wasn't.

Oh! How comes! Stick with that and leave the peripherals to someone else.

Where did you get it? I need to know to warn others.

Ger back to school.

No. It's the 74 Series. And then there's the 40xx Series.

Only in your dreams.

Studying electronics is fun. But it's hard work too. And it is expansive (measurement instruments...)

I suggest reading "The Art of Electronics". Bye yourself some parts, a prototype-board and start to build things. Maybe there are experimentals cases for kids available for you. They usually explain things in quite an easy way.

My design would look somewhat like that:

+12V 620 Ohm + +12V ___ | + .-|___|-----o | | 0,25 W | | | |< | o---------| BD140 | | |\ | | | | | | .--o .--------. | | | | | | | | 1N4001- '------< motor | | | ^ | | | | | .------< | | | '--o | | | .-. | '--------' .-. | |100 Ohm | 6k2 | | | |2W | . 0,25W| | '-' | '-' | | INPUT _2k2Ohm | | | ####-|___|-. | | | 0,25W| | | | 3.3V | |/ | |/ or o---| BC548 o------'-| BDX39C 5V | |> | |>

.-. | .-. | 2k2Ohm| | | | |620 Ohm | 0,25W | | | | |0,25W | '-' | '-' | | | | | === === === === GND GND GND GND

Where 1N4001 is a Diode, BDX39C, BD140, BC548 are transistors and the rectangular things are resistors.

The diode is needed because a motor usually returns some energy to the switch when it is switched off.

We need 3 stages because you controller might be able to source just ~2..10mA of current.

xky means x * 1000+y ... so 6k2 = 6200

This information is provided without warrenty whatsoever. Damages can occur if this design is used. If it is used than I can not be held responsible for anything. It's up to the builder to decide if it is correct or not. I don't claim that it will work, since it was designed on paper without building and measuring.

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Reply to
John F

Missed that one! That indeed renders everything I've written utterly useless. Sorry to the OP (NHF I hope), please refer to the design by the rude gentleman. Since the OP said he would like to begin in electronics, I just assumed it was a simple project with a small stepper motor (a resonable place to start) that would be concivable in such ameteurish fashion as I proposed (which is btw. based on a tested and working design, although not made by electronics pros but by my fellow inexpirienced students).

And a question for the rude gentleman: about your design, am I reading it correctly? It seems to me that this is some kind of a "cascading switch" that would only be able to turn the motor on and off. Wouldn't a optocoupler-transistor-small relay combo be a more classical approach, since it is over 2A@12V? Or why not use some voltage driven type of transistors (the high-power type)? Or are you trying to create a cascading amp to allow the possibility of PWM-controlling the motor's speed or something? After you thashing my reply like that, I could at least learn something... Btw. I'm not a big fan of analog electronics and discrete components so bear with me a bit. If I'm properly tutored, you could be spared a nervous breakdown or a heart attack when you read my answer to someone's question next time.

Regards,

- R.

Reply to
Roland

Hi Peter, Roland is trying to be helpful and admits that he is more of a software guy while John's schematic looks neat and will work although his design is overly complicated considering there are better and easier alternatives. On the matter of posting replies it is true that any reply takes time and is usually given with good intentions. However, there is never any need for harsh criticism from any quarter and really it benefits no one.

Just use an N-channel logic-level fet that can handle the current and drive the gate of the fet directly from your gpio. 3.3V is kind of low but should be ok and you might be able to use a pull-up to +5V and run it in open-drain mode (turn off output for a high, set output direction for low) if you cpu is 5V tolerant.

Bear in mind that although your motor might only draw 2.5A during normal running that this is not the case when it is under load or starting or stalled in which case you can expect practically a "short-circuit". The

+12v power-supply for the motor should be separate or if the logic supply is regulated off the +12v line then some provision for filtering and stabilizing the logic supply is needed. An unregulated supply will be ok to use just as long as it close to the required voltage.

You will need an N channel logic-level power FET and more than likely one in a TO-220 equivalent package mainly for the power rating. Some I have used are VNP3507 and IRF3205 and these look like they are way overkill, but trust me you'll need them or haven't you heard that "smoking" is a health hazard :)

The fets include a source-drain diode that is suitable for inductive loads. What you might find is that if you kill the power while the motor is running (assuming a DC brush motor) that the motor acts as a "dynamo" and pumps power back into the supply though the source-drain diode while it is spinning down. You might need a diode in the motor supply to isolate this "phantom" power during an emergency stop.

BTW, I usually include a current limit resistor of around 10K from the GPIO to the gate of the fet. This is not needed for the normal operation but just helps to protect the fragile GPIO pin in the event of a catastrophic breakdown of the fet which can shunt the +12V supply through the drain-gate to the GPIO and taking out whatever else it may end-up shunting to from there.

.----------------. | | | | +5V o---------. C| | (opt) | C| MOTOR | .-. C| | | | PULL-UP | | | | | /+\ +12V '-' ||-+ ( ) POWER | || can give this or not.

Reply to
Peter Jakacki

Peter Jakacki =E5=AF=AB=E9=81=93=EF=BC=9A

thank you everyone

Reply to
cmk128

And all this can be replaced by one single mosfet.....

Meindert

Reply to
Meindert Sprang

Usually GPIOs default to inputs, so the motor will likely run uncontrolled at startup or during a reset, program reload etc.

So perhaps a pull-down would be better, but then the mosfet would need to be carefully chosen so as to switch fully on at the lower voltage (~3V).

--

John Devereux
Reply to
John Devereux

[snip]

Depends. If you are using 3.3V logic it can be hard finding _one_...

formatting link
is one. 30A max. at 3V U_GS.

Of course you can still add a bipolar driver and reverse your output inside the µC.

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Reply to
John F

Can happen :-) I admit that I was in a somewhat bad mood by then. Sorry for that.

Well, for a small stepper your solution might work, but even there are bigger ones with higher tork and thus with higher currents. (Big things = Things that hurt when they are falling an your toes :-))

Would you like to turn it just on (x)or off? IMHO it makes sense to turn it on and off too :-)

Relays aren't used in such cases any more. MOSFETs are.

My Solution was intended to make people think and probably learn. :-) It worked.

That's what a FET is.

As I replyed downthread a single MOSFET can do all of it

formatting link
is one of those logic level types. At 3V input it is able to sink 30A approximately. Schould be enough :-)

formatting link
is a little less over-powered. It might not be able to sink the current the motor needs to runn off when used with 3.3V.

This can be done anyway. Any switch can switch on or off. It would take a little more for controlling it with PWM. That's too much to explain here (see second link below). Some good application notes can be found on that from various sources.

Fundamentals:

formatting link
(appchp1.pdf .. appchp7.pdf)

Everything on motors:

formatting link

I hope so! That's a great way to do so. Most others would have gone and stopped asking. Congratulations for taking the opportunity.

lol :-) No. It wasn't that serious. As I already said. Bad mood. My apologies for that. Sorry. IIRC it was already past midnight over here then too...

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Reply to
John F

No prob. ;) As for 2.3A, I somehow simply read-over ignoring it. My computer architecture/software-distored view of embedded world as small, low-power devices is probably to blame.

Of course, I seem to have been over-eager to add control to a motor that possibly has no means for it.

I was wondering about that, in fact. My education in electronics was highly theoretical (fundamentals of solid state semiconductor physics and planar technologies, amps and multivibrators circuit analysis, feedback analysis, frequency analysis and such) and for me FETs seem to be ideal elements for such switching, them being voltage driven and sinking low currents and in a matter of speaking separating input circuit from the output. But all the designs I came across used BJTs (mostly BC547/8) for switching and supposed there was a reason for it and blamed my inability to bridge the theory/practice gap for the inability to think of a reason why (knowing that there are really high

-power FETs). So FETs _are_ used outside of CMOS ICs and JFET amps, I'm not crazy? ;-p

I was wondering if the PWM switching speed would dismiss the possibility of using a relay (me thinking that was the classical way to do it) and if that was why the transistors were used. Since I continued my education in computer engineering, not electronics, I still have some issues with the basic concepts, i.e. deciding whether a ciruit works as an amp or a switch without calculations and if the PWM is alternating between levels fast enough, would it constitute a need for dynamic analysis etc. etc. I have enough problems in my basic fields of interest without that. ;)

Thanx for the links, the second one seems really interesting, it's been a while since I saw anything to do with motors similarily.

Yeah, it was kindo' late. :)

Cheers,

- R.

Reply to
Roland

Natural but wrong assumption as CNC machines that do a lot of materials bashing and other tasks have embedded controllers and lots of higher power motors etc..

Relays and motor control is an issue without some form of starter/stopper circuit as often the relays (or mechanical switches) can end up with high current and/or voltage surges damaging the contacts. .....

--
Paul Carpenter          | paul@pcserviceselectronics.co.uk
    PC Services
              GNU H8 & mailing list info
             For those web sites you hate
Reply to
Paul Carpenter

I know that, and I know that there are embedded diagnostics computers even in giant turbines and generators but still my mind tends to associate the embedded world with something small. You could call it a professional deformation, NHF hi-power guys. :)

Would you care to elaborate this a bit, if it's not too much of a bother? I thought that such current/voltage spikes could be eliminated using protective diodes + coils and/or capacitors, but I've never seen many designs using relays so I'm a bit in the dark about this.

Thanx!

- R.

Reply to
Roland

That is true for information shoveling devices :-) I do more hardware and analog. I admit that most embedded stuff is just under my hood when it comes to plan&buy. I let things be done.

How comes? No. I thought it would be a good idea to switch it on and off ...

Indeed they are. Modern electronics are full of them. Bipolar still have their field. But when it comes to switching, MOSFETs are the choice (they do not need any power to switch on, whereas a BJT neets the base current to stay on, which is quite hich in the saturation area [B~10..50 instead of 100..500])

No currents! Their gates are insulated by SiO ... hence the Metal _Oxide_ Semiconductor naming. The only time they need current is to recharge the inputs capacitance...

Not quite. For such things you need an optocoupler... Then you really have a separated circuit (some thousend volts are possible as difference).

max. Ic=100mA or 250mW get a datasheet from infineon they are best for the 54x.

Yes... They are cheap like salt :-) Nowadays 84x is more common (SMD versions of the 54x)

As you say here. There are millions of different components. I just picked the ones that I'm used to pick in my designs.

If you want to learn on, get the "Art of Elecronics" (Horowitz/Hills) which is somewhat old but the fundamentals don't really change that fast.

Not at all :-) (Or should I know something ;-P)

Relays are seldomly used any more. A FET is much cheaper... if you need to switch let's say a trunk for 380V/6A then some kind of relay might be worth using. If you need to transport current in both directions there are CMOS switches for small currents, but if the currents get higher a relay might be used.

There are transistorized relays without any mechanical contacts or coils in them.

Usually it is not quite hard to tell the difference but you could read on in the AoE on that. They have the basic concepts up to the most sofisticated ones.

Not really. As long as it reaches the final levels not. That's the easy way. If you intend to get defined slopes instead of fast rise- and fall times it will be harder (could be for EMI reasons)

I can imagine :-)

Give it a shot there are very interesting facts on brushless and some other modern concepts...

Yep.

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Reply to
John F

Yes, yes, that's what I meant when I said they sink low currents. Not constantly sinking current, but the mean over time being low. Btw. This discussion made me shudder when I remembered my Semiconductor Electronic Elements book - the thickest and most equation-laden book I own. One of the reasons I kept my nose away form more electronics. ;)

Agreed! Now I was referring to the insulating layer under the gate electrode and again didn't express myself very well. :) Optocouplers sure do seem great, gotta get me one to play with...

Ok, thanx a lot for the explanations and a bunch of tips! I will try to get my hands on a copy of The Art of Electronics (I believe I saw a PDF version somewhere) and check it out. I do think any extra knowledge sure comes handy. :)

Regards,

- R.

Reply to
Roland

They sink _no_ currents ... pA probably, if not even fA...

Most of the time negligible.

Aw... you hardly need any of the things in the big books :-) everything you need is the datasheets, a few tricks to do the calculations, some standard topologies, a few trics to get things stable. That's it! Really!

Any one will do the Current-Ratio is the thing to look for and the max. insulating voltage.

No problem, you're welcome. That's what usenet is for... Next time I might come back and ask for something and then I hope to get an answer too ;-)

I don't think so... its form 1989 ... and several hundred pages and a few 10s of $$... So get a hardcopy. You'll love it :-) I'm still hoping to get a new version of it... But hope's low at the moment. In german there's from Tietze & Schenk - Halbleiterschaltungstechnik (Technology of Semiconductors circuits... or something thelike...) ~

100 US$

Of course ... Knowledge can't be taken away any more (alcohol can ... of course... but not to mention it)

BTW... viva italia ... Great game, Germany lost within the last minutes... or the other way round ... Italy won within the last minutes :-)

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.
Reply to
John F

Since you are new to this(programming an interface with the real world), I reccommend that you look into configuring some of the GPIO for inputs and some for ouputs. Connect some toggle switches to the inputs and LEDs to the outputs with some very simple circuitry. Read(poll) your inputs and drive corresponding outputs. Then you can move on and configure the inputs to interrupt you on state change. This is where you should begin, after all, you are a programmer. Use the GPIO pins as simple digital I/O first.

Reply to
Ivanna Pee

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.