NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » sudden slow reaction

September 25, 2012
by escartiz
escartiz's Avatar

Hi everyone

I have been working on a project that was working fine and all of the sudden everything is responding in slow motion or delayed,

This is what I have

  • two pins to control a 12v motor with a L298N
  • two limit switches to two more pins to stop the motor in any direction.
  • two more pins to light up 2 leds, green for standby and another red one when motor is activated
  • temp sensor that actives motor CW or CCW
  • another pin with a 10k trimpot to adjust temp sensor value to turn cw or ccw

I had everything working perfect. So the code is not the issue.

Then I wanted to turn on a 120v AC lamp instead of the red led to indicate motor movement and everything slowed down.

  • I connected the red led pin to a 2n7000 mosfet center pin
  • Drain to ground
  • 100k resistor between gate and drain
  • Source to a relay relay coil pin 1
  • ground to relay coil pin 2
  • relay pin 5 and 3 to to 120ac lamp wire to act as switch

My main problem is that after adding the mosfet, resistor, and relay the limit switches begin taking a couple second to do their work and the motor goes beyond the stopping points.

Also any re adjusting to the trimpod takes couple seconds to start/reverse the motor.

Removing the mosfet/resistor/relay makes everything work as it should.

So I wonder if I am missing something here, should changing the resistor value fix this unwanted delay??? and if so what values should I try.

Any help is really appreciated.

September 26, 2012
by sask55
sask55's Avatar

Escartiz

The slow responses is a strange consequence.

From your description it would seam you have the connections to the 2n7000 incorrect. See the Servo Squirter Tutorial for a example of the correct connection. Basically the mosfet must be placed on the low (ground) side of the load, The source goes to ground, the drain goes to the load, that is your relay coil pin 1 The other side of the load, your relay pin 2, would go to a + voltage source in this case it should be a supply that is 12 volts above ground.

Also on the relay to have a normally open switched circuit to the lamp, you will be using pins 4 and 5 not pins 3 and 5.

You may want to consider using a fly back diode in parrellel to the coil to handle any EMF voltage produced by the switching of the relay coil is an inductive load.

September 26, 2012
by BobaMosfet
BobaMosfet's Avatar

Inductor inductor inductor....

BM

September 26, 2012
by escartiz
escartiz's Avatar

Thanks for the suggestions. I verified the mosfet connections and they are correct as you mention, also the pins 4 and 5 on the relay instead of 3 and 4 are correct.

I placed a 1N4148 diode parallel to pin 1 and 2 (not sure if this diode is appropriate) , I also fixed a loose cable on the breadboard that I hadn't notice. It works perfect now :)

Thanks a lot,

September 26, 2012
by Ralphxyz
Ralphxyz's Avatar

fixed a loose cable on the breadboard that I hadn't notice. It works perfect now :)

That one will getcha all the time.

Glad you got it working!

Ralph

September 27, 2012
by sask55
sask55's Avatar

Yes! it is good to here you got it working.

I am very curious about the nature of the circuit the problem, and steps you took to fix it. There is very little similarity between the circuit that you described in your first post and the circuit I described to make the connections correctly.

When you say “I verified the mosfet connections and they are correct as you mention” are you implying that they where correct all along? Or do you mean you made all of the changes to correct the circuit? If the circuit was set up anything like what you had described both inductance of the coil and any loose connections on the board would have been irrelevant, there is no way the lamp could light or the coil be energized.

Was the circuit set up as I described all allong? Then why was it described, with such detail so incorrectly, in your original post? "I connected the red led pin to a 2n7000 mosfet center pin" was the only piont that was correct.

I am just confused about what was done to get your project working.

September 28, 2012
by escartiz
escartiz's Avatar

Yes the mosfet was connected correctly all the time, aswell as the relay. I made two mistakes on my description, meaning

  • led pin to a 2n7000 mosfet center pin
  • source to ground
  • drain to relay coil pin 1
  • 120v lamp to relay's pin 4 and 5

I am not sure what was the issue or what could have fixed it. The only things I did was making sure all the cables were in place and added the diode as you told me.

The lamp was lighting fine all along, the issue was that before adding the mosfet/relay/lamp everything worked as expected meaning fast, right on time as soon as the sensor would reach the trimpot value.

But after those changes everything became slow although doing what it is suppose to do, the switches wouldn't deactivate the motor on time, and the light/led also would take a few seconds to light up/turn off

Right after adding the diode and checking all connections, turned it on and it light up as soon as the value was reach and the motor stoped as soon as it touched the switches

I am also very confused what caused/fixed the delay :S

September 29, 2012
by sask55
sask55's Avatar

There were clearly five important differences, not two, between the circuit you originally described and the circuit I described.

If the circuit was indeed set up correctly all along, as you now say, then the issue was NOT the inductance of the coil. The fix was NOT the diode. As important as a fly back diode is it has no active part in the circuit when coil is being energized. The diode should shut EMF voltage spikes as the coil is de-energized when the circuit is turned off. I would have no effect on energizing the coil and therefore EMF was NOT the source of the issue.

That only leaves the bad (loose) connection as the source of the issue.

September 29, 2012
by escartiz
escartiz's Avatar

I have confirmed what you are saying, I have removed the diode to test and see if I could find the issue again and it works fine without it. Besides the mosfet and relay order, what are the other 3 differences on my circuit?

September 29, 2012
by sask55
sask55's Avatar

First thing, I was not saying the diode was not important in the circuit. It may be very important to have it in place. It should protect the circuit from the voltage spikes that will occur each time the relay coil is de-energized. What I was saying was that the voltage spikes will only occurs as the coil is de-energized and therefore this would not explain what was going on when the coil was being energized. I would continue to use the diode for sure.

I think I may have used the term EMF somewhat incorrectly in my earlier posts. It is the voltage spike that will occur when the current supply to an inductor is suddenly stopped and the magnetic field is collapsing that I was referring to. Strictly speaking I don’t think that is referred to as EMF.

What I was referring to are the five changes that had to be made in your from your original post description of your layout.

You described the connections as

1 •I connected the red led pin to a 2n7000 mosfet center pin -this connection is correct

2 •Drain to ground - Source to ground is correct

3 •100k resistor between gate and drain - No resistor is required

4 •Source to a relay relay coil pin 1 - Drain to relay coil pin is correct

5 •ground to relay coil pin 2 - 12 volt supplies relay coil pin is correct

6 •relay pin 5 and 3 to to 120ac lamp wire to act as switch - relay pins 4 an 5 to lamp wire is correct

Five of the six points were incorrect.

As it was not just the functioning of the lamp that was involved but the functioning of the entire MCU, it is a mystery to me what was going on. I am very uncertain how I would replicate your original problem in hardware without any software changes.

In any event it is working now and that is good.

Post a Reply

Please log in to post a reply.

Did you know that two resistors plus a transistor can be used to make a better voltage supply? Learn more...