Anybody with confli...
 
Notifications
Clear all

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

  RSS

HEGOM
(@hegom)
Active Member
Joined: 7 months ago
Posts: 7
2020-05-15 3:48 pm  

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)
Eminent Member
Joined: 7 months ago
Posts: 28
2020-05-15 6:49 pm  

@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
(@hegom)
Active Member
Joined: 7 months ago
Posts: 7
2020-05-16 2:11 am  

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 7 months ago by HEGOM

ReplyQuote
Macoofer
(@macoofer)
Eminent Member
Joined: 7 months ago
Posts: 28
2020-05-16 8:46 am  

@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)
Honorable Member
Joined: 1 year ago
Posts: 527
2020-05-16 9:47 am  

@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.

 

This post was modified 7 months ago by robotBuilder

ReplyQuote
HEGOM
(@hegom)
Active Member
Joined: 7 months ago
Posts: 7
2020-05-17 12:04 am  
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
(@hegom)
Active Member
Joined: 7 months ago
Posts: 7
2020-05-17 3:16 pm  

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