PIC to Relay


Closed Thread
Results 1 to 15 of 15

Thread: PIC to Relay

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    Hi guys. I want to use my pic to switch on/off a load (240v Light bulb) via a 5v relay. What transistor would be suitable, what relay and what diode should i use for "flyback"?
    There are a huge number of choices, but if you want a quick solution, a generic NPN transistor like the 2N3904 would do it. If you're using 5 volts on the relay, a 2N7000 MOSFET would be even better. You can find circuit examples for both on line.

    The 1N4001 is a good choice for the flywheel diode. It's already been suggested that you consider using a triac instead of a relay, and this is an excellent idea. A sensitive-gate triac can be used, or you can use a triac driver like the MOC3033.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  2. #2
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    Thanks for those quick replies russ n master. Would you happen to know of a specific model 5v relay that would be able to switch an AC load (240v house-hold globe)? I prefer using the relay although its noisy . Im just beginner and trying to figure out controlling that triac will just end up taking too long. For now i'll use a relay. Maybe later when i have some time will i experiment with a triac.

  3. #3
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Controlling a triac is pretty simple. It looked confusing to me at first because i was looking at it as a transistor. All you have to do is connect it in series with the load using the A and B pins. then you apply a short between pin B and the 3rd pin. I would definately recommend using a triac optoisolator like RussMartin said. It keeps the mains electrically safely isolated from your low voltage circuit. If you ever want to try it out yourself then i would be happy to provide some drawings and part numbers that ive used in the past.

    Your choice of relay depends on a few things. You already said you want it to be operated from 5V and control a 240V bulb. You also need to think about how many amps you will be using. Not a lot for a standard 240V bulb. I think most 240V relays could handle that. I would assume you want a PCB mountable one. You can get ones with a different number of switches etc (SPST, SPDT, DPDT etc). I use Rapid for components so i usually start by looking at the relay page. Unfortunately it doesnt give you a lot of information without clicking on each one. 60-4190 appears to be suitable for your needs and is fairly cheap.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This is just a 'heads-up' when dealing with Rapid...

    Avoid the 'own-brand' products (eg TruSemi for Semiconductors, or TruCap for Capacitors etc) and pick a known branded product if at all possible. I can't confirm it, but based on the number of rejects we have experienced, these could be B, C or even D grade components.

    I've got TruSemi 78L05's which are the closest thing to a dead-short giving 18vDC on your boards 5v rail... and I've others which vary between 4.1v and 5.9v depending on whether you are drawing a milliamp or two!

    Sometimes too cheap is just that, and we have to remind ourselves of John Ruskin's poem...

  5. #5
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    Sometimes too cheap is just that, and we have to remind ourselves of John Ruskin's poem...
    In the words of an on-the-air fumble by John Cameron Swayze in the early days of live television advertisements: "Remember, with Timex, you get what you pay for; and you don't pay very much."
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  6. #6
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Ok, heres that schematic. Im sorry its not the best looking one ever. I did it in M$ paint :P

    The lefthand side of the optoisolator works exactly the same as an LED. Check the datasheet for the specific one your using for the voltage. Usually i put a 1K resistor between it and the PIC. I always put a 1K resistor between the opto and the G pin of the triac too although i cant remember why (maybe someone else can clarify this bit).

    It may or may not help you but ive included a circuit that i designed to control 4 lights using triacs. I usually find that a PCB layout helps me more than a schematic so you have both just incase. The triac im using is a "BTA08-600B 8A 600V" and the opto is a "MOC3020M". Both resistors either side of the optos are 1Ks. I have a few of these circuits connected up and working perfectly
    Attached Images Attached Images   

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    I think useful to add the attached schematic for all who want to use TRIAC for their ac application.
    Remember that the triac side is always connected to the main. Be very careful !!

    Al.
    Attached Images Attached Images
    All progress began with an idea

Similar Threads

  1. HELP ME, SMS controlled relay using PIC
    By pazko1125 in forum mel PIC BASIC
    Replies: 14
    Last Post: - 2nd October 2008, 15:26
  2. Pic to relay
    By ruijc in forum General
    Replies: 4
    Last Post: - 8th November 2007, 19:03
  3. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  4. Replies: 22
    Last Post: - 9th April 2007, 15:25
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts