Help with current flow

Hello all,

I've been trying to interpret this schematic for awhile now, but I'm still unable to figure out how it actually works, despite how simple it looks. I wish to use a similar setup for a couple linear actuators I have on the way, but with some switches included as well. Like I said, I've been at this for a little while, so I'd appreciate it if anyone could clarify, or at least start to clarify, how current flows through this circuit.

Thanks!

Start at one side of the motor, follow the path through the relay contacts to the on/off transistor.
Then assume the contacts have transferred because the direction transistor is on.
The current path through the motor has changed direction.

.

The relay should have a kickback diode should be across the coil.
The on/off transistor should also have a kickback diode across it, cathode to collector.

.

The relay simply changes the polarity to the motor. The TIP120 is the power switch.

Assume power is turned on via the transistors. A ground is applies to the left relay contact common. Follow the NC contacts and it gets to the right side of the motor. Follow the positive from the battery, through the NC to the left side of the motor. The motor has power so will turn.

Now turn on the relay and repeat using the NO (now closed). The polarity of the motor is now reversed.

Weedpharma

LarryD:
The relay should have a kickback diode should be across the coil.
The on/off transistor should also have a kickback diode across it, cathode to collector.

I'm so glad you said something about the kickback diode across the transistor. My motor was continuing to run even after switching it off, and I couldn't figure out why. Now I know!

weedpharma:
The relay simply changes the polarity to the motor. The TIP120 is the power switch.

Assume power is turned on via the transistors. A ground is applies to the left relay contact common. Follow the NC contacts and it gets to the right side of the motor. Follow the positive from the battery, through the NC to the left side of the motor. The motor has power so will turn.

Now turn on the relay and repeat using the NO (now closed). The polarity of the motor is now reversed.

Awesome! I understand now!

Is there is reason why I wouldn't be able to put two switches into this circuit? One to activate the ON/OFF transistor, and one to activate the DIRECTION transistor? I want the motor to run while the switch is flipped on, and then turn off when the switch is off. With the example code provided on that website, the motor only runs forwards and backwards for a couple seconds or so because the code is placed within the "void setup()" area.

Use switches in place of the transistors? Yes, you could do that.

CrossRoads:
Use switches in place of the transistors? Yes, you could do that.

I don't think I was quite clear enough. My bad. What I meant, is that right now, with the code provided, the transistors are 'always on' I guess. I want a way to turn them on manually, whenever I wish. That's where the switches come in. One for the ON/OFF transistor and one for the DIRECTION transistor.

Here is some code that I just quickly wrote up.

#define DIR 5
#define MOTOR 4
int onoffswitch = 7;
int dirswitch = 8;

void setup() {
  pinMode(DIR, OUTPUT);
  pinMode(MOTOR, OUTPUT);
  pinMode(onoffswitch, INPUT);
  pinMode(dirswitch, INPUT);
}

void loop() {
  if ((digitalRead(onoffswitch)==HIGH) && (digitalRead(dirswitch)==LOW)){
   digitalWrite(MOTOR, HIGH);
   delay(2000);
   digitalWrite(MOTOR, LOW); 
  }
  else if ((digitalRead(onoffswitch)==HIGH) && (digitalRead(dirswitch)==HIGH)){
   digitalWrite(DIR, HIGH);
   delay(20);
   digitalWrite(MOTOR, HIGH);
   delay(2000);
   digitalWrite(MOTOR, LOW);
   digitalWrite(DIR, LOW);
  }
  else{
    digitalWrite(MOTOR, LOW);
    digitalWrite(DIR, LOW);
  }
}

The motor doesn't even come close to working correctly. I'm certain this is because I'm not the greatest at programming yet. :wink: I have something to work on, I suppose!

Also, adding in those two diodes didn't get rid of the problem I was having with the motor running after I turn off the switches, unfortunately. I'll have to tinker some more with it tomorrow.

I didn't dig into your code, but reading an input pin and acting on that to control output pins is pretty standard uC programming.

Make sure your switches are wired correctly.

TehPl0x:
I'm so glad you said something about the kickback diode across the transistor. My motor was continuing to run even after switching it off, and I couldn't figure out why. Now I know!

Unless you have wired it incorrectly that means that the lack of the diode has caused the transistor to fail :frowning:

I'm not very impressed by the University of Minnesota's Mech Eng department publishing that. Perhaps they should have more contact with the EE department.

Russell.

The free-wheel diode needs to be across the motor, not the transistor, but due to the relay switching
it would then be across the two common contacts, provide a route for current to
flow when the transistor switches off that doesn't involve frying it. Putting the diode
across the transistor is not going to help, you'll fry the diode too!

Remember the issue with inductive loads is that they force current to continue flowing
until the magnetic fields die down, and with whatever voltage necessary - provide an
easy low-voltage route and there won't be high voltages. The current is in the windings,
and needs to be allowed to keep going (it decays away slowly then, rather than blasting
through silicon components).

MarkT:
Remember the issue with inductive loads is that they force current to continue flowing
until the magnetic fields die down, and with whatever voltage necessary - provide an
easy low-voltage route and there won't be high voltages. The current is in the windings,
and needs to be allowed to keep going (it decays away slowly then, rather than blasting
through silicon components).

So I'm just going to have to deal with the motor continuing to spin after I shut it off? This is just a test circuit right now, but whenever I want to swap out my motor for a linear actuators, letting it continue running will not be an option. These two actuators are going to be for an adjustable standing desk. It would be pretty inconvenient if the actuators kept raising the desk even after I had shut them off. There has to be a way to dissipate the current being created by induction, otherwise nothing would shut off immediately, right?

The free-wheel diode needs to be across the motor, not the transistor, but due to the relay switching
it would then be across the two common contacts, provide a route for current to
flow when the transistor switches off that doesn't involve frying it. Putting the diode
across the transistor is not going to help, you'll fry the diode too!

You can use a MOV transorb instead.
The voltage across the motor reverses not the voltage across the transistor.

Edit:
add a MOV across the motor also.
.

Your transistors are only on if the s/w has them on. The default state might be motor on, relay on, in which case they are on until the switch is turned off. Since you don't have switches yet, it is not possible for the software to detect them in the off state. If you have a DMM (meter) measure the voltage on the base of the transistors and then across the transistors (collector to emitter). If the base = HIGH, the collector to emitter should be 0V (or very close to it). If the base = LOW, the col to emitter should be the battery voltage (12V). If you have damaged the transistors by not using the flyback diodes then the transistor will be shorted from collector to emitter. Check them on diode scale.

raschemmel:
Your transistors are only on if the s/w has them on. The default state might be motor on, relay on, in which case they are on until the switch is turned off. Since you don't have switches yet, it is not possible for the software to detect them in the off state. If you have a DMM (meter) measure the voltage on the base of the transistors and then across the transistors (collector to emitter). If the base = HIGH, the collector to emitter should be 0V (or very close to it). If the base = LOW, the col to emitter should be the battery voltage (12V). If you have damaged the transistors by not using the flyback diodes then the transistor will be shorted from collector to emitter. Check them on diode scale.

Yeah, my DIR transistor was in an always on state. I fixed it now. The arduino is a little finicky about detecting the switch states, but for the most part, it works. Now I need to figure out how to program the arduino to continually check the switch states, and run the motor based upon those states. Thanks a bunch!

Actually, I have one more question. I originally had the common terminals of my two switches connected to the 5V line on my breadboard. I thought that when the switch was open, the 5V wouldn't travel through to the arduino, but then when I closed the switch, the 5V would flow and return a "HIGH" state. This wasn't the case, however. The pins the switches are connected to always returned a "HIGH" state, regardless of which way I flipped the switch. When I rewired the common terminals to ground instead, the switches worked perfectly. Why is that? I was wiring the switches based upon this pull-down resistor diagram, but it didn't work. Maybe my switches are messed up; I have no idea.

It sounds like you have not wired the switches correctly.
You must identify the switch terminals properly.

Pins that are left floating will cause you intermittent problems ( they may be detected HIGH or LOW ).

Attach a picture of the switches.

.

Switch pins should be pulled high by a resistor (10k) and pulled to GND by the other terminal of the switch.

See this example.

Yeah, I had the resistors in the wrong place for pulling the current down. Would this work for pulling the unwanted current down? I want to make sure before I test this. I nearly destroyed my arduino with my incorrect resistor placement last time. :sweat_smile: Lol

Would this work for pulling the unwanted current down?

I have no idea what you are trying to say. I only speak Electronics.

Draw a schematic, take a photo and post the photo.

Arduino input pin should have a 10k pullup.
Other side of switch should go to GND.
Closing switch shorts input pin to GND (connecting pullup resistor across 5V & GND).
Input pin is HIGH Impedance (approx 100 Mohm) so there is no problem with shorting it to GND.