Arduino and external sources

Thread Starter

adam555

Joined Aug 17, 2013
858
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?
 

BillB3857

Joined Feb 28, 2009
2,571
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?
 

Thread Starter

adam555

Joined Aug 17, 2013
858
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.
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

Have you done a search (here or Google) for stepper motor drive from and Arduino?
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:

Thread Starter

adam555

Joined Aug 17, 2013
858
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...



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:

wayneh

Joined Sep 9, 2010
17,498
When can I ground different power sources together and when can I not?
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.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
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.
Thanks; I think I understand the difference now.
 

THE_RB

Joined Feb 11, 2008
5,438
...
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?
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.
 

Thread Starter

adam555

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

Austin Clark

Joined Dec 28, 2011
412
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.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
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.
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.

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.
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.
 

Austin Clark

Joined Dec 28, 2011
412
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.
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.
 

Thread Starter

adam555

Joined Aug 17, 2013
858
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.
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?
 
Top