+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Full Member level 3
    Points: 3,771, Level: 14

    Join Date
    Oct 2004
    Location
    ITALY
    Posts
    156
    Helped
    7 / 7
    Points
    3,771
    Level
    14

    pic16f876

    Hi,

    I'm making a control board. It is a keyboard that has to drive 15 different 12V automotive relays.

    I used Pic 16f876 as MCU for this board. because of few pins free i'd like to drive relays using a General purpose I/O expander controlled by I2c Bus(PCA9555).

    Pwer supply for MCU and I/O expander is a common lm7805 (1A)

    PCA9555 has got 16 cmos output 20mA per Pin(max 200mA).
    I decide to interface it by ULN2003(7 darlington array) using classic relay NPN configuration.(uln2003 output switches relay's coil to GND). Relays aren't driven by 7805 but directly from car battery.

    This circuit works fine for singular relays but when I try to switch on more than five arrays it gives me a lot of problems. It looks like there isn't enough current to drive ULN2003, some relays switch off, other are out of control, uln2003 and PCA9555 gets warmer.

    What would you suggest me to do? is there a better way to interface I/O expander to relays?

    thanks for your help

    •   AltAdvertisement

        
       

  2. #2
    Member level 4
    Points: 1,976, Level: 10

    Join Date
    Mar 2005
    Posts
    68
    Helped
    3 / 3
    Points
    1,976
    Level
    10

    i2c i/o relay

    Salam,

    I think you r using so complicated method

    Why not just use a 74LS673 16 bit serial in parallel out shift registers for expanding the I/O?

    You can take the output of the 74LS673 or your I/O expander to switching transistors or whatever , don't use 7805 use a power regulator this can source a high current

    Hope that helps



  3. #3
    Advanced Member level 5
    Points: 74,061, Level: 66

    Join Date
    Oct 2004
    Location
    West Coast
    Posts
    7,942
    Helped
    2329 / 2329
    Points
    74,061
    Level
    66

    deriving relay using uln2003

    For test purposes use LEDs instead of relays. Maybe switching relays cause spikes and thus mulfuncion of the PIC microcontroller.
    Try this and see how it goes..
    Regards,
    IanP



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 2
    Points: 5,866, Level: 18

    Join Date
    Mar 2002
    Location
    UK
    Posts
    520
    Helped
    47 / 47
    Points
    5,866
    Level
    18

    driving a relay with a pic

    I think IanP is on the right track. I have had problems like this myself. Electrically you seem to have it right, but probably the layout is wrong. Relays do generate a great deal of noise. On pcb all grounds should go back to a common point. Pic should be decoupled even after the regulator. You could try having the relays on a separate board and optocouple them. I am afraid that it could well be a case of trial and error. Also make sure that you are not exceeding the total dissapation of the uln2003.



    •   AltAdvertisement

        
       

  5. #5
    Full Member level 3
    Points: 3,771, Level: 14

    Join Date
    Oct 2004
    Location
    ITALY
    Posts
    156
    Helped
    7 / 7
    Points
    3,771
    Level
    14

    uln2003 driving relay

    on the same board I use another I/O expander to drive to drive 1 led for each kay. and it works fine.

    Would you please suggest me some useful optocoupler capable to drive led or to be interfaced by ULN or transitor?

    I found also ULN2068, do you think it would be better?

    Thanks for your time.



  6. #6
    Full Member level 6
    Points: 4,369, Level: 15
    metal's Avatar
    Join Date
    Dec 2004
    Posts
    364
    Helped
    19 / 19
    Points
    4,369
    Level
    15

    drive a relay using pic micro

    Hello

    If you need to expand I/O pins, the easiest way is to use a decoder, for example, you can use three pins from the PIC, and a 3-8 lines decoder, will do the job, more easily than I2C method.

    Regards



  7. #7
    Advanced Member level 5
    Points: 74,061, Level: 66

    Join Date
    Oct 2004
    Location
    West Coast
    Posts
    7,942
    Helped
    2329 / 2329
    Points
    74,061
    Level
    66

    relay controller board using pic mcu

    If you recon the LED expander works fine why the relay expander can't do the same?
    That was the reason behind the suggestion that you first try the other expander with LEDs, and, if this works fine, then the next step would be to install ≈0.1 to 1mH inductor at the input pin of the7805 voltage regulatoer and ≈10-100µH inductor followed by 100nF (ceramic)+10µF(tantalum) at the output (as close as possible to PIC).
    Regards,
    IanP



    •   AltAdvertisement

        
       

  8. #8
    Advanced Member level 1
    Points: 6,426, Level: 19

    Join Date
    Jul 2002
    Location
    Far out, man!
    Posts
    435
    Helped
    91 / 91
    Points
    6,426
    Level
    19

    74ls673 pic

    You should connect COM (pin 9) of the ULN2003 to the battery voltage, as a rule.
    You had it floating in the drawing in your other topic on the same subject.

    In your other topic I also asked about your PCB layout because I once ran
    into problems when relays were mounted close to each other. The magnetic
    fields from adjacent relays interfered with each other so that they didn't "pull"
    enough. The minimum distance between two relays should be specified in the
    relay datasheet.

    Just some suggestions...

    /Rambo



  9. #9
    Advanced Member level 2
    Points: 5,866, Level: 18

    Join Date
    Mar 2002
    Location
    UK
    Posts
    520
    Helped
    47 / 47
    Points
    5,866
    Level
    18

    pic16f output expander

    Try this,

    Leave your circuit as it is for the time being with I2C devices, if you use say 3 line to 8 decoders, you will only be able to drive one relay at once. There are of course ways round this, but for the moment leave as is.

    Try having all your relays away on a separate board, say at least a few inches away prom the Pic. Now the important bit, take the 0 (ground) lead from each board back to a common 0 point, with no other possible ground returns. via chassis etc. I had the same problem trying to control several machines with a Micro, they were all earthed at their respective supply connections, The Micro was going crazy with erratic operation. Removing the grounds and then taking them back to a sing point completely cured the problem.

    If this does not cure it, I think you need to look at further supression methods as well.



  10. #10
    Full Member level 3
    Points: 3,771, Level: 14

    Join Date
    Oct 2004
    Location
    ITALY
    Posts
    156
    Helped
    7 / 7
    Points
    3,771
    Level
    14

    driving relays

    Thanks a lot for your help!!

    I finally found my problem. It was a ground problem for uln2003. now my layout works very fine. it hasn't got any other problem. But I think I'd better use an inductor in 7805 input, wouldn't I ?



--[[ ]]--