Transistor wont trip relay coil when motor is attached

I wrote a sketch to monitor a pair of REED switches, 1 trips to LOW when a linear actuator (that drives a piston water pump) reaches max extension, the other goes low when the actuator retracts. My sketch compares the switches status and then biases a darlington (TIP120) base accordingly to cycle the actuator through its range of motion.

I cross wired an Omron 24VDC coil relay to switch polarity …hooked up a 4 amp 24 volt power supply and the system seemed to work just fine. The relay coil switched on and off in accordance with the position of the actuator (fitted with a magnet on the end). I checked for polarity switching with a DMM and it all looked great. 24 VDC was applied across the com contacts and I measured 24 or -24 V depending on the coil status.

So then I attached the actuator motor to the NO contacts of the relay. Now the “Extended” REED switch failed to turn the coil on in time…the actuator ran to the end of its travel (something the mfr says not to allow). I found that it takes many seconds for the TIP to pass enough current to trip the coil. Eventually it does but I can’t understand why it takes so long.

I tried using limit switches that I know are good but same problem. Also tried using a larger 24 V 4 amp PS …the motor only draws 0.4 amp. I’ve got a blue cap across the coil contacts and a diode although this relay is pre-fitted with them.

I have made a few successful projects now using TIP120/PWM pin to control things…I’ve got a 1000 ohm resistor between the pwm and the base.

I’m powering the Jeenode with a 78L05…I put a pair of diodes between the 24V supply and the input pin just to give a bit of voltage drop from the 24 volts (although it is rated to 35 volts). Measure 4.9 volts out to the jeenode.

I’m at a loss…any advice or suggestions on how to debug would be great. Attached are my sketch and a photo of my “driver” and homemade pump (using a stainless steel pneumatic ram, check valves not yet installed).

EDIT: I thought i attached the sketch…here it is in case it helps:

/* Describe: Driver for low a low speed positive displacement water pump
Saved to: Documents\farmstuff\Arduino\WATER
*/
// Make DIO pin assignments
#define ExtendedReedPin 4 //DIO1, port 1 DIO on the Jeenode
#define RetractedReedPin 5 //DIO2 on the Jeenode
int TIP120pin = 6; // this is DIO3 (this is a pwm pin)
//Variables that will change
int ExtendedState = 0; //Current state of the Extended Reed Switch
int RetractedState = 0;
int OutState = 0;

void setup () {
Serial.begin(9600);
pinMode(ExtendedReedPin, INPUT_PULLUP); // initialize the DIO as inputs or outputs
pinMode(RetractedReedPin, INPUT_PULLUP);
pinMode(TIP120pin, OUTPUT);

if (ExtendedState == HIGH && RetractedState == HIGH) {
analogWrite (TIP120pin,255); // analogWrite only applies to pwm pins
}
}

void loop () {
//analogWrite (TIP120pin,0);
Serial.print (OutState); // all of the serial.prints are for debugging
Serial.println(TIP120pin);
delay(50);
//READ Reed switches: open or closed:
ExtendedState = digitalRead(ExtendedReedPin);
RetractedState = digitalRead(RetractedReedPin);

if (ExtendedState == LOW && RetractedState == HIGH) {
//digitalWrite(OutState,LOW); // This does not work
analogWrite (TIP120pin,0); // this does
}
if (ExtendedState == HIGH && RetractedState == LOW) {
analogWrite (TIP120pin,255);
OutState = digitalRead(TIP120pin);
}
Serial.print ("ExtendedState = “);
Serial.print (ExtendedState);
Serial.print (” RetractedState = “);
Serial.print (RetractedState);
Serial.print (” Output to TIP120 = ");
Serial.println(OutState);

}

SANY0045.JPG

Please supply a wiring diagram.

Measure across the switch that is slow to see if the switch actually operates at the right time. Is the delay due to electronics or mechanics? It may be that the switch is too slow to operate so needs to be moved or a stronger magnet is required so it operates sooner.

Weedpharma

I’ve done my best with the wiring diagrams. The arduino/TIP120 was lifted from http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/
Which is where I learned to use transistors to switch relays.

The polarity reversing cross wiring diagram is from forum.arduino.cc/index.php?topic=63783.0
Lefty’s instructions were spot on and it worked the first time.

< Measure across the switch that is slow to see if the switch actually operates at the right time. Is the delay due to electronics or mechanics? It may be that the switch is too slow to operate so needs to be moved or a stronger magnet is required so it operates sooner.>

I’m sorry I did not make this clear. The problem is electronic. I put the voltmeter across output pin 6. With no load on the relay it goes to 3.2 volts and trips the coil when the “Extended” switch is closed. But when I connect the actuator motor (24 v, 0.4 amp), then when the Extended switch is CLOSED it does not result in an immediate 3.2 volt output from pin 6. It takes from 3 to 10 seconds for this to happen. I’m on my second day watching this happen 

I tried 3 different switches here that I first checked with an ohm meter, they all worked fine, NO but closed when … closed. But the problem persists. I also tried a stronger magnet – no soap. Then I tried a limit switch (with a little roller, NO). It is definitely not mechanism of the switch itself.

I put the photo of the overall setup because I wondered if the collapsing coil upsets the 328? Itsn’t there some sort of electromagnet nuclear pulse when the coil goes down? I did put a diode across but this fancy relay has one already inside.

Very frustrating because I know this has got to be an ordinary problem with a simple fix.

Thanks for your help. Oh right, I do have a Leonardo board but I wanted to save it AND put this jeenode that’s been laying around to use. The Leo, I hope will be an interface for a spectrophotometer…another day.

BTW/ I’m getting a 502 Bad Gateway crash ,seemingly from this site only. in case it is important

You should have a commutation diode wired across the motor , at the motor with leads as short as possible

I mean the relay of course , what makes you so sure ther is a diode inside ?

Also mounting power components on a bread board is not a good idea.

Show a better picture of your circuit not someon elses.

If it only happens when the motor is connected which is high current it could easily be a bad connection

Hi,
You cannot place a commutating doide across the motor because you are reversing it.

Please, please, can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
NOT a fritzy diag.

Hand drawn is easiest.

Can you please post a copy of your sketch, using code tags?

May I suggest during testing you put the limit switches closer together so over shoot does not mechanically damage the endstops.

If you bypass the reed switches when the actuator is running in its relevant direction, does it stop.
I presume you have tested that the reed switches and the motor direction correspond.

I find it very bad that the actuator has no internal limit switches wired to the motor.

A quick look at your program, are you trying to get continuous back and forth running of the actuator.
You have catered for each of the limits being low but not when they are both high.
I would have a relay to change direction and a relay to stop the motor.
And an input to stop and start it.
Tom...... :slight_smile:

You have not shown the switches.

Your if (extended==high &. Retracted == low).

Can have the same state, ether both high or both low depending on your wiring. This will stop the statement following being done.

Weedpharma

TomGeorge:
Hi,
You cannot place a commutating doide across the motor because you are reversing it

Tom...... :slight_smile:

No quite.
There should be one though across the supply leads close to the contactor

It appears to be a big ask to use a 78L05 from 24v via a couple of diodes.

They are only rated at 100mA and I did a quick look for Nano current drain and some came back at 46mA at idle.

Also wondering why you use a large transistor to turn on a small relay.
I realise it is a darlington but still, bit of an overkill, no other problem with using it as I see though.

The diode should be across the relay coil directly not on the transistor C to Gnd.

Weedpharma

TIP120 has an inbuilt protection diode....plus as above.

He actually said there was in his text.

Diode in picture is not his circuit its a pic of someone elses.

Hi;

//digitalWrite(OutState,LOW); // This does not work
analogWrite (TIP120pin,0); // this does

digitalWrite(TIP120pin,LOW);
will work.
as will
digtalWrite(TIP120pin,HIGH);
Tom.... :slight_smile:

Boardburner2:
No quite.
There should be one though across the supply leads close to the contactor

Good Idea, will do. thanks

past my bedtime here, will try drawing a circus diagram in the am. The reed switches go to input pins. i'll try to clear up all the questions tomorrow...thanks for all the repsonses very much. tis quite a drought here so this is more than a "back burner" issue for me. Not sure what i did wrong with the code post...will try attaching again.

i have attached the code this time…i hope

LinearActuator_PumpWithPolaritySwitchingRelay.ino (1.56 KB)

Drawing would be good.

A pic would also be a good idea as with power circuits, especially with motors involved , the physical layout of the wires can be important.

Circuit drawing attached. all the commons and grounds are connected to the Battery neg. I’ve tried using a 24V regulated power supply too. but the problem is still the same.

Also, I tried using a handheld magnet. if i close the extended reed during the extension phase the delay is present. But there is no delay when the retracted reed is closed. So sending pin 6 LOW is not a problem. Just going HIGH is a problem.

fLINTsTONEcad.pdf (106 KB)

Here is a closeup of the wiring

wiring closeup photo.jpg

TomGeorge:
Hi,
You cannot place a commutating doide across the motor because you are reversing it.

Please, please, can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
NOT a fritzy diag.

Hand drawn is easiest.

OK I HAVE DONE THIS, ROUGH AS GUTS BUT SO AM I.

Can you please post a copy of your sketch, using code tags?

May I suggest during testing you put the limit switches closer together so over shoot does not mechanically damage the endstops. YES I HAVE DONE THIS. IT HAS SURVIVED SEVERAL OVERSHOOTS TO END OF TRAVEL...AS LONG AS I'M THERE TO FLIP THE TOGGLE OFF IT CAN TAKE SOME ABUSE.

If you bypass the reed switches when the actuator is running in its relevant direction, does it stop.
I presume you have tested that the reed switches and the motor direction correspond.

I STOPS IN THE RETRACT PHASE BUT WONT STOP IN TIME IN THE EXTEND PHASE

I find it very bad that the actuator has no internal limit switches wired to the motor.

SMC SELLS A SEPARATE CONTROLLER...VERY PRICEY. I HAVE A LIMIT SWITCH YET TO INSTALL

A quick look at your program, are you trying to get continuous back and forth running of the actuator. YES
You have catered for each of the limits being low but not when they are both high. BOTH HIGH = DO NOTHING, WHERE IS THE GUY WHO TAUGHT ME THAT...GAMMON!
I would have a relay to change direction and a relay to stop the motor. BRILLIANT ... I WILL DO THIS NOW
THEN I CAN ADD A TIME DELAY TO ALLOW THE COIL TO ACTUATE. THAT IS A WORK AROUND BUT I DO WISH TO UNDERSTAND THE SOURCE OF THIS DELAY. I'M GOING TO PUT A 100 OHM RESISTOR IN PLACE OF THE MOTOR...GET RID OF ANY POSSIBLE RADIATION FROM MOTOR WINDING COLLAPSE TYPE THING
And an input to stop and start it. WHAT SORT OF INPUT DO YOU MEAN TOM///AND THANKS VERY MUCH!
Tom...... :slight_smile:

Shouldn't the jeenode be powered by 3v (rather than 5v). I thought this was the reason for including the two diodes (as a voltage drop to the output of the regulator) but looking again, this is not the case.

I don't think this is necessarily causing your problem but I'm also pretty sure there should be some capacitors around the implementation of the 78L05 if you want it to operate smoothly. Especially when there is noise present (such as a motors or coils in the system).