fs90r

package module
v0.0.0-...-1c175a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 2 Imported by: 0

README

FS90R servo

Go Reference golangci-lint Go Report Card

This drivers allows to control a FS90R servo connected on a PWM GPIO pin

Documentation

For full documentation, please visit Go Reference

Quick start

import (
	"os"

	"github.com/raspberrypi-go-drivers/fs90r"
	"github.com/stianeikeland/go-rpio/v4"
)

func main() {
	err := rpio.Open()
	if err != nil {
		os.Exit(1)
	}
	defer rpio.Close()
	servo := fs90r.NewFS90R(18)
	servo.SetSpeed(50) // Set servo speed to 50% (CCW)
}

Raspberry Pi compatibility

This driver has has only been tested on an Raspberry Pi Zero WH using integrated bluetooth but may work well on other Raspberry Pi having integrated Bluetooth

License

MIT License


Special thanks to @stianeikeland

This driver is based on his work in stianeikeland/go-rpio

Documentation

Overview

Package fs90r allows to control a FS90R servo connected on a PWM GPIO pin

Example (Ccw)
err := rpio.Open()
if err != nil {
	os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(50) // Set servo speed to 50% (CCW)
Example (Cw)
err := rpio.Open()
if err != nil {
	os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(-50) // Set servo speed to 50% (CW)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS90R

type FS90R struct {
	// contains filtered or unexported fields
}

FS90R instance

func NewFS90R

func NewFS90R(pinID uint8) *FS90R

NewFS90R creates a new FS90R instance

The pinID specified must be a PWM compatible pin

Example
err := rpio.Open()
if err != nil {
	os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(100) // Set servo speed to 100% (CCW)

func (*FS90R) SetBalancePoint

func (fs90r *FS90R) SetBalancePoint(balancePoint float64)

SetBalancePoint set the balance point (pulse duration) at which the servo will stay still. The balance point is in milliseconds and is 1.5 by default

You can use this method if the servo is moving at default position (0% speed) but it's better to adjust this value by using the small screw under the FS90R

You can check servos PWM behavior for more details https://www.pololu.com/blog/17/servo-control-interface-in-detail

Example
err := rpio.Open()
if err != nil {
	os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(0) // if the servo is moving with this setup you can use SetBalancePoint
servo.SetBalancePoint(1.6)
// if the value used in SetBalancePoint is correct, the servo should now stay still

func (*FS90R) SetSpeed

func (fs90r *FS90R) SetSpeed(speedPct int8)

SetSpeed set the speed using percentage, from -100 to 100

Positive value is clockwise, negative CCW

Example
err := rpio.Open()
if err != nil {
	os.Exit(1)
}
defer rpio.Close()
servo := fs90r.NewFS90R(18)
servo.SetSpeed(-25) // Set servo speed to 25% (CW)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL