10000 GitHub - qcasey/drok: Simple lib for UART on a variety of DROK Buck / Boost power supplies.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

qcasey/drok

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

drok

GoDoc Go Report Card

A simple lib for interfacing with a variety of DROK Buck / Boost power supplies.

Thanks to Ben James for the supplementary writeup

Usage

Open a serial port @4800 baud and pass to the desired functions.

package examples

import (
    "fmt"

    drok "github.com/qcasey/drok"
    "github.com/tarm/serial"
)

func main() {
    c := &serial.Config{Name: "/dev/ttyUSB0", Baud: 4800}
    drokDevice, err := serial.OpenPort(c)
    if err != nil {
        panic("Failed to open serial port")
    }

    // Read output
    isOn, err := drok.IsOn(drokDevice)
    if err != nil {
        panic(err.Error())

595D
    }
    if isOn {
        fmt.Println("DROK power supply is turned on")
    } else {
        fmt.Println("DROK power supply is turned off")
    }

    // Read output voltage
    voltage, err := drok.ReadVoltage(drokDevice)
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("Output voltage limit set to: %f\n", voltage)

    // Read output current
    current, err := drok.ReadCurrent(drokDevice)
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("Total output current is: %f\n", current)

    // Set output to true (enabling power output)
    err = drok.SetOutput(drokDevice, true)
    if err != nil {
        panic(err.Error())
    }

    // Set output voltage to 12.3v
    err = drok.SetVoltage(drokDevice, 12.3)
    if err != nil {
        panic(err.Error())
    }

    // Set output current limit to 0.95A
    err = drok.SetCurrent(drokDevice, 0.95)
    if err != nil {
        panic(err.Error())
    }

}

About

Simple lib for UART on a variety of DROK Buck / Boost power supplies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0