Is it possible to control a servo past 180°?

Hi all,

I am looking to move this servo from 0-270°: http://www.dfrobot.com/index.php?route=product/product&path=156_51_108&product_id=1177

Using the example code found in the developer docs I can not get it to move past 180° Would this be an error with my set frequency and/or duty cycle? My code is the 95% thesame as the example code. I changed the period to .02 and the MIN to .01. It looks like this:

`const SERVO_MIN = 0.01 //duty cycle .03 is default
const SERVO_MAX = 0.1

servo <- hardware.pin7
servo.configure(PWM_OUT, 0.02, SERVO_MIN)

server.log("Device Online!");

// expects a value between 0.0 and 1.0
function setServo(value) {
    local scaledValue = value * (SERVO_MAX - SERVO_MIN) + SERVO_MIN
    server.log(scaledValue)

    servo.write(scaledValue)
}

function sweep() {
    // Write the current position
    local position = 0.0
    
    for (local i = 0; i < 10; i++) {
      setServo(position)
      position = position + 0.1
      imp.sleep(1.0)
    }
    
}`

Thank you

Have you tried to move the servo max up?

Yep, I moved it past .1 and it stops writing to the servo.

The 20ms period is pretty standard (50Hz). The page you linked to shows this is acceptable.

The pulse range is 500-2500us (0.5 - 2.5ms).

SERVO_MAX = 0.120ms = 2ms. This should be 0.125 to get 2500us max.
SERVO_MIN = 0.01
20ms = 0.2ms. This should be 0.025 to get 500us min.

Try those?

Thanks for the reply Hugo. I tried similar numbers to that (I believe .12 and .02 for SERVO_MAX and SERVO_MIN respectively) and weirdly enough sending anything over .8 to setServo(pos) would not write, BUT writing .8 did take it to 270 degrees.

The solution I came up with was to set

`const SERVO_MIN = 0.00
const SERVO_MAX = 0.12`

To go to 0 degrees I can call setServo(0.0) and to go to 270 degrees I can call setServo(0.8). It’s a bit hacky but for the intended project it works.

And to confirm what you wrote Hugo that indeed move the servo properly from 0-270 degrees. Thank you very much.