I'm currently working on a project with an RC car. Everything works fine, but when the variables of speed and steer are sent, received and set, they are not being received anymore.
I use two Arduinos. One has a dual axis potentiometer joystick and a transmitter, the other has a servo and an L293D with one motor.
I send the variables with VirtualWire. That works great. The program on the receiving Arduino is as follows (pseudocode):
check which one it is
calculate needed value
write the value to the corresponding object
But when it writes a PWM value above ~30 to the chip, it stops receiving signals (seen with Serial.print()) and the motor keeps spinning at that speed.
Only when I bring the antennas very close to each other it works again.
When the chip is not attached, this problem doesn't occur. It even just does work with an LED.
I'm thinking the chip needs to much power but I even powered the whole circuit with a 9V battery and that doesn't seem to help.
I can post the code tomorrow, if that's necessary.
Does someone know why this happens??
Hi, welcome to the forum.
It could be that electric noise from the motor is disturbing the receiver. That is just a wild guess, but it is possible and it could explain what you have.
How are the grounds connected ? A ground current from the motor could fill the receiver with noise.
Perhaps you can turn on a led when a valid packet is received.
Thanks for your answer.
The L293D has four GND leads for heatsink, that is attached and they are common.
The motor connection one goes to the chip output 1 and the motor connection two goes to the chip output 2.
Ground btw is everywhere common.
And yeah it has a noise, but that is audible. Probably ~400Hz from PWM. Not at 433MHz?
But I could test it, with a second receiver close to it and mointoring the results. I’ll post them here.
I will do that tomorrow.
The PWM is about 480Hz for most PWM pins.
The receiver is 433MHz, but the bitrate is often 2kHz.
The 500Hz PWM/motor noise could influence the 2kHz, either via the antenna via 433MHz or directly into the receiver to the data.
A common ground is not enough. A piece of ground wire of 10cm in the wrong place could be enough to introduce the noise from the motor into the receiver.
You could also add a snubber circuit to the motor, but good ground wires are essential.
Don't underestimate the ground current. I always keep that in mind, and sometimes I still make a mistake, when the ground current can take two paths.
A piece of ground wire of 10cm in the wrong place could be enough to introduce the noise from the motor into the receiver.
That will probably be the heatsink, then.
No, I'm talking about ground current.
The current from the battery is going into the L293D, into the motor, back into the L293D, and returns to the battery. That current that returns from the L293D to the battery is the ground current.
It depends on the rest of the circuit if that ground current has influence on the Arduino.
Okay I put another receiver next to the car (while the car was on, too) and this one just does receive the correct data, anytime.
So where the car stops with receiving, the second receiver works just fine.
That's really weird... I don't understand it anymoreee!!
I have even rewired some parts of the circuit and checked all the grounds... There couldn't be anything bad to all that.
EDIT: Okay now I attached the car receiver to another Arduino at the same time, now this Arduino also it stops reading variables... The problem is in the receiver.
So the receiver in the car stops reading out (receiving?) data, that's the problem.
But now what can I do about this??
Yes, that is what I was thinking. The receiver is blocked/filled with noise from the motor and does no longer receive valid data.
Could you make a photo of it ?
Do you use an antenna ?
Perhaps a snubber circuit on every motor.
Or a copper shield around the receiver.
Or a better antenna.
I do not have a solution, it might be hard to fix.
And when the second Arduino has the second receiver attached to it, with DATA connected between them, VCC connected between them, GND connected to everything (+ the car): it works (no interference).
But when DATA connected between them, VCC connected between the second receiver and the car Arduino, GND connected to everything (+ the car): it does NOT work (yes interference).
Here’s a link to my Drive, it’s a zip containing some pictures. I think they would be too big in total for the forum here.
I have just read about a snubber circuit, but I don’t really understand what it is what I should make. It has to be simple.
But would it be an idea to connect the shield of the motor to the ground?
Thanks for the photos. I looked at them a few times.
The wires from Arduino to receiver and others are very short, that should be no problem.
What is the 100 ohm resistor doing ? It seems as if it is connected to 5V and GND.
Do you use the 5V from the Arduino board for the servo motor ? The 5V voltage regulator is not able to supply enough current for a servo motor.
I would like to add a large capacitor for both motors, that is : for the servo motor and for the L293D.
Could you add a capacitor near the L293D of at least 470uF to the battery voltage and GND.
And another near the servo connector to 5V and GND.
The battery black wire is connected to GND on one side of the Arduino, and you use the GND on the other side of the Arduino for the motors. The ground current is going through the Arduino. Could you add a wire at the bottom of the Arduino that connects the GND from one side to the other side.
I'm not sure this will be enough, but it should help (I hope).
Okay I just did exactly what you said... I added a 470µF elco to the servo connector (5V Arduino regulated) and a 470µF elco to the L293D chip (9V battery).
(I also removed the 100Ω resistor, I used that for powering the circuit with my powerbank which only works for a few seconds when it supplies such a low current.)
But, still the same problem.
Then I disconnected the servo connector, still the same problem.
But what I did see...
I set the speed to max at the remote, the I walked to the car (I placed it a few meters away just for sure), then it did weird. It was clicking, it was spinning and immediately stopping.
But when I helped the wheels with spinning (like cranking an old car), they just spin, and the Arduino Power LED dies almost and immediately turns on again.
The wheels are still spinning.
Then I touch the wheels, with an increasing force, but then the Power LED dims and keeps dimming and at a certain point the Arduino resets.
I'll look if I can post a short video of this.
EDIT: I placed an Amperemeter between the battery and the circuit, the average value is 240mA, but when I'm touching the wheels this goes to 290mA and at 300mA the Arduino resets...
I’ll look if I can post a short video of this.
A schematic would be far more useful. It sounds, though, like you are expecting the Arduino to supply more current than it can. It is a controller, not a power supply.
Here's the schematic of the car.
Here's the schematic of the car.
I seem to be missing something...
I seem to be missing something...
I don't think so...
Here it is. And here (all svg).
Like it or not, the schematic was missing from your earlier message.
You are powering a receiver, the Arduino, and a servo from the internal 5V regulator on the Nano, which is a 78M05 rated at a max of 500mA.
What battery are you using for 9V? A little 9V battery won't power a servo and motor, it certainly won't put out 500mA without dropping voltage drastically.
What is the stall current of the motor? And of the servo?
What is your power supply rated at? Is it regulated?