Servo Shield

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.

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 (http://forums.openmv.io/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?

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.

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?

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.

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?

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:

Or better you could make your own shield with a USB connector and PWM output for the servo :slight_smile: 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:

But these will also work:

If you don’t know where to start, you could re-use one of our shields:
https://github.com/openmv/openmv/tree/master/eagle/openmv2/shields

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/micro-and-mini-servos/analog-micro-and-mini-servos/hs-82mg-standard-metal-gear-micro-servo/product


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.

Just make sure to apply 5v on the VIN connector. Or, alternatively, supply 5v to one of the connectors on the servo shield.

Are the connections below correct to control one(1) servo using the M7 board with the WiFi shield only?

Yes!

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/micro-and-mini-servos/analog-micro-and-mini-servos/hs-85mg-premium-metal-gear-micro-servo/product

from pyb import Servo
servo = Servo(3) # P9
servo.pulse_width(1800)
time.sleep(10)
servo.pulse_width(1200)

Yeah, that’s the right connection. Mmm, Ibrahim might be able to test this for you right now.

Hi,

This works with r2.5

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)

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.