Transistors, Relays, and atTinys, oh my...

Discussion in 'The Projects Forum' started by J.Smitty, Apr 16, 2014.

  1. J.Smitty

    Thread Starter New Member

    Apr 16, 2014
    5
    0
    I just finished a project for an automated reading lamp to turn on when I sat in my trusty reading chair. The project involved a switch/sensor for when I sat down. An atTiny85 read for the input, and upon receipt, sent an output signal through a transistor, then to a relay. The relay was then supposed to trigger the lamp to turn on.
    Unfortunately, it didn't work.
    I originally built the prototype on a breadboard, running an Arduino's 5v output though the relay (switch), and it worked when I sat down to light an LED. The final result used 5v though a wall adapter to run the atTiny circuit. The relay (coil/sensor) was hooked up to this as well, as it was with the prototype. The difference in the final project is its on a homebrew PCB now, and instead of running 5v through the relay (switch), it's running the 120vac required by the lamp. By everything I can tell, the relay is rated to perform this.
    Hopefully, someone can take a look at the curcuit, and see something I missed.
    The parts I used are:
    Relay- OUAZ-SS-105D
    Transistor- BC547

    Circuit Image here:
    http://tinypic.com/r/bgtflh/8

    ~All of the "To" or "From" parts are terminal board wire connecters.
    The "To AC" connector connects to the AC plug side of the power cord, and the input of the 5v DC adapter.
    The "from regulator" connects to the output of the adapter. I measured here, and I am getting 5vDC.
    The "to sensor" simply connects to the sensor that detects when I sit in the chair. It sends the analog reading to the atTiny85 on pin2, then sends an output on pin7 to the transistor, which should trigger the relay.
    The "To Lamp" connects the other end of the AC line to the lamp.

    Really stumped now as to what went wrong from breadboard/dc/led to PCB/AC/Lamp.

    Thanks for any help you can provide.
    [​IMG]
     
  2. ronv

    AAC Fanatic!

    Nov 12, 2008
    3,290
    1,255
    Can you post the schematic?
     
  3. J.Smitty

    Thread Starter New Member

    Apr 16, 2014
    5
    0
    I hadn't made one. I will once I have the opportunity to.
     
  4. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,770
    970
  5. J.Smitty

    Thread Starter New Member

    Apr 16, 2014
    5
    0
    Ok, here is a schematic:
    http://tinypic.com/r/29kvo93/8
    Pin2 on the atTiny is the analog input, Pin7 is the output signal to the transistor.

    The missing traces on the PCB design may be all of the terminal connectors. They each have a "connection" in the center of them. These aren't actually used, it is just for spacing when I print the PCB for homebrew fabrication.

    This design worked on the breadboard, lightning an LED, using the 5v through the relay instead of 120vac.

    Thank you for your interest in helping me solve this too!
     
  6. J.Smitty

    Thread Starter New Member

    Apr 16, 2014
    5
    0
    Update: I just rebuilt it on a breadboard again, and it worked. Even with the lamp. I'm guessing the problem is in my PCB design. Maybe I'll use one of those pre-made "breadboard style PCBs" instead.
    Meanwhile, is there anything else you guys see that could improve it? I'm sure I'm missing something.
     
  7. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    Perhaps a diode across the relay coil to prevent voltage spikes when you turn it off from damaging your microcontroller.
    Other than that, a microcontroller is a bit overkill for this project, but if it works it works. You might as well add some other capabilities to it, you've got plenty of processing cycles to work with. Perhaps some sort of timing mechanism? Different operating modes? Who knows.
     
  8. J.Smitty

    Thread Starter New Member

    Apr 16, 2014
    5
    0
    http://tinypic.com/r/2hedmbl/8
    I think I got the diode direction right.... Is that what you mean?
    Also, I went with a MCU, because the sensor is a homemade pressure switch. I'm lucky if I can get a full volt across. I tried hooking it straight to the transistor, but it didn't switch. Figured an MCU was the easiest solution.
     
  9. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    Yes, that diode is correct.

    Any less than a volt and you're going to have a hard time overcoming the BJT Base-Emitter junction voltage (just like a diode). That's why the transistor didn't switch.
     
Loading...