Shop OBEX P1 Docs P2 Docs Learn Events
Need help powering relays from microcontroller!! — Parallax Forums

Need help powering relays from microcontroller!!

Just finished writing the code for my car's push to start system. I'm using a BS2 Rev. J from a Boe Bot kit I had lying around. I have everything working on a breadboard using LED's to simulate the components but now I have no idea how to make it work inside the car.

I'll be powering 2 ignition relays (IG1 & IG2), a starter relay and an ACC relay. I can't find a data sheet for my specific relays but most 12V 30A relays I saw draw 130mA to switch them. The IG1, IG2 and ACC circuit will all be continuous while the car is on and the starter won't be powered for more than 1-2 seconds. I need to find a way to amplify the current from the microcontroller to be able to power the relays.

I looked into MOSFET's but from my super limited understanding it looks like they are controlled by the voltage difference between the gate and the source and when that happens, the source connects to the drain. I saw a lot of 'hey use this transistor' etc. but not too much on how to wire them up. I do have 2 car amplifiers for parts so I'm sure I have all kinds of transistors to toy around with.

Any help would be greatly appreciated!

Comments

  • The easy way to do it is to drive the coil of the relay through a U2803, this acts as a current driver and is quite enough for that particular job.

    Just have it wired correctly and you are good to go.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2017-03-02 21:47
    The ULN2803 (and some links for how to wire them up) are here: www.sparkfun.com/products/312

    They also have some MOSFET power control kits too, but the ULN2803 sounds like it'll be plenty for your needs.
  • I had forgotten about that method since I had put this project on hold for a few months. Do they come in any smaller packages? Trying to cut down the size of the entire unit since I'm going to have all the relays on the board with all the other components.
  • A single TO92 transistor such as a 2N2222, a 470 ohm resistor from the I/O to the base, emitter to ground, collector to relay coil, and a 1N4004 or similar diode across the relay coil.
  • Also I've never used one before, any requirements for the common pin (required minimum voltage or amperage?) didn't see that on the data sheet
  • kwinnkwinn Posts: 8,697
    edited 2017-03-03 03:09
    The common pin should be connected to the car ground. The ULN outputs should be connected to one side of the relay coils and the other side of the relay coils should be connected to the car +12V.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-03-03 04:13
    The "common pin" (pin 9) of the ULN200x refers to the common diodes on the collectors. This you should tie to the +12V. Normally "common" refers to ground because it is short form for "common ground" but that is not always the case. Pin 8 though is common ground.

    uln2003.png
  • KrappenSchitzKrappenSchitz Posts: 6
    edited 2017-03-03 04:33
    That's how I had planned to wire it up. I don't really know how they work though (which is why I'm having a hard time with what needs to be hooked up where).

    The ground is ground obviously but does the "com" pin have to be a particular power source? Or can I just give it any +12V source? Is it just a turn on signal or is it something that needs a substantial amount of current?

    The way the ignition works is there are basically 2 live wires (AM1 and AM2) when the ignition is moved to a certain position those wires connect to the IG1, IG2, ACC and starter wires. So I'm just making sure that the "com" pin doesn't have to be the same wire as the 12v source going to the relays I'll be powering since 3 of the 4 relays have different power sources.

    Is it really as simple as power and ground to the unl2803 then input and amplified output?
    I'm just having a hard time understanding where the extra current is coming from.....
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2017-03-03 04:53
    COM connects to the same supply as the load. So if your relays go to +12V then your COM goes to +12V. They effectively become the flywheel protection diode across the coil of the relay. Current does flow through this diode from the collapsing magnetic field of the relay's coil when it is turned off. Otherwise you would have a very large voltage spike that could kill the transistor or driver. So physically make it the same as the relay, not just another +12V line unless you like replacing parts.

    You can though run it elsewhere or not at all even, as long as you use a diode across the coil which is easier to do this way sometimes.
  • Gotcha. In my case though I have 3 different +12V sources for 4 relays so could I connect them all to COM? Or should I just go the individual diode way? That honestly seems easier to me, will a standard 1A diode suffice?
  • Standard 1A diode is fine and easier, even 1N4148s will do with such small coils.
  • Awesome! Thank you for all your help!
  • kwinnkwinn Posts: 8,697
    Well, color me embarrassed. Forgot about the COM connection to the flyback diodes, and meant the GND connection in my post.

    Sigh, another seniors moment. Thank you Peter for catching that.
Sign In or Register to comment.