Anybody with confli...
 
Notifications
Clear all

Anybody with conflict with Servo.h and optical speed sensor?

7 Posts
3 Users
0 Likes
1,315 Views
(@hegom)
Member
Joined: 4 years ago
Posts: 5
Topic starter  

Hi all.

Iam building a 'classic' 2 wheel robot, with arduino uno, a sensor shield, a motor shield, a servo for rotate the ultrasonic sensor and ultrasonic sensor (for obstacles avoidance) .

Everything was working fine, until i decided to add a couple of optical sensor for speed detection.

First of all, i had to include another library to manage them and timers. Ok they blinks when wheels moves, and i obtain values to read.

The 'head with Ultrasonic sensor, move too, bound to a micro servo, and this is ok, BUT only the left motor run, the right one is still.

If i remove link to timers and optical sensors library and comment every connected line in the sketch, the left and right motor works fine again.

Ok, there is a conflict between libraries and motor shield? why only on right motor? is it related with pins iam using for it?

Before you ask for details, there is something so BIG iam not seeing in all this?

ย 

thanks for everybody can help me. Iam blocked in completing this project. ๐Ÿ™ย 


   
Quote
Macoofer
(@macoofer)
Member
Joined: 4 years ago
Posts: 27
 

@hegom Hi,

ย 

Unfortunately, without details, I'm afraid nobody will be able to say anything useful on this issue.

- Which Servo and sensor are used

- Which library was used for the sensor

- How did you power up your project

- What is the code you used

ย 

So the big thing you are missing to solve your problem are the missing details 😉ย 

I'm sure many of us would be able to help you solve your problem, once you provide that info.

ย 

Regards,

ย 

Macoofer


   
ReplyQuote
(@hegom)
Member
Joined: 4 years ago
Posts: 5
Topic starter  

hello Macoofer,

you are right, i wanted just to avoid to bore with too much 'data' at first impact, but, 'data' are needed anyway ๐Ÿ™‚

here they are:

Iam using:

ย 1) arduino uno

2) arduino sensor shield v.5.0

3) motor shieldย  ย  https://www.amazon.it/gp/product/B07CHBRF4Z/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

4) speed sensorย  ย  https://www.amazon.it/gp/product/B07VSGKQQF/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

5) Servo MicroServo TowerPro SG90

6) ultrasonic sensor HC-SR04 4 pin

This is the kit link (but i bought some pieces at different places) https://www.amazon.it/gp/product/B074CXBC7H/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1

Links toย  sensor shield:

HC-SR04<<<<<<<<<<<<<<<<
GNDย  --> 12G,
ECHO--> 12S
TRIG-->ย  13S
VCC-->ย  ย  13V (+5V)

SERVO<<<<<<<<<<<<<<<<
GND--->8G
VCC--->8V (+5V)
Signal-->8S

MotorShield<<<<<<<<<<<<<
ENA-->6S
IN1-->7S
IN2-->5S
IN3-->4S
IN4--->10S
ENB--->9S
+5V --->10V (+5V)ย  this is the pin , on motor shield, that isย  allowable after removing jumperย  onย  ENB.

Actually i ignore why it have to be connected, since that sensor shield andย  motor shield, are powered in parallel by battery pack.

After i added speed sensor, i connected them to pin 2 and 3 of the sensor shield, where i know are 'connected' interrupts 0 and 1.

ย 

thanks for your help.

This post was modified 4 years ago by HEGOM

   
ReplyQuote
Macoofer
(@macoofer)
Member
Joined: 4 years ago
Posts: 27
 

@hegom Well, if the sensor and motor shield, as well as the servo are powered by the battery directly and not from the +5V on the Arduino, then you can rule out a power shortage.ย 

The fact that only one motor runs after adding the sensor code hints into the direction there is a flaw in the IDE code (my guess is a misplaced bracket)

You can start ruling out some things by temporarily re-assigning the pins, to where both motors would respond to the same fraction of code, switch left and right motor, etc, just as a test.

In order to give a better advice, we would need your IDE code that you are using.

ย 

Mac

ย 

P.S. I just noticed The Dronebot Workshop (Bill) actually did a full youtube video on this robot, with the speed sensors:

In case you haven't yet, check out that video and the related website article that has all the details and code.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2042
 

@hegom

The kindle thingys don't show up for me.
In the Leave a reply editor you will see a paper clip symbol and Attach Files for adding images to your posts.
Where are you getting your information for building this basic robot? There are complete examples you can follow which include explaining how it all works like the above Bill's Robot Car example.

ย 


   
ReplyQuote
(@hegom)
Member
Joined: 4 years ago
Posts: 5
Topic starter  
Posted by: @macoofer

@hegom Well, if the sensor and motor shield, as well as the servo are powered by the battery directly and not from the +5V on the Arduino, then you can rule out a power shortage.ย 

The fact that only one motor runs after adding the sensor code hints into the direction there is a flaw in the IDE code (my guess is a misplaced bracket)

You can start ruling out some things by temporarily re-assigning the pins, to where both motors would respond to the same fraction of code, switch left and right motor, etc, just as a test.

In order to give a better advice, we would need your IDE code that you are using.

ย 

Mac

ย 

P.S. I just noticed The Dronebot Workshop (Bill) actually did a full youtube video on this robot, with the speed sensors:

In case you haven't yet, check out that video and the related website article that has all the details and code.

Hi Macoofer and Robotbuilder.

thanks for replying.

I will check the code and will make some try also, with both motors. I will watch again that video, but if i remember well, i did not found an answer there.

As soon as possible i will pubblish my sketch and the original project, where there is something still i dont understand about powering ENB pin after removing the jumper, even if powering is supplied at input vcc of motor shield.

thanks for now


   
ReplyQuote
(@hegom)
Member
Joined: 4 years ago
Posts: 5
Topic starter  

hi all,

iam back.

made some test.

When this morning, i edited the last TEST1ย  sketch (included in this post) and put on arduino, servo was moving, but not the right motor.

Then i tried to remove the second wire attached on ENB pin (without shutter), the one going in +5 on the sensoe shield) , but i saw that motor shield was without power.

Once i connected it again , servo had a move then was still forever, no matter what i tried. Right motor was still.

So i tried with just few lines of code , with servo library ONLY , to test servo, and it works perfectly.

Again, when i upload the TEST1 sketch, Servo doesnt move, nor the right motor.

Everything else looks like to works , as i can read the speed of left motor on serial monitor, and i see the flow going on by some serial print i put to check.

I am afraid there is some mysterious corrispondance between interrupts, libraries , motor shield and servo.

Iam still not understanding what it could be.....

ย 

ย 


   
ReplyQuote