MotorShiel + virtualWire + servoTimer2

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
MadProf
 
Posts: 4
Joined: Fri Jul 02, 2010 8:08 am

MotorShiel + virtualWire + servoTimer2

Post by MadProf »

Hello,
I'm a beginner in Arduino and electronic.
I'm using the motorshield for my little rover. It work well alone. Then if use it with RF315mhz and virtualWire, it work fine too, i can transmit order to turn left, right, backward, forward... But if I include servoTimer2.h (servo.h can't be use with virtualWire.h cause they both use timer1) motor 2 doesn't run anymore. Motor 3 and 4 work but not 2. Servo is on the pin 9.
Do you know what is the problem ? why only motor 2 doesn't works ?

Thx,

MadProf

PS: sry for my english

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: MotorShiel + virtualWire + servoTimer2

Post by adafruit_support_bill »

I'm not familiar with ServoTimer2, but I would suspect there is a timer conflict between that and the AFMotor library. AFMotor uses timers for the PWM. It uses a different timer for motors 1&2 vs. 3&4.

MadProf
 
Posts: 4
Joined: Fri Jul 02, 2010 8:08 am

Re: MotorShiel + virtualWire + servoTimer2

Post by MadProf »

Thx for your reply arduwino,
It confirm what I thought, but I absolutely don't know how to use AFMotor + virtualWire + a servo's library. Is it possible to change the timer for the lib servoTimer2 ? Is there a third timer ?
ServoTimer2 thread
I'm sorry if I ask dumb questions...

MadProf

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: MotorShiel + virtualWire + servoTimer2

Post by adafruit_support_bill »

There are only three hardware timers on the Duemilanove. It would probably take some tricky coding to get all three libraries to work together.

The Mega has 4 timers. You might have better luck with that.

MadProf
 
Posts: 4
Joined: Fri Jul 02, 2010 8:08 am

Re: MotorShiel + virtualWire + servoTimer2

Post by MadProf »

Thx for your response.
Do you think the 3rd timer is in use or I can use it without facing problems ?
I have 2 arduino, some shields, so I don't want to buy an other board.

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: MotorShiel + virtualWire + servoTimer2

Post by adafruit_support_bill »

It looks like the servoTimer2 and the VirtualWire each use one timer. AFMotor uses two.

From the source code, AFMotor is using timer0 and timer2. You said that VirtualWire is using timer1. I would guess that servoTimer2 is also using timer2. It might be possible to hack two of the libraries to share a timer, but that is not likely to be a trivial task.

Other possibilities:

If you don't need bidirectional control on all of your motors, you could use a simple transister controller for one of them.
You could use a serial motor controller like one of the ones from Pololu. http://www.pololu.com/

MadProf
 
Posts: 4
Joined: Fri Jul 02, 2010 8:08 am

Re: MotorShiel + virtualWire + servoTimer2

Post by MadProf »

Unfortunately I need bidirectional for both motors...
I will look for a arduino mega if it's the only solution. I'm not capable of hack the library.

Thx for your help.

MadProf

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”