12V device, 5v MCU, how to interface?

Discussion in 'The Projects Forum' started by bigclick_dean, Aug 15, 2012.

  1. bigclick_dean

    Thread Starter Member

    Jan 24, 2010
    38
    0
    Hey All,

    I have been trying to connect a RFID reader to an ATMEGA32u4 and I am having a bit of an issue with the mixed power supply.

    The RF reader I have has 6 lines:

    1. VCC +12V
    2. GND
    3. D0
    4. D1
    5. LED
    6. Buzzer

    The reader outputs Wiegand structured data and I have no issues reading it, I can connect the VCC +5v from the MCU to pin 1 and the reader functions fine but has a very short range and has mis reads sometimes.

    The D0/D1/LED/BUZZER seem to output max 5V for high (even when 12V is supplied to VCC) so it must have some sort of internal regulation.

    The LED/BUZZER pins are active low so when pulled to GND they either light up or buzz.

    I can connect 12V (wall wart) to the reader, 5V to the MCU (From USB) and connect the GNDs and it all works fine, but when I unplug the MCU from USB it freaks out a bit and stays powered up partially.

    I am reading around 3V on the D0 and D1 lines (if I unplug these then the MCU turns off fully).

    Is there another way I should be connecting this up? I did look at a NPN transistor (BC548) to switch the 12V wall wart line so when the MCU was off the RFID reader was totally off but I couldn't get it to work.

    I had a 1N4001 diode across the 12V load and a 4.7k resistor between the MCU pin and the NPN Base, however nothing I did would work.

    I could put a full relay in there to do it but I think it is a bit overkill, the RFID reader has little to no documentation and I cannot find any reference to what it draws, but I would assume a very small amount.

    Any help would be appreciated.

    Cheers,
    Dean
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Hey Dean.

    Does that mean the RFID is still powered on, but the ATMEGA32u4 is not powered?

    If so, what may be happening is the ATMEGA32u4 is getting some power off the (still powered) digital lines from the RFID. Typically (meaning I don't work with ATMEGA anything) digital lines have diodes connected to the power supply rails for static protection. These diodes WILL allow a high input level to power the device on when no other power is applied.

    It's sloppy power so the ATMEGA may be running only in spurts.

    I got caught by something similar using CMOS chips where the chip did not have any power but was running "just fine." Took me a while to convince my colleges we actually did have a wiring problem.

    Once you get bit by this you should remember the lesson. ;)

    And welcome to the forums!
     
  3. wayneh

    Expert

    Sep 9, 2010
    12,101
    3,033
    Hard to say what went wrong here. Drawing it out might help - you might have used it as an emitter-follower, which wouldn't work. The 4.7k might be too high a value. A rule of thumb is that the base current needs to be 10% of the collector current.

    But anyway a better choice than a BJT like the BC548 would be a logic level, n-channel MOSFET. It needs only a voltage - not a current - on its gate to make the switch. Source pin to ground, drain to the low voltage of you're load. The MOSFET completes the path to ground when the gate voltage passes the threshold.
     
  4. bigclick_dean

    Thread Starter Member

    Jan 24, 2010
    38
    0
    Thanks to the both of you for your responses.

    @ernie - I think that is exactly what is happening, the data lines stay at between 3-5v when the 12v is connected to the reader and is feeding power back through to the MCU therefore causing it to go crazy (constantly resets, etc). Is there anything you can think of that could prevent this?

    @wayne - Yeah I wasn't sure either, it would work randomly but not that well, could have been the 4.7k but without any spec docs it was going to be hard. I grabbed a n-channel fet from the local store (60v 1A was all they really had) with a switching voltage of 2.5v. It seems to work quite well and can handle the 12v reader fine. The only problem still is the voltage is still coming out of the reader so when the 5V to the MCU is disconnected the device is still putting enough power out of the digital pin to keep the FET active hence not actually turning it off.

    Any ideas? I did have a 10k resistor between the digital line and GND and that helped a bit but in the end it still doesn't really work.

    Cheers,
    Dean
     
  5. wayneh

    Expert

    Sep 9, 2010
    12,101
    3,033
    Well, you could try just reducing that to see how much pull-down will do the job. Don't go below 470Ω or so, and you should read how much load on the output your controller can tolerate.

    I wonder if you couldn't use a diode here, maybe an LED, to cutoff current to the gate when the controller voltage starts to sag.
     
Loading...