piadcs

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 3 Imported by: 0

README

PiADCs

Libraries in Go to interface TI ADCs with Raspberry Pi. Currently only the ADS126x is supported but other ADCs with similar programming could also be added. The ADS1262 precision ADC makes for a cheap but very powerful Data aquisition system when paired with a Raspberry Pi.

How to set up and install

  1. Set up your Raspberry Pi with the Raspberry Pi OS (https://www.raspberrypi.org/software/) and connect it to the ADC. For an example of how to connect them with minimal noise for the highest precision measurments see the hookup example given in the schematics folder.

  2. Make sure you have Go installed on your Raspberry Pi (Version 1.16 or higher) - https://golang.org/doc/install

  3. Use the go get command

go get -u github.com/AnnaKnapp/piadcs

How to use

Import the main library and the subfolder with the library for the adc you want to use (at this time on the ads126x is supported)

import(
	"github.com/AnnaKnapp/piadcs"
	adc "github.com/AnnaKnapp/piadcs/ads126x"
)

Please check out the examples folder for usage examples. These examples are intended to run on a Raspberry Pi running Raspberry Pi OS and assume the connections shown in the schematics folder. The testing was done using a ProtoCentral ADS126x breakout board and a Raspberry Pi 4 B (other Pi models should also work).

Documentation

https://pkg.go.dev/github.com/AnnaKnapp/piadcs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFromConsecutiveRegisters

func ReadFromConsecutiveRegisters(connection spi.Conn, startingreg byte, numbertoread byte) []byte

Use this function to check what data is stored at what registers. The starting register and the number of registers to read must be specified.

func RegisterMatch

func RegisterMatch(a, b []byte) bool

checks if the data returned from a register read matches the data that was initially sent - use this to ensure you properly set your registers

func WriteToConsecutiveRegisters

func WriteToConsecutiveRegisters(connection spi.Conn, startingreg byte, datatowrite []byte)

This writes data to consecutive registers. You need to specify the starting register and the byte slice of data to write. It will go down the slice and write one byte to each consecutive register starting from the one specified. Please see the datasheet for more information. The WREG opcode is used here and uses the same programming on multiple different TI ADCs

Types

type Register

type Register struct {
	Name    string
	Address byte

	Defaultvalue byte

	//use the function Setregister with values from the constants file or you can also set this manually by looking at the datasheet.
	Setvalue byte
}

func NewRegister

func NewRegister(name string, address byte) Register

Use this to create a register to then set using the setregister function

func (*Register) Setregister

func (reg *Register) Setregister(settings []byte)

This function sets the register data byte according to the settings specified. PLEASE make sure to list either ALL settings for a given register OR the default value. For examp if you want to change the POWER register on the ADS126x to enable vbias, make sure to also include the setting for the internal reference which is also controlled by that register. This will ensure that the registers are set exactly as you intended. The lists of all possible settings for registers are listed in the constants file for that device.

Directories

Path Synopsis
To test out this library with this product - https://www.waveshare.com/18983.htm - It works but is not ideal for precision measurement for many reasons - Primarily that the ADC is powered from the Raspberry Pi which adds a huge source of noise.
To test out this library with this product - https://www.waveshare.com/18983.htm - It works but is not ideal for precision measurement for many reasons - Primarily that the ADC is powered from the Raspberry Pi which adds a huge source of noise.
Package supports use of Texas Insturments ADS1262 and ADS1263 32-bit analog to digital converters
Package supports use of Texas Insturments ADS1262 and ADS1263 32-bit analog to digital converters

Jump to

Keyboard shortcuts

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