L293D + DC motor = problem with 2 digital inputs

Hi everybody!

At first I would like to thank you for your answers in advance.

I have a problem I can't solve! I am totally new in the world of electronics so take bear with me.. :-?

I have a sketch like this (the chip on the breadbord is (suposed to be) L293D):

On pins 2 and 3 I attached interrupts and turned on pull up resistor like this:

pinMode(2, INPUT);
digitalWrite(2, HIGH);
pinMode(3, INPUT);
digitalWrite(2, HIGH);
attachInterrupt(0, myFunction1, CHANGE);
attachInterrupt(1, myFunction2, CHANGE);

I am able to control the DC motor. It works OK... But the problem is I am getting interrupt signals without pressing on buttons... It looks like some noise... There is a lot more of interrupts (that shouldnt be), when the motor is spining.

Any idea?

Thanks again for your time!!

Is that drawing an accurate one?
Could it be induced noise from the motor?
What happens if you leave the code as it is, but disconnect the wires to the interrupt pins, and use serial commands to start and stop the motor.
Do you still get interrupts?

Why are you using interrupts to read the button state? Is there something that you are not showing us that is preventing the Arduino from reading the button state often enough?

Perhaps that could (should?) be addressed.

[edit]You are turning on the internal pullup resistors, while the sketch shows external resistors. Are you using both?[/edit]

Those look like series resistors to me, not pull-ups.

That is true, it is not helping in the noise pickup stakes.

Also you have absolutely no decoupling in that circuit:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Answer to AVOL post:

If I leave the code as it is, but disconnect the wires to the interrupt pins, and use serial commands to start and stop the motor I don't get interrupts. So it's almost for sure the induced noise from the motor like you said... Is there any way to reduce the induced noise from the motor?

Answer to PaulS post:
I am ussing interrupts as I wan't to stop the motor as soon as I get interrupt from one of two bottons without executing any additional line of code.... I am sure there is no code that would prevent Arduino from reading button state often enough.....

And yes.. These are series resistors just for protection not relevant for now I think..

Thanks all of YOU for fast responses.. :slight_smile:

Grumpy_Mike - do you think de-coupling is solution?

I am ussing interrupts as I wan't to stop the motor as soon as I get interrupt from one of two bottons without executing any additional line of code....

Imagine your motor is running at 6000rpm.
Sounds fast?
That's 100 revolutions per second or 100Hz.

Your Arduino is running at 16MHz, and so is checking the state of interrupts about 16 million times a second (a bit less because some instructions take more than one cycle).

In one instruction cycle, your motor rotates 0.00225 of a degree (at 6000rpm, remember).

Do you really need that level of control, because even if you cut the power and shunt the motor, it's going to take a lot longer to actually come to a halt.

AWOL I think you are right about that... But this is not the solution for the problem I have? Isn't it? Even if I do normal digital readings I would have same problems am I right? Or should I try without interrupts?

Using digitalRead, you may have the same problems, but they'll be a lot easier to deal with, and will leave your interrupts free for important stuff.

I recommend you look a Grumpy Mike's tutorial on decoupling.

Thanks to all of you!! I will try with de-coupling and let you know if it was a solution or not...

Is this schematics OK or am I missing something?

What types of capacitors should I use (ceramic, electrolytic...)??

Anyone... Is it the right way I "decoupled" the schematics up there or am I missing something?

Does anyone know for a forum, that would be apropriate for the question about decoupling I have?

Richard Crowley thank you very much for pointing me at the right direction!!!

The last image from http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html:

made me think, that it is a good idea to decouple a DC motor to prevent unvanted noise...

Just one more question... Which software do you recomend for schematic diagrams?

Hello again.. :slight_smile:

Richard, I appreciate your help and patience.. :slight_smile: And yes.. You are right that Fritz draws schematics too, but I didn't knew that at the time... Another thing I tried with Eagle is, that I would like to make my own PCB....

I redraw the schematic... I think it's OK now... I have just few questions more:
What should be the value of the choke on the schematics?
What about if I have let's say 2 X L293D chips, do I have to make two exactly the same circuits ?

And one more question about the Eagle:

I don't know how to make holes on the bottom layer of the PCB... I need the holes becaus I would like to make a PCB by myself, so the preapared holes on the PCB would make things easyer to drill!

Thanks in advance!