Servo Shield

General discussion about topics related to OpenMV.
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Servo Shield

Postby cagiva » Fri Aug 25, 2017 1:40 pm

Do I need the servo shield if I want to control just one hitec servo like the HS-85MG? Can I just connect it directly to pins one of the OpenMV board to control it with Servo.py script?
User avatar
iabdalkader
Posts: 624
Joined: Sun May 24, 2015 3:53 pm

Re: Servo Shield

Postby iabdalkader » Fri Aug 25, 2017 2:53 pm

cagiva wrote:
Fri Aug 25, 2017 1:40 pm
Do I need the servo shield if I want to control just one hitec servo like the HS-85MG? Can I just connect it directly to pins one of the OpenMV board to control it with Servo.py script?
No, you can control up to 3 servos directly with the M7 camera. If you need to control more servos, you'll need the servo shield.
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Mon Aug 28, 2017 12:39 pm

Hi Ibrahim,

Thanks for the clarification. For my project, I just need to control one servo remotely using a web browser, but I'll prefer not to use an additional board to control the servo via UART/I2C. However, I found this post (viewtopic.php?t=159#p769) where you indicate that the WiFi shield and servos cannot be used at the same time. Is that still the case with the M7 camera?
User avatar
kwagyeman
Posts: 2447
Joined: Sun May 24, 2015 2:10 pm

Re: Servo Shield

Postby kwagyeman » Mon Aug 28, 2017 1:38 pm

The M7 has one free pin when the WiFi shield is used for servos. Servo channel 3. Or P9. The M4 does not. Not that the I2C / uart serial pins are also free.
Nyamekye,
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Mon Aug 28, 2017 4:23 pm

kwagyeman wrote:
Mon Aug 28, 2017 1:38 pm
The M7 has one free pin when the WiFi shield is used for servos. Servo channel 3. Or P9.
Great, thanks Kwabena. One more question. Can I power the board and the servo via the USB connector using an external 5V 2A power bank?
User avatar
kwagyeman
Posts: 2447
Joined: Sun May 24, 2015 2:10 pm

Re: Servo Shield

Postby kwagyeman » Mon Aug 28, 2017 5:37 pm

No, you need to connect to the VIN connector. If you have some way to provide power over a service connector then you can use one of the servo channels for power.
Nyamekye,
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Mon Aug 28, 2017 7:04 pm

Sorry Kwabena, I'm not sure I follow. The servo has 3 wires, but are you saying that I need to connect the Vin and GND to an external power source and only use the servo signal wire to control it?
User avatar
iabdalkader
Posts: 624
Joined: Sun May 24, 2015 3:53 pm

Re: Servo Shield

Postby iabdalkader » Mon Aug 28, 2017 7:19 pm

The regulator can supply up to 500mA, so I think it's safe to power the cam and servo from USB power bank (connect the servo to the 3.3v output on the left header). If you want to power the servo from 5v, you'll have to use one of these to power the cam and servo from USB:

https://www.sparkfun.com/products/12035
https://www.sparkfun.com/products/9966
https://www.sparkfun.com/products/12700

Or better you could make your own shield with a USB connector and PWM output for the servo :) It would be best to design the shield with the stackable headers we use so you can connect it on the back or front sides:

https://www.sparkfun.com/products/9279

But these will also work:

https://www.sparkfun.com/products/11895

If you don't know where to start, you could re-use one of our shields:
https://github.com/openmv/openmv/tree/m ... v2/shields
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Mon Aug 28, 2017 8:32 pm

iabdalkader wrote:
Mon Aug 28, 2017 7:19 pm
The regulator can supply up to 500mA, so I think it's safe to power the cam and servo from USB power bank (connect the servo to the 3.3v output on the left header).
In my case, the servo requires an operating voltage range from 4.8V ~ 6.0V so this will not work for me.

http://hitecrcd.com/products/servos/mic ... vo/product

iabdalkader wrote:
Mon Aug 28, 2017 7:19 pm
Or better you could make your own shield with a USB connector and PWM output for the servo :) It would be best to design the shield with the stackable headers we use so you can connect it on the back or front sides
Instead of creating my own shield, can I just use your Servo shield with the WiFi shield to control one servo?
User avatar
iabdalkader
Posts: 624
Joined: Sun May 24, 2015 3:53 pm

Re: Servo Shield

Postby iabdalkader » Mon Aug 28, 2017 8:49 pm

cagiva wrote:
Mon Aug 28, 2017 8:32 pm
Instead of creating my own shield, can I just use your Servo shield with the WiFi shield to control one servo?
Yes, sure you can.
User avatar
kwagyeman
Posts: 2447
Joined: Sun May 24, 2015 2:10 pm

Re: Servo Shield

Postby kwagyeman » Mon Aug 28, 2017 10:07 pm

Just make sure to apply 5v on the VIN connector. Or, alternatively, supply 5v to one of the connectors on the servo shield.
Nyamekye,
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Tue Sep 19, 2017 9:58 pm

Are the connections below correct to control one(1) servo using the M7 board with the WiFi shield only?
OpenMV.jpg
OpenMV.jpg (86.19 KiB) Viewed 6731 times
User avatar
kwagyeman
Posts: 2447
Joined: Sun May 24, 2015 2:10 pm

Re: Servo Shield

Postby kwagyeman » Wed Sep 20, 2017 12:43 am

Yes!
Nyamekye,
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Wed Nov 01, 2017 12:54 am

The WiFi shield doesn't have P9 listed on it so should I connect the servo signal wire to the RST pin on the WiFi shield; which lines up with P9 on M7 board?

The 5V servo jumps a tiny bit when I power up the M7 board, but after that it doesn't respond to the pulse width I send (between 1000-2000us).

http://hitecrcd.com/products/servos/mic ... vo/product

Code: Select all

from pyb import Servo
servo = Servo(3) # P9
servo.pulse_width(1800)
time.sleep(10)
servo.pulse_width(1200)
User avatar
kwagyeman
Posts: 2447
Joined: Sun May 24, 2015 2:10 pm

Re: Servo Shield

Postby kwagyeman » Wed Nov 01, 2017 8:36 am

Yeah, that's the right connection. Mmm, Ibrahim might be able to test this for you right now.
Nyamekye,
User avatar
iabdalkader
Posts: 624
Joined: Sun May 24, 2015 3:53 pm

Re: Servo Shield

Postby iabdalkader » Wed Nov 01, 2017 12:25 pm

Hi,

This works with r2.5

Code: Select all

from pyb import Servo
import time
servo = Servo(3) # P9

while (True):
    servo.pulse_width(1200)
    time.sleep(100)
    servo.pulse_width(1800)
    time.sleep(100)
User avatar
cagiva
Posts: 78
Joined: Thu Jan 05, 2017 9:23 pm

Re: Servo Shield

Postby cagiva » Thu Nov 02, 2017 4:10 pm

Thanks Ibrahim. The sleep(10) in the original servo_control.py example was too short for my servo. Your snapshot code uses sleep(100) and with that value, it works. You might want to update the servo_control.py example. Anyway, thank you both, for looking into this.

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest