Arduino and external sources

Discussion in 'General Electronics Chat' started by adam555, Sep 2, 2013.

  1. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I need to feed 12V to a step-motor that is controlled by Arduino (at 5V). I guess the best way to do it is by using a optocoupler to isolate both power supplies.

    The problem is: I only have 1 single optocoupler, so, is there any way I can control the 4 Arduino outputs with a single optocoupler, or do I forcebly need a optocoupler for each?
     
  2. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    Think of the opto coupler as a switch. Could you control all 4 Arduino outputs with one switch? Also, do the opto couplers have the ability to carry the current required by the stepper motor? Maybe transistors or FETs would work better for you. Have you done a search (here or Google) for stepper motor drive from and Arduino?
     
  3. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    That's why I'm asking; because I can't figure out a way to do it with just one. Maybe I could, but probably only moving the the motor continuously in one direction.

    Forgot to check the specs, and you're right. It's fine with the voltage (up to 30V), but I'm afraid I would need more than its 100mA limit; the motor is 12V and 48Ω; so I guess it would require 250mA.

    I just found some power MOSFETs; but only 3. Never used those before; that's why they didn't come to mind when I got the motor yesterday.

    Thanks

    I got it working yesterday directly from Arduino at 5V with 4 transistors, but it had no strength. Then I couldn't provide the 12V it needs because I just had 1 optocoupler.
     
    Last edited: Sep 2, 2013
  4. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Just found a page that explains how to do what I'm looking for with power MOSFETs; however, in its example both power supplies are not isolated, they are grounded together; like this...

    [​IMG]

    But the other day someone on this forum told me not to ground different power supplies together; so, to be sure; should I, or should I not?

    When can I ground different power sources together and when can I not?
     
    Last edited: Sep 2, 2013
  5. wayneh

    Expert

    Sep 9, 2010
    12,123
    3,047
    You generally can ground them to a single common ground except in certain, hopefully rare circumstances. You have to avoid a situation where one mains-connected power supply can drive current to another mains-connected power supply over what you think is a ground-to-ground connection. For instance, connecting the audio "ground" of your computer's sound card to true earth ground might zap your sound card.

    You can test for this condition by making your first ground-to-ground connection using a 220Ω resistor. If a large voltage appears across it or it explodes, then you'll be glad you didn't make a direct connection.

    If only one or none of your power supplies are mains-connected, then this is not a concern. There's no path to complete the circuit.
     
  6. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Thanks; I think I understand the difference now.
     
  7. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    An old rule is to put a multimeter between the two grounds, and see if any significant AC volts or DC volts exists.

    If the AC and DC voltage tests show the two grounds don't have much voltage between them, you can connect the grounds with something like a small (1/4W) resistor of low ohms (like 100 ohms).

    If the resistor does not get hot, and does not burst into flames, that's a great sign that you can connect the two grounds.

    It sounds complex but only takes a few seconds to probe with your meter, then touch a small resistor between the grounds to test.
     
    Austin Clark likes this.
  8. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Yes, I was actually thinking it would safer to test the voltage with a multimeter first than burn my few resistors. :D
     
  9. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    Improperly interfacing a 12V system with a 5V system is perfectly safe, IF there exists no voltage between the two supposed "grounds" (remember ground is RELATIVE), and you know what you're doing. I actually destroyed my first Arduino in this exact way, trying to drive a stepper motor. However, I think you'll be fine.

    Technically, however, there is a way to control 4 electrically isolated pins via a single optocoupler. Via serial communication. However, in this case that wouldn't make much sense. It just isn't necessary.
     
  10. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    Thanks Austin, I'll make sure to check both grounds with a multimeter before using any external power supply with Arduino.

    I also read somewhere that I should use a diode when connecting motors to Arduino -which is not included in the the example I posted-. I guess it would go before junction between the 2 grounds.

    Yes, I also thought that was the only way to send the data through just one optocoupler. But for now I don't think I would be able to split the serial feed into 4 ways. That's a project I had planned for when I learn a bit more.
     
  11. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    You put the diode in parallel with the motor, in the opposite direction you'll be applying a voltage. This is to prevent the inductance of the motor from creating a high voltage spike when it is suddenly turned off. The current passes through the diode safely.
     
  12. adam555

    Thread Starter Active Member

    Aug 17, 2013
    858
    39
    I see what you mean, with a regular motor, but how do I do that with a step motor; won't I need 4 diodes?
     
  13. Austin Clark

    Member

    Dec 28, 2011
    409
    44
    I suppose so.
     
  14. Jibby

    New Member

    Sep 12, 2013
    15
    1
    You forcibly need a opto-coupler for each.
     
Loading...