Page 1 of 1

Servo won't take negitive angles

Posted: Mon Mar 22, 2021 1:20 am
by OutoftheBOTS_
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
>>>

Re: Servo won't take negitive angles

Posted: Mon Mar 22, 2021 6:24 pm
by pythoncoder
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.

Re: Servo won't take negitive angles

Posted: Fri Mar 26, 2021 7:46 am
by OutoftheBOTS_
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

Re: Servo won't take negitive angles

Posted: Fri Mar 26, 2021 8:15 am
by pythoncoder
I can't help with Windows, I'm afraid. I ditched it for Linux when XP came out. Hopefully someone else can advise.

Re: Servo won't take negitive angles

Posted: Sun Apr 25, 2021 2:32 pm
by grodstein
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

Re: Servo won't take negitive angles

Posted: Tue Apr 27, 2021 1:04 pm
by grodstein
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