Controlling hobby servos

I think it would make a lot of sense to have the ability to control hobby servos with the GPIO pins of the OpenMV. However, I took a look at the pyb.Servo library in the documentation, and I can see that all the pin names are from PyBoard – there are no X1, X2, X3 or X4 pins on the OpenMV. Is that a problem with the documentation not being updated, or is that library actually not functional on OpenMV? I know I can generate the right PWM signal using timers, but it would be much more convenient to use the library.

I need to update the docs on that. But, I’ve tested doing Pan and Tilt and that works. The servo control is just like you see in with the pyb module.

Hi,

I am trying to get a servo to work but I just don’t get it to work trough the ide v1.1 in Ubuntu and Windows.

It just crashes when I try to use the sample code:

s1 = pyb.Servo(1) # create a servo object on position X1
s2 = pyb.Servo(2) # create a servo object on position X2

s1.angle(45) # move servo 1 to 45 degrees
s2.angle(0) # move servo 2 to 0 degrees

move servo1 and servo2 synchronously, taking 1500ms

s1.angle(-60, 1500)
s2.angle(30, 1500)

or

from pyb import Servo

s1 = Servo(1) # servo on position 1 (PB15, VIN, GND)
s1.angle(45) # move to 45 degrees
s1.angle(-60, 1500) # move to -60 degrees in 1500ms
s1.speed(50) # for continuous rotation servos

What could be the reason of this, when I try to update the unit to v1.2 nothing happens under windows.

Thanks for any response and help :slight_smile:

Hi, have you installed the dev environment? Home · openmv/openmv Wiki · GitHub

Without it you can’t get all the fixes we’ve been releasing.

Anyway, Ibrahim just released a new windows version right now: Releases · openmv/openmv · GitHub

Version 1.1 is no good. Lots of fixes since then.

When you’ve updated the firmware let me know if the servos working better then. If not, we can release a custom firmware image.

For updating the firmware on windows see this guide: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwi_0Lux083LAhXG4SYKHUcgB9oQFggwMAM&url=http%3A%2F%2Fmicropython.org%2Fresources%2FMicro-Python-Windows-setup.pdf&usg=AFQjCNGrjBRxBE38PeOja-iobNfnz09MWA&sig2=wAZodXV62zic_BIxnr2eVw&bvm=bv.117218890,d.eWE

Put the board into DFU mode, then upload the OpenMV Cam 2 firmware that ships with the GUI.

If you’re on Linux the firmware update in the GUI will work without needing the separate DFU app.

Thanks for the quick response, I will try both routes!

I will come back to you when I am finished :slight_smile:

So I started with updating openmv.

I had a lot a trouble updating openmv, I tried the following to update:

  • Via windows 10, Openmv-ide 1.2 failed
  • Via windows 10, Openmv-ide 1.1 failed
  • Via windows 7, Openmv-ide 1.2 failed
  • Via windows 7, Openmv-ide 1.1 failed
  • Via Vbox, Ubuntu 12 64bit Openmv-ide 1.2 failed
  • Via Vbox, Ubuntu 12 64bit Openmv-ide develop version failed
  • Via Vbox, Ubuntu 14 64bit Openmv-ide 1.2 failed
  • Via Vbox, Ubuntu 14 64bit Openmv-ide develop version failed
  • Via Vbox, Ubuntu 15 64bit Openmv-ide 1.2 failed
  • Via Vbox, Ubuntu 15 64bit Openmv-ide develop version failed
  • Via Ubuntu 14 on desktop, Openmv-ide developer version succesfull

Openmv-ide 1.2 ubuntu standalone doesn’t work for any editions above because glibc 2.21 is used instead 2.23 (even tried a unstable vesions).

So now I am using the Openmv-ide 1.2 on windows 10 but the servo still doesnt work.
If i try this code it runs and the ide doesnt crash but my servo still doesnt respond, see the sample code below:

from pyb import Servo
s1 = Servo(1) # servo on position 1 (PB15, VIN, GND)
s1.angle(45) # move to 45 degrees
s1.angle(-60, 1500) # move to -60 degrees in 1500ms

So for the signal I tried pin pb15,14,13 and pd13,12.
I use for juice vin and gnd on the board.

Hope you can help me!

Hi,

The servo outputs are PD12/PD13, or pin P7/P8. Servo1 is P7 and Servo2 is P8.

The VIN pin doesn’t output voltage. Its in input.

About the IDE crashes. What’s the exact issue? Did the IDE not start? We’ll have to fix that then. On Windows the firmware update does not work. You have to put the board into DFU mode and then use a separate tool.

This code:

from pyb import Servo
s1 = Servo(1) # servo on position 1 (PB15, VIN, GND)
s1.angle(45) # move to 45 degrees
s1.angle(-60, 1500) # move to -60 degrees in 1500ms

Will drive a Servo output on PD12 (P7).

I just tested it out and it seems to be working.

The servo works, I am not sure if the output of v3.3 in vout is enough but I can use a external power source for 5v :slight_smile:

Thank you for the quick responses, I can say that the new firmware works like a charm.

Kind regards,
Roy

We’ll have examples and stuff done too as soon as we can. We plan to make the example folder folder Arduino like with examples for everything. Until then, the best way to see the API is to look at these files:

https://github.com/openmv/openmv/tree/master/src/omv/py

The py_*.c files have all the function wrappers in them. Pretty straight forwards to figure our arguments.

The pyb module is from MicroPython so that’s already online and documented.

Can you check the Github link above please?