ads1115

package module
v0.0.0-...-6833c30 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: BSD-2-Clause Imports: 6 Imported by: 3

README

ads1115

golang ads1115 library

Documentation

Index

Constants

View Source
const (

	// Configuration Register MSB[7] OS field
	OsField                     = 7
	OsWNoEffect              OS = 0b0 // W
	OsWStartSingleConversion OS = 0b1 // W / reset
	OsRPerformingConversion  OS = 0b0 // R
	OsRConversionReady       OS = 0b1 // R

	// Configuration Register MSB[6:4] MUX field
	MuxField Mux = 4
	MuxA0A1  Mux = 0b000 //reset
	MuxA0A3  Mux = 0b001
	MuxA1A3  Mux = 0b010
	MuxA2A3  Mux = 0b011
	MuxA0GND Mux = 0b100
	MuxA1GND Mux = 0b101
	MuxA2GND Mux = 0b110
	MuxA3GND Mux = 0b111

	// Configuration Register MSB[3:1] PGA (Gain field)
	PGAField         = 1
	PGA6144      PGA = 0b000
	PGA6144Scale     = 187.5 / 1000000
	PGA4096      PGA = 0b001
	PGA4096Scale     = 125 / 1000000
	PGA2048      PGA = 0b010 //reset
	PGA2048Scale     = 62.5 / 1000000
	PGA1024      PGA = 0b011
	PGA1024Scale     = 31.25 / 1000000
	PGA512       PGA = 0b100
	PGA512Scale      = 15.625 / 1000000
	PGA256       PGA = 0b101
	PGA256Scale      = 7.8125 / 1000000

	// Configuration Register MSB[0] Mode
	ModeField           = 0
	ModeContinuous Mode = 0
	ModeSingle     Mode = 1 //reset

	// Configuration Register LSB[7:5] Data Rate
	DRField    = 5
	SPS8    DR = 0b000
	SPS16   DR = 0b001
	SPS32   DR = 0b010
	SPS64   DR = 0b011
	SPS128  DR = 0b100 //reset
	SPS250  DR = 0b101
	SPS475  DR = 0b110
	SPS860  DR = 0b111

	// Configuration Register LSB[4] Comp Mode
	CMField               = 4
	CMTraditional      CM = 0b0 //reset
	CMWindowComparator CM = 0b1

	// Configuration Register LSB[3] Comp polarity
	CPField         = 3
	CPActiveLow  CP = 0b0 //reset
	CPActiveHigh CP = 0b1

	// Configuration Register LSB[2] Latching comparator
	LCField    = 2
	LCNon   LC = 0b0 //reset
	LCYes   LC = 0b1

	// Configuration Register LSB[1:0] Comparator queue
	QField         = 0
	QOne     Queue = 0b00
	QTwo     Queue = 0b01
	QFour    Queue = 0b10
	QDisable Queue = 0b11 //reset
)

Variables

This section is empty.

Functions

func Init

func Init(device string, add int, module *Ads1115) error

Init function initialize MCP28003 after boot or restart of device

func ReadAnalog

func ReadAnalog(module *Ads1115, input string) float64

ReadAnalog function read conversion register en return result in volt

func ReadConversionRegister

func ReadConversionRegister(module *Ads1115, input string) float64

ReadConversionRegister function is deprecated en is replaced by ReadAnalog function

Types

type Ads1115

type Ads1115 struct {
	Device      *i2c.Dev
	Name        string `json:"name"`
	Address     int    `json:"address"`
	Description string `json:"description"`
}

func New

func New(device string, name string, address int, description string) (Ads1115, error)

type CM

type CM byte

type CP

type CP byte

type Configuration

type Configuration struct {
	OS                 OS    `json:"os"`
	Mux                Mux   `json:"mux"`
	PGA                PGA   `json:"pga"`
	Mode               Mode  `json:"mode"`
	DataRate           DR    `json:"dr"`
	ComparatorMode     CM    `json:"cm"`
	ComparatorPolarity CP    `json:"cp"`
	LatchingComparator LC    `json:"lc"`
	ComparatorQueue    Queue `json:"queue"`
}

type DR

type DR byte

type LC

type LC byte

type Mode

type Mode byte

type Mux

type Mux byte

type OS

type OS byte

type PGA

type PGA byte

type Queue

type Queue byte

Jump to

Keyboard shortcuts

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