Using Arduino to control a power supply

Discussion in 'Embedded Systems and Microcontrollers' started by electrophile, Jan 30, 2016.

  1. electrophile

    Thread Starter Member

    Aug 30, 2013
    100
    1
    Continuing my earlier experiment to build a laser diode driver, I wanted to turn the laser on and off from one of the pins of the Arduino. Would the attached schematic work? I'm trying to give the INHIBIT pin a path to ground using the P-MSOFET. The INHIBIT pin on the ST1CC40 (a constant current driver) when pulled below 1.2V disables the supply and when pulled above this, enables the supply.
     
  2. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    The data sheet says you should leave the inhibit pin floating if not used, which implies to me that it has an internal pull up, or something functionally equivalent. So I think your 5v supply switched through the MOSFET is unnecessary. Looks to me like all you need is a switched path from inhibit pin to ground, perhaps directly through the opto?

    I could be way off base - most of that ST1CC40 circuit is well beyond my understanding, so it's entirely possible I'm misinterpreting this part as well.
     
  3. David Knight

    New Member

    Aug 4, 2015
    26
    5
  4. electrophile

    Thread Starter Member

    Aug 30, 2013
    100
    1
    Thanks David and @ebeowulf17!

    I don't need dimming functionality so much as just being able to turn the supply on and off through an MCU but it makes sense to keep this in mind when I'd need something that can control the current through the laser diode thus varying its output power. After ebeowulf17's suggestions I started thinking and did more research. This is what I came up with which I'll test in a day or so. The INH pin can now be controlled through an Arduino with opto isolation. I simulated the opto isolation bit and that works great. Essentially the INH pin needs to be kept floating or connected to Vin for the device to be ON. In this schematic, the device is normally OFF and is turned on only when the MCU enables it.
     
  5. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,805
    833
    Pin 11 is a PWM pin on the Arduino; the Arduino PWM pins are 3, 5, 6, 9, 10, or 11.
     
  6. David Knight

    New Member

    Aug 4, 2015
    26
    5
    The circuit can work with an opto, but the opto isn't necessary.
     
  7. electrophile

    Thread Starter Member

    Aug 30, 2013
    100
    1
    Yep! I'm controlling the steppers with grbl and pin 11 is the PWM spindle control which in this case is being repurposed to turn the laser on and off.
    Yes you are right. The optocoupler is to get better noise rejection and essentially protect the Arduino from mishaps (which I'm quite likely to make).
     
  8. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    One small concern: I see you've added a jumper so that you can manually force it on or off, but there's risk of creating a short. If you use the jumper to tie inhibit to ground and the Arduino tries to activate the power supply, there will be a short from power supply through opto, through jumper to ground. I think one extra resistor between the power supply and the opto would limit current to acceptable levels in the event of such a short.
     
  9. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    ...or was I misreading your schematic? What is P2? I just realized you have jumpers elsewhere in your schematic and they're represented differently, so I probably misread that portion.
     
  10. electrophile

    Thread Starter Member

    Aug 30, 2013
    100
    1
    Yes you are right. The P2 is when you want to use the board as a constant ON device. When this happens, the device should not be connected to an Arduino or any other MCU and would operate as a standalone system. This resistor is between the collector of the opto output and Vin right? How big would that resistor have to be?
     
  11. ebeowulf17

    Active Member

    Aug 12, 2014
    678
    79
    It depends on how much current the relevant parts can handle:
    1) power supply
    2) opto isolator
    3) wires/traces/jumpers, etc.

    If it were me, I'd probably use a bigger resistor than the bare minimum and reduce the potential short circuit current a lot more, down to 100mA or lower. If this is on the 12V supply, that would only require a 120 ohm resistor between Vin and the opto. The other related number is your R5 pull down resistor, since the added resistor will create a voltage divider. If you kept R5 at least ten times the value of your new short circuit current limiting resistor, the voltage reduction would be negligible and have no effect on functionality.

    To me, those values feel like minimums. If this is a one-off that you're building yourself, I'd probably go much higher on both resistor values, like 1k current limiting and 10k pull down. Off the top of my head, I'd expect that to work just fine. But if this will be hard to change (surface mount parts on custom pcb or some such thing) then it might be worth doing better calculations than my guesstimates!
     
  12. electrophile

    Thread Starter Member

    Aug 30, 2013
    100
    1
    Got it! Thanks!
     
Loading...