Servo won't take negitive angles

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Servo won't take negitive angles

Post by OutoftheBOTS_ » Mon Mar 22, 2021 1:20 am

I am using a PYB1.1 with firmware 1.12v (I know it isn't the latest but seem not to be able to update it)

I am trying out the servo class and it seems to be working when I give positive angles between 0 and 90 but it won't let me give it negative angles.

see below for debug
MicroPython v1.12-557-g3a9d94803 on 2020-06-22; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> from pyb import Servo
>>>
>>> s1 = Servo(1) # servo on position 1 (X1, VIN, GND)
>>> s1.calibration() #read calibration
(640, 2420, 1500, 2470, 2200)
>>> s1.angle(0) # move to 0 degrees
>>> s1.pulse_width() #read pulse width
1500
>>> s1.angle(-45) #set to negitive 45
>>> s1.pulse_width() #read pulse width
1500
>>>

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Servo won't take negitive angles

Post by pythoncoder » Mon Mar 22, 2021 6:24 pm

With current firmware:

Code: Select all

>>> from pyb import Servo
>>> s = Servo(1)
>>> s.angle(80)
>>> s.angle()
79
>>> s.angle(-80)
>>> s.angle()
-79
>>> s.pulse_width()
640
>>> s.angle(0)
>>> s.pulse_width()
1500
>>> s.angle(90)
>>> s.pulse_width()
2420
>>> 
Why can you not update firmware? It is usually easily done.
Peter Hinch
Index to my micropython libraries.

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: Servo won't take negitive angles

Post by OutoftheBOTS_ » Fri Mar 26, 2021 7:46 am

pythoncoder wrote:
Mon Mar 22, 2021 6:24 pm
With current firmware:

Code: Select all

>>> from pyb import Servo
>>> s = Servo(1)
>>> s.angle(80)
>>> s.angle()
79
>>> s.angle(-80)
>>> s.angle()
-79
>>> s.pulse_width()
640
>>> s.angle(0)
>>> s.pulse_width()
1500
>>> s.angle(90)
>>> s.pulse_width()
2420
>>> 
Why can you not update firmware? It is usually easily done.
I am using a windows computer which always doesn't like to play nice with this sort of stuff. I am trying to flash the DFU file using DfuSe demo. I have successfully flashed micopython DFU files before to other boards. When I put the PYB in to boot loader mode the DfuSe demo detects it going into boot loader. When I try to flash Dfuse says it is writing but when I reboot the PYB it still has the old firmware

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Servo won't take negitive angles

Post by pythoncoder » Fri Mar 26, 2021 8:15 am

I can't help with Windows, I'm afraid. I ditched it for Linux when XP came out. Hopefully someone else can advise.
Peter Hinch
Index to my micropython libraries.

grodstein
Posts: 13
Joined: Tue Dec 01, 2020 6:23 pm

Re: Servo won't take negitive angles

Post by grodstein » Sun Apr 25, 2021 2:32 pm

For what it's worth, I'm having similar problems flashing new PyBoard firmware under Windows. If you ever figure out how to do it, please post your recipe. Have you had more luck with an ESP32? Maybe using a PyBoard under Windows was not the best idea.
/Joel

grodstein
Posts: 13
Joined: Tue Dec 01, 2020 6:23 pm

Re: Servo won't take negitive angles

Post by grodstein » Tue Apr 27, 2021 1:04 pm

One more observation on this thread. My own PyBoard is still at v1.12 on 2019-12-20. And its behavior is exactly as Peter describes. I cannot replicate the issue that OutOfTheBOTS describes.
Also, I threw a scope on the servo output pin (X1 for me) and the waveform timing agrees pretty much exactly with what Servo.pulse_width() says it should be.

/Joel

Post Reply