1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Basic problem with transistors

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by giftiger_wunsch, Jul 25, 2009.

  1. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Hi,

    I'm stuck with what I'd imagine is a very easy to solve problem :eek: I am attempting to interface a robotic arm with a rabbit 4000 microprocessor (the details of each aren't especially important, but the board on which the microprocessor is mounted has five 8-bit parallel ports which have a logic high of 3.3V, and the robotic arm has five motors which are powered by 4 D-type 1.5V batteries in series.

    I'm planning on using pairs of parallel port bits to activate the motors and decide which direction they should move. It seemed logical to do this with complementary highs and lows between the two bits to activate it in each direction, and either both high or both low to cause the motor to stop. If the bits had an output high enough to power the motors directly, the motor could of course just be connected between the two bits; but I am stuck trying to get my head around how the voltage between the two bits could be used to influence the flow and direction of flow of current through the motor from a battery.

    I've thought about using transistors, but I have never used them before and perhaps need a better understanding of them, but from what I understand the input and output circuits need to share either the base, collector, or emitter terminals, and I am unsure how to do this when using two different power sources. I've also considered options involving EX-NOR gates, relays, etc., but I don't seem to be able to come up with a working answer.

    If someone could suggest how this might be achieved I would be grateful. Sorry for the long-winded post.

    Thanks.
     
    Last edited: Jul 25, 2009
  2. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,592
    Likes:
    477
    Location:
    L.A., USA Zulu -8
    Google "H-Bridge circuit". They can be used to drive a motor in either direction from a logic input.
     
  3. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks for the tip; I found some results about H-Bridge circuits, but that was mainly the part I had already figured out for myself. My main problem is with how to make a signal from the microprocessor control the higher power circuit which actually drives the motors (i.e. the H-Bridge circuit). I'm guessing it should be done with transistors, but since one of the terminals of a transistor is shared, that seems to suggest that the two circuits will cross over and I could potentially damage my processor by connecting the batteries across the parallel bits.

    Of course, I could be completely mistaken; as I have said, I've never used transistors before and only know what I've read about them; how / if they can be used with two distinct circuits / power sources seems to be a grey area in the materials I've read.

    I'm going to draw up my basic design (which will probably be fundamentally flawed) and perhaps someone could give me some pointers as to why it's fundamentally flawed :eek: I'll post the circuit diagram when I've finished drawing it up.
     
    Last edited: Jul 25, 2009
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK

    welcome to the diverse world of electronic hardware! :) there's so many different ways of doing a job, and there is often not a 'correct way' of doing something, there are often different solutions, and most of us will naturally prefer one particular method, and even sometimes be scornful of another way we see.

    Your honesty describing the current gap in knowledge you have has got to be worth recognition at the least, not many people would be so free to speak as you have!

    I think this is good subject to learn about too, jobs in electronics and software, especially design are a lot more rewarded than working in an electrical appliance retailer or computer shop. If you can stay on top of technology as it turns over, then you've got it made. To learn enough knowledge to design hardware is a bit of a slog at first, but it's rewarding along the way, I'm sure anyone will tell you the same. As they say, 'a journey of a 1000 miles starts with the first step'.

    I think maybe this might not be the ideal forum for someone to ask as a complete hardware beginner (I hope I can be proved wrong, anyone?)

    May I also suggest there must be some specialist robotics forums you can tune into and pick up this info from. You can use keywords related to it h-bridge pwm(mentioned above) motor driver (any more, anyone?)
     
    Last edited: Jul 25, 2009
    • Like Like x 1
  6. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks for the post marcbarker. Indeed I often find that some of the explanations in this forum go a bit over my head, but usually with some inductive logic and an understanding of the function of a component, I can piece together what the experts here probably expect to already understood.

    Unfortunately, I'm not entirely clear on transistors so it's not working in this case. My understanding of transistors is that the voltage across the base and emitter determines the resistance between the collector and emitter, which means that a logic high from the microprocessor on the base terminal should ake the transistor allow current to flow between the collector and emitter. Feel free to correct any of that if it's wrong :eek: but in particular, since the low-voltage, low-current circuit from the microprocessor will share the emitter with the much higher-powered circuit, I'm concerned either that that means the battery power may feedback and damage the processor since the circuits will be linked, or that the process circuit will not actually be completed as there is only one terminal from the processor in the circuit.

    Could someone help clarify this aspect of transistors? :eek:
     
  7. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Not an unfamiliar concept to me at least; while I'm new to hardware and have thus far only done some basic tinkering, I am a pretty adept programmer and your comment applies to software just as it applies to hardware.

    I agree! I'm eager to get more experience with hardware. I like to think I have a bit of a knack for electronics, but thus far I don't have enough experience for a 'knack' to get me very far. :p
     
  8. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK
    Your understanding of transistor is quite close, probably close enough for some people. In the most common way they're used, a transistor is more like a current-controlled current sink. A small current flowing through the diode inside the transistor, encourages a bigger current down the collector to emitter.

    The transistor was invented by accident, similar to the way a thermionic vlave/tube was invented by noticing there was a current flowing in an electrode that was only added for testing. They were testing a normal diode by passing a current through it, and added another diode next to it, sharing the same substrate, and they found it amplified.

    I understand your fear about the high current flowing possibly affecting a microcontroller. However, the transistor tends to isolate the high current circuit from the low current one.
     
    Last edited: Jul 25, 2009
  9. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Right, thanks for the explanation. How would the low-power circuit actually be completed though? Since the shared emitter essentially means a shared ground, the microprocessor's parallel port bit would be connected to the battery's negative terminal, which doesn't sound like a completed circuit to me... am I missing something?


    Attached is the diagram I promised in a previous post. Any advice?
     

    Attached Files:

    Last edited: Jul 26, 2009
  10. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK
    In designs where there is a large current controlled, you usually segregrate power ground from the ground of the uC, to prevent large current flowing where it shouldn't. These 'power' and 'control' grounds are connected together at a single point only (i.e. via half the cores of a ribbon cable). The uC ground and H-B grounds are linked by the ribbon cable.

    That's an interesting way you'd drawn your H-B circuit. Most would call it upside down:) Convention in electronics is for current to flow top-down, via the 'arrows' part of the transistor symbols. Another convention is that signal paths travel from left-to-right, though some people prefer right-left.

    I can see something major missing, and that is a ground between the controller and H-B. There's more things missing, but I don't remember because I closed the window now....
     
  11. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Ah, I see. Your mention of a ground answers the question of completing the low-power circuit. With a link between the H-B circuit and the microprocessor's GND terminals, the signalling current will then flow through the transistors' base and to GND. Though I'm still not clear on how to prevent the H-B current flowing through the microprocessor's GND...
     
    Last edited: Jul 26, 2009
  12. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK
    Because the Power Ground and Control Groud are only connected by a single point only, means there cannot be a current flow between them.

    The H-B control circuit should also include isolation of these currents from oneanother. Series-resistors between the uC output and H-B is an extra level of protection to protect the uC if the H-B failed, say it tried to send a current to the uC.

    A fundemantal law of electricity is current passes through the path of least resistance. The art of design is programming this current flow.

    Think about currents more, and less about voltages.
     
    Last edited: Jul 26, 2009
  13. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks again for the advice marc. I've amended my circuit diagram. Was this the correct way to connect the microprocessor's GND or is there a more efficient way? Given that I need to control 5 motors in this way, this is starting to build up quite a list of components I'll need to buy...

    EDIT: I may also modify the circuitry so that instead of both ports draining to GND, they are instead connected to each other so that the transistors can only be activated if the two bits are complements, which was the original intention; but this doesn't reduce the number of diodes I'll need to ground the circuits properly.
     

    Attached Files:

    Last edited: Jul 26, 2009
  14. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Any more suggestions to improve the circuits anyone? Thanks for all the help so far.
     
  15. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK
    Hey Giftiger, that h-bridge scheme you'd just posted! It's not a practical schematic to build a circuit to, but is good enough for describing how to connect the grounds together, that's all. Other than that, sorry, it won't work.

    Blow away those 4 diodes and the green wires. No diodes needed this circuit. Instead the uC ground just connects with one wire (or part of ribbon cable carrying signals) to H-B ground, that's all.

    I can see from the schematic what your present understanding is. Looks like (if you haven't already) you need to get a book on electronics hardware and read up. Great book is the 'Horowitz and Hill', it's usually in libraries.

    You still need a practical circuit for a h-bridge, using transistors.
     
    Last edited: Jul 26, 2009
  16. Mr RB

    Mr RB Well-Known Member

    Joined:
    Jul 22, 2008
    Messages:
    4,716
    Likes:
    194
    Location:
    Out there
    Hi, Pololu make a real cheap little 2 motor hbridge controller that just needs 3 pins to control each motor, (2 pins if you dont pwm) check down the page for;
    TB6612FNG Dual Motor Driver Carrier
    Pololu - Motor Drivers

    it's only $10 and drives 2 motors of 1 amp average 3 amps peak. Very nice on a tiny PCB about the size of your thumbnail!

    They have other nice motor drivers on that page too.
     
    • Like Like x 1
  17. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks for the continued input. Could you explain why my schematic won't work?

    Based on your comments, I see why the diodes and green wires are unnecessary and only a single ground connection strictly needed; I was trying to avoid the signal current passing through the motor, though I'm not actually sure *why* I was trying to avoid that... :eek:

    However as I mentioned, I may also modify the schematic so that the transistors with base originating from PA1 have emitter connected to PA2, and vice verca. That should avoid short-circuiting the battery by having all four transistors allow current to flow, as if there is no voltage difference between PA1 and PA2 (both are at 3.3V), no current will flow, and all four transistors will block current on the H-B circuit.



    Thanks for the suggestion Mr RB, but it may be difficult for me to order from an american site; the postage price will probably be the same as the actual component price. Also, unless I get completely defeated by this circuit I would prefer to try building it myself, it'll be much more rewarding in the long run :)


    Thanks, I'll be sure to look out for that book. I've been meaning to get a couple of electronics books, rather than continuing to be an annoying noob on these forums :)
     
    Last edited: Jul 26, 2009
  18. marcbarker

    marcbarker New Member

    Joined:
    Jul 5, 2009
    Messages:
    727
    Likes:
    7
    Location:
    London, UK
    Home-made H-bridges are a great way to crowbar your battery, with spectacular results! The problem with the current H-B design, is that the 'high-side' transistors aren't driven fully off, another is it's got bipolar transisitors. MOSFETs are a better choice, because they don't blow up so easily, and the circuit is simpler. You just generally connect the fet input to your uC output.

    For the 'low-side' of H-B you'll use a n-channel mosfet. For the 'high-side' you'll use a p-channel one, plus some extra circuit. Someone else can post a schematic, because I'm working on a website right now.

    Great Online Reference!!! >>>Beginning Electronics
     
    Last edited: Jul 28, 2009
  19. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks for the advice! I appreciate that I was asking too many questions on here rather than looking up more information transistors etc., and I managed to find a good resource describing transistors. I now realise that a MOSFET is more appropriate, and is in fact what I assumed was the way transistors worked; I note now from reading up on them that my previous description of how I thought a transistor worked applies better to FETs than to bipolar transistors.

    I'm going to do some more research on MOSFETs and draw up my schematic again, and then hopefully someone will have the time to confirm that it won't damage my microprocessor / start a fire / cause a black hole to form. Either way I'll post it in a new thread with a more suitable title.

    Thanks again guys, especially marcbarker.
     
  20. solis365

    solis365 New Member

    Joined:
    Oct 22, 2008
    Messages:
    240
    Likes:
    4
    Location:
    CT&NY, USA
    MOSFETs as you have discovered are voltage-controlled devices, whereas BJTs are current-controlled.

    Your uC can't output very much current, but it can output a voltage. So if you are trying to control a large current, the BJT will require a proportionally larger current into the base. Instead use a logic-level MOSFET. These take virtually no current into the gate (microamps, nanoamps or less, depending on the type of MOSFET)

    I think a pretty popular MOSFET for this purpose is the IRF510 type. (datasheet: http://www.electro-tech-online.com/custompdfs/2009/07/irf-510.pdf) However you usually want to drive the gates on those with +5V, and your uC is +3.3V, which will be on the "edge" of being fully on (if its not fully on it will be a "higher resistance" as you explained above. this will cause it to dissipate more power and thus get hot and be less efficient. depending on how much current your motor needs you could burn out the transistor if it is not fully on.) You can see from the datasheet that the threshhold voltage ( VGS(TH) as they note it) is between 2 and 4 volts.

    If you haven't read by now, threshold voltage is that 'turn-on' point. It was posted elsewhere on the net with pretty good wording:

    if you havent heard what inversion means, it refers to enough electrons being collected between the Drain and Source terminals so that it can conduct. i.e. weak inversion = not many electrons there to conduct = higher resistance

    OK, heres basically how the operation of a mosfet works. voltages labeled VxS, such as VDS, means the voltage at x referenced to the voltage at the source (for the low side of an H bridge, the source is grounded, so 0.)

    1. When the gate voltage VGS is less than Vth, the FET is off. there is a very small amount of current passed through but in your application, motors and H-Bridges, it wont be even detectable.

    2. When the gate voltage VGS is GREATER than Vth, but VDS is less than VGS-Vth. This is the region where it acts like a voltage-controlled resistor, called the ohmic region, the triode region, or the linear region.

    3. When the gate voltage VGS is GREATER than VTH, and VDS is GREATER than VGS-Vth. The device is in saturation. It is fully on.

    But if you're reading about it the professional authors can probably explain it better than I :)

    I could try drawing up a schematic of my own but you seem to be picking this up fast and you said you wanted to try things yourself, so my guess is that your MOSFET schematic will be pretty close to good :)


    EDIT: oh yeah! dont get MOSFET "saturation" confused and BJT "saturation", they are very different things, i.e. a BJT operating in the saturation mode will not be anything similar to a MOSFET operating in saturation. MOSFET "saturation" is like "forward active" mode for BJTs
     
    Last edited: Jul 28, 2009
  21. giftiger_wunsch

    giftiger_wunsch New Member

    Joined:
    Jun 15, 2009
    Messages:
    813
    Likes:
    3
    Location:
    Kent, England
    Thanks, your post was enormously helpful, especially the information about the threshold point: I knew there had to be a threshold point, but I hadn't been able to figure out the symbol denoting it or how to check the threshold point on the MOSFETs I have been looking for on the electronics store site.

    I noticed similar products on the electronics store website, closest were IRF740 or IRF540A types... I'm rather disgruntled by the fact that while BJTs were about 15p each, most IRFxxx MOS-FETs are about £1.30 each. The cheapest MOS-FETs listed are 2N7002s, but they have an 'ID' of 300mA (I assume that refers to the maximum current rating of the drain) which is most likely too low to effectively power the motors. Since I have to power 5 motors and use 4 MOS-FETs for each H bridge circuit, it seems so far that the MOS-FETs are going to cost more than the robotic arm did...

    Though it would defeat my ability to prevent H-B short-circuits by ensuring that all four mos-fets aren't allowing current flow at the same time by using PA2 as the ground of PA1 and vice verca, it should be possible to solve the partly-on problem by using the PA1 and PA2 (etc.) ports as the ground at VSS and use one of the 5V supply ports on the uC for the gate supply. A logic 0 bit could be used to 'open' the MOS-FETs, as the logic high 3.3V will make VGS 1.7V which should be too low to begin to 'open' the MOS-FET... I hope?


    I'll still have a go at drawing up a schematic (tomorrow now, since it's coming up for 2am), but it appears this may be slightly outside of my budget...

    Edit: On second thoughts, the IRFZ24N is 74p per unit, and reduces to 60p / unit if I buy 20 of them at once. Might not be too bad after all.
     
    Last edited: Jul 28, 2009

Share This Page