B4R Question Why does the use of the rServo library cause anomalies on the ARDUINO UNO card ?

Marc DANIEL

Active Member
Licensed User
My B4R program works fine on MEGA2560 but bug on Arduino Uno ...

Using the servomotor does not cause problems on Arduino Uno but the sending of the PWM signal is interrupted on the rear motor
 

Attachments

  • VoitureArduino.zip
    2.8 KB · Views: 31

hatzisn

Well-Known Member
Licensed User
I am not in front of my computer to check the code but I have heard in a lot of videos in YouTube over and over again that you ought to power the motors with external power so if you don't it may be a power issue.

Edit - You also have to bridge the ground of external power and internal arduino ground
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
Merci pour votre réponse, mais j’alimente directement le moteur contrairement au servomoteur qui y est connecté à la sortie 4,5 V des cartes Arduino et comme je l’ai écrit plus haut, tout se passe bien sur Arduino Mega mais pas sur Uno

Fritzing.png
 
Upvote 0

klaus

Expert
Licensed User
I had a look at your code.
You use pin 4, but on the Arduino UNO, this pin does not support PWM, only pins ~3, ~5, ~6, ~9, ~10, and ~11 support PWM.

J'ai regardé ton code.
Tu utilises la borne 4, mais sur l'Ardiono UNO, cette borne ne fonctionne pas en PWM (modulation de largeur d'impulsion, seules les bornes ~3, ~5, ~6, ~9, ~10, et ~11 supportent PWM.
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
Yes, Klaus, you are right and I know these PWM terminals but I believe I have already tried all the terminals on UNO.
However, I will be carrying out further tests with this card.

Oui, Klaus, tu as raison et je connais ces bornes PWM mais je crois avoir déjà essayé toutes les bornes sur UNO.
Cependant, je vais effectuer de nouveaux tests avec cette carte
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
Klaus, je viens de tester le programme avec la carte ARDUINO en modifiant les PINs attribués à IN1 (5 au lieu de 4) et IN2(6 au lieu de 5) et j'obtiens hélas les mêmes résultats que précédemment: le servomoteur fonctionne bien mais les roues arrière restent immobiles ... et si je supprime l'utilisation de la bibliothèque rServo en conservant le même programme, les roues arrière tournent bien sûr... C'est pourquoi je pense que la carte Arduino Uno est "perturbée" par l'utilisation de la bibliothèque rServo même si le servomoteur fonctionne correctement, il y a une incidence sur les autres broches PWM qui contrôlent le moteur arrière.
Cordialement,
Marc

Klaus, I have just tested the program with the ARDUINO card by modifying the PINs assigned to IN1 (5 instead of 4) and IN2 (6 instead of 5) and unfortunately I get the same results as before: the servomotor works well but the rear wheels remain stationary ... and if I remove the use of the rServo library keeping the same program, the rear wheels of course rotate ... This is why I think the Arduino Uno board is "messed up" By using the rServo library even if the servo motor is working properly, there is an impact on the other PWM pins which control the rear motor.

Regards,

Marc
 

Attachments

  • VoitureArduino.zip
    2.8 KB · Views: 29
Upvote 0

Marc DANIEL

Active Member
Licensed User
et pourtant le fabricant du servomoteur indique une alimentation sur la carte Arduino:
and yet the manufacturer of the servomotor indicates a power supply on the Arduino board:
Alimentation1.png

Je vais tout de même tenter une alimentation externe avec une deuxième source sinon je resterai connecté sur ma carte Mega2560 qui va très bien (Elle est juste un peu envahissante...)

I will still try an external power supply with a second source otherwise I will stay connected to my Mega2560 card which is fine (It is just a little intrusive ...)
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
Non, cela ne fonctionne pas plus avec une alimentation extérieure pour le servo
No, it does not work anymore with an external power supply for the servo

PowerMG996R.png
 
Upvote 0

klaus

Expert
Licensed User
I had a closer look at your code and saw that the pins IN1 and IN2 do not need to be PWM as these are pure digital.
Only pin ENA need PWM, and this one was already OK in the previous version.
I suppose that Log("Vitesse de la voiture:",SpeedM) shows the correct value.

So, I do not know why it does not work on the UNO.
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
Pas de souci, je voulais juste tenter de savoir quelle était la cause exacte de ce dysfonctionnement. Peut-être que ce bogue disparaîtra dans une prochaine version de la bibliothèque rServo ?

No problem, I just wanted to try to find out what the exact cause of this malfunction was. Maybe this bug will go away in a future version of the rServo library?
 
Upvote 0

Marc DANIEL

Active Member
Licensed User
I downloaded the latest Arduino version of the Servo library and replaced the old one from 2019 in ARDUINO. Then I will redo a test on an Arduino Uno with my application "Arduino Car"
 

Attachments

  • Servo-1.1.8.zip
    125.3 KB · Views: 24
Last edited:
Upvote 0

Marc DANIEL

Active Member
Licensed User
The proof that it is indeed the rServo library that causes anomalies in the program is that as soon as this library is removed, the car works properly except obviously the servo motor which can no longer function properly without its rServo library and which risks destroying the steering system !!!

because "MyServo.AnalogWrite" does not match "MyServoWrite" with the rServo library

The conclusion is that you have to use a MEGA2560 card with the original program!

La preuve que c'est bien la bibliothèque rServo qui provoque des anomalies dans le programme est que dès que l'on supprime cette bibliothèque, la voiture fonctionne correctement sauf évidemment le servomoteur qui ne peut plus fonctionner correctement sans sa bibliothèque rServo et qui risque de détruire le système de direction !!!

parce que "MonServo.AnalogWrite" ne correspond pas à "MonServoWrite" avec la bibliothèque rServo

La conclusion est donc qu'il faut utiliser une carte MEGA2560 avec le programme original !
 

Attachments

  • VoitureArduinoUNO.zip
    3.1 KB · Views: 26
Upvote 0

Marc DANIEL

Active Member
Licensed User
Finally, I come back to you. I managed to use an Arduino UNO board to operate an ARDUINO car with the servo motor at the front and a rear motorization BUT in association with the shield board YROBOT XBee Motor Driver:

PM-R3 shield.jpg


MiniUNO&YROBOT.jpg
 
Last edited:
Upvote 0

Marc DANIEL

Active Member
Licensed User
Pins D5 and D6 must be used for the management of the rear motors (PWM) and pins D4 and D7 to manage the direction of rotation of the wheels. The servomotor is simply plugged into the 3 colored pins at 3. The only physical connections are therefore the servo motor, the system power supply, the rear motor(s), and the Bluetooth system if used.
 

Attachments

  • 4WD_YFROBOT.zip
    2.6 KB · Views: 16
Last edited:
Upvote 0
Top