use ir receiver to control DC motor

i use the ir receiver to control the motor. but i got some problem. when the motor run ,the arduino will not response to ir signal again . i use the L298N to control the motor. and L298N voltage is directed connected to the Arduino 5v supply, not used any other component. maybe i should use a seperate battery and not the arduino 5v output pin ??

the L298N : pin4.pin ----- Arduino 5v output pin5,pin7 ------Arduino pin5,pin7 TTL Pin6 -------Arduino pin6 Ena pin1,8,15 --------Arduino GND

Ir ---- pin1 ------arduino 5v output Gnd --------Arduino GND data ----arduino pin2

Generally you shouldn't be powering motors with the Arduino's regulated 5 V line as it cannot supply the current required by most motors. You might also want to put some 0.1 uF capacitors across your motor terminals for noise suppression.

  • Ben

Yep this is a case of the interference generated by the motor crashing the Arduino. Running off a separate supply will help electromagnetically coupled interference can still cause problems. Supppress the motor by putting a small (say 0.1uF) none polerised capacitor across it.

thanks for your reply above all , i will try it . maybe i should do like that:

  1. use seperate Volatage supply
  2. L298 pin9 -- connect arduino 5v output and add a 100nf capacitors to GND. pin4 --connect seperate 5v and add a 100nf capacitors to GND. pin2,pin3 -- connect motor , add 4 diode to release the current in motor.

maybe is it right? and the volatage GND can share the Arduino GND?

other more ,anybody can teach me how to post a image?

Put the capacitors across your motor terminals directly, as close to the motor case as possible. Please see the following page for more information, including pictures that show where the capacitors should ideally be soldered:

Dealing with motor noise

Also note that you can (and probably should, given this controller’s nearly 2-V drop) the use more than 5 V for your power supply voltage, and unless you’re using a switching regulator capable of delivering high currents, you will not want your power supply voltage regulated. Using the regulated Arduino 5 V line for your logic voltage is fine.

  • Ben

Another problem you might have is that some timing intense tasks like using Ir can be disturbed when using PWM on the Arduino board.

Unfortunately you can't directly post an image. Only a link to an image that is somewhere on the web.

Another problem you might have is that some timing intense tasks like using Ir can be disturbed when using PWM on the Arduino board.

Why is this? Is this because the PWM routine is using a timer in a way that conflicts with the code used to do the pulse timing?

  • Ben

I think so. But maybe some of the “hard core” guys can shed a light on this, i just remember it being an issu from a way back thread.

thanks for reply . I will deal with it like what you teached me to use a capacitor to accross the motor terminal. But there is another problem about voltage. Because my motor is so small , the voltage supply of arduino is enough. it is possible to use it directly and not use seperate votage supply ? if i use an Opto-isolator ,it maybe play an role as seperate voltage supply. But should i use two Opto-isolator to isolate the PIN4 and Pin9 of L298?

Even if the Arduino board can supply voltage / current enough for your motor, you should seriously consider using a seperat supply. When the motor starts up, for a short time it can use much more current than when it's running continusly, this could be problematic for Arduino and give you all kinds of problems.

If you are using the same supply then it is a waste of time using an opto isolator, it won't do anything for you. If you do want to try and use the same supply then it must be decoupled strongly. That is use a separate 5V regulator or use and inductor and capacitor in the supply before it gets to your motor. You need a small capacitor to remove the high frequencies (0.1uF) and a large one (>100uF) to handle the current surges.

maybe i havenot express my idea clearly. i said the supply for motor is the Arduino voltage output pin. (The 5v output pin.) It isn't the same as the supply for Arduino, it's just arduino's output.Maybe the Opto-isolator can produce some effects?

Maybe the Opto-isolator can produce some effects?

You can't power something through an opto isolator only switch it. There is not enough drive capacity on the output transistor of an opto isolator to directly control the motor. Although there is enough drive on an Arduino output pin to power the LED part of the opto isolator. So the output of the opto isolator will have to control a transistor or FET to switch the motor. If you have done this then don't connect the Arduino power or ground to your motor supply power and ground otherwise you nullify the isolation the opto has given you.

maybe i havenot express my idea clearly. i said the supply for motor is the Arduino voltage output pin. (The 5v output pin.) It isn't the same as the supply for Arduino, it's just arduino's output.Maybe the Opto-isolator can produce some effects?

The 5 V output pin is the voltage that is "powering" your Arduino, for all intents and purposes. This is the output of the voltage regulator and it is directly used to power all of the onboard components (most crucially the mega168). Putting a motor on this regulated line will introduce all sorts of noise that can cause problems for your mega168. If anything, power your motor with the voltage you are supplying to VIN so that the Arduino's regulator can help with the decoupling.

  • Ben

thanks again. so i have to use a seperate voltage supply or the arduino Voltage input to driver motor. another hint is to connect one or two 0.1uf capcitor on motor termials. now i know that the output voltage pin of arduino only indicate its onboard “powering” and have not capacity to drive others. thanks.

The regulated 5 V on the Arduino can deliver power, just not very much. You can use it to power something like an RC receiver, LEDs, various sensors, etc. Motors start getting tricky both because they usually draw a lot of current and they can be fairly noisy (electrically speaking).

  • Ben