ULTRASONIC with DC MOTOR Problem

Hi, I have a problem when using the ultrasonic sensor with a dc motors, the task I want to do is when the reading of the sensor less than 40 cm moving motors forward. and when the readings more than 40 cm move motors backward or rotate, this is already happening without any problems in programming But the readings of the ultrasonic is wrong sometimes maybe zero or 1 , and because of it the movement is not 100% and non stable , Anyone can help me to solve this problem?
The defect is not from connections or programming because the motion occurs but is not balanced.
My expectations are that the noise of the dc motor is affected on the sensor signals , that’s true ?

Thanks in advance

ahmadelwaly:
Hi, I have a problem when using the ultrasonic sensor with a dc motors, the task I want to do is when the reading of the sensor less than 40 cm moving motors forward. and when the readings more than 40 cm move motors backward or rotate, this is already happening without any problems in programming But the readings of the ultrasonic is wrong sometimes maybe zero or 1 , and because of it the movement is not 100% and non stable , Anyone can help me to solve this problem?
The defect is not from connections or programming because the motion occurs but is not balanced.
My expectations are that the noise of the dc motor is affected on the sensor signals , that’s true ?

Thanks in advance

Certainly possible. Everything moving makes noise and the bearings of your motors may be doing it in the the ultrasonic range.

Things to try: Reduce speed of motors. Lubricate the bearings. Increase the speed of the motors. Replace the motors.

Paul

Duplicate of post https://forum.arduino.cc/index.php?topic=599780.0

Don't cross post!

slipstick:
Duplicate of post https://forum.arduino.cc/index.php?topic=599780.0

Don't cross post!

fixed

Using a SR04? You can modify the SR04 for greater accuracy, such as the receiver is 38Khz instead of 40Khs, the up voltage converter is very noisy, and other modifications for about 30USD, that will greatly improve the SR04.

You can go through a pile of SR04's and find two that, when pinging, do not produce the same errors and code out the errors of both sensors. I had pretty good results with this method. I'd fire A and if A got a hit, I'd fire B to confirm the hit. Solder a cap across the V+ and ground pins on the SR04's to reduce noise. I used a 10nF (103). I found mounting A and B on top of each other worked a lot better then having them next to each other.

I ended up using a TFMini in single trigger mode. Cost about the same as all the modifications to the SR04.

ahmadelwaly:
But the readings of the ultrasonic is wrong sometimes maybe zero or 1

Add code to ignore 0 or 1 or other obviously bad readings.