Documentation
¶
Overview ¶
Package ti contains drivers for IC's produces by Texas Instruments.
Package ti contains drivers for IC's produced by Texas Instruments.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADS1100 ¶
type ADS1100 struct {
// contains filtered or unexported fields
}
ADS1100 is a 16-bit ADC. It's PGA can be set to 1, 2, 4 or 8. Allowed values for the data rate are 8, 16, 32 or 128 SPS.
Example ¶
d, err := i2c.Open(&i2c.Devfs{ Dev: "/dev/i2c-0", }, 0x1c) if err != nil { panic(fmt.Sprintf("failed to open device: %v", err)) } defer d.Close() // 4.048 is Vref, 16 is the data rate and the PGA is set to 1. adc, err := NewADS1100(d, 4.048, 16, 1) if err != nil { panic(fmt.Sprintf("failed to create ADS1100: %v", err)) } // Retrieve voltage of channel 1... v, err := adc.Voltage(1) if err != nil { panic(fmt.Sprintf("failed to read channel 1 of ADS1100: %s", err)) } // ...read the raw value of channel 1. PGA has not been applied. c, err := adc.OutputCode(1) if err != nil { panic(fmt.Sprintf("failed to read channel 1 of ADS1100: %s", err)) } fmt.Printf("channel 1 reads %f or digital output code %d", v, c)
Output:
func NewADS1100 ¶
NewADS1100 returns an ADS1100.
func (*ADS1100) DataRate ¶
DataRate reads the config register of the ADC returns the current value of the data rate.
func (ADS1100) OutputCode ¶
OutputCode queries the channel and returns its digital output code. The maximum code depends on the selected data rate. The higher the data rate, the lower the number of bits used.
func (*ADS1100) SetDataRate ¶
SetDataRate writes the value for the data rate to the ADC.
type ADS1110 ¶
type ADS1110 struct {
// contains filtered or unexported fields
}
ADS1110 is a 16-bits ADC. It's PGA can be set to 1, 2, 4 or 8. Allowed values are 15, 30, 60 or 240 SPS. The ADS1110 always uses an internal voltage reference of 2.048V.
func NewADS1110 ¶
NewADS1110 returns an ADS1110.
func (*ADS1110) DataRate ¶
DataRate reads the config register of the ADC returns the current value of the data rate.
func (ADS1110) OutputCode ¶
OutputCode queries the channel and returns its digital output code. The maximum code depends on the selected data rate. The higher the data rate, the lower the number of bits used.
func (*ADS1110) SetDataRate ¶
SetDataRate writes the value for the data rate to the ADC.
type DAC5578 ¶
type DAC5578 struct {
// contains filtered or unexported fields
}
DAC5578 is a 8 channel DAC with a resolution of 8 bits. The datasheet is here: http://www.ti.com/lit/ds/symlink/dac5578.pdf
Example ¶
// We are going to write 5.5 volt to channel 0. volts := 5.5 channel := 0 dev, err := i2c.Open(&i2c.Devfs{ Dev: "/dev/i2c-0", }, 0x48) if err != nil { panic(fmt.Sprintf("failed to open device: %v", err)) } defer dev.Close() // Create the DAC. The reference voltage is set to 10V. dac := NewDAC5578(dev, 10) // Write volts to the channel. err = dac.SetVoltage(volts, channel) if err != nil { panic(fmt.Sprintf("failed to set voltage: %v", err)) } // It's also possible to set output of a channel with digital output // code. The value must be between 0 and 255. if err := dac.SetInputCode(255, channel); err != nil { panic(fmt.Sprintf("failed to set voltage using output code: %v", err)) }
Output:
func NewDAC5578 ¶
NewDAC5578 returns a new instance of DAC5578.
func NewDAC6578 ¶
NewDAC6578 returns a new instance of DAC5578.
func NewDAC7578 ¶
NewDAC7578 returns a new instance of DAC5578.
func (*DAC5578) SetInputCode ¶
SetInputCode writes the digital input code to the DAC
func (*DAC5578) SetVoltage ¶
SetVoltage set output voltage of channel. Using the Vref the input code is calculated and then SetInputCode is called.
type DAC6578 ¶
type DAC6578 struct {
// contains filtered or unexported fields
}
DAC6578 is a 8 channel DAC with a resolution of 10 bits. The datasheet is here: http://www.ti.com/lit/ds/symlink/dac6578.pdf
func (*DAC6578) SetInputCode ¶
SetInputCode writes the digital input code to the DAC
func (*DAC6578) SetVoltage ¶
SetVoltage set output voltage of channel. Using the Vref the input code is calculated and then SetInputCode is called.
type DAC7578 ¶
type DAC7578 struct {
// contains filtered or unexported fields
}
DAC7578 is a 8 channel DAC with a resolution of 10 bits. The datasheet is here: http://www.ti.com/lit/ds/symlink/dac7578.pdf
func (*DAC7578) SetInputCode ¶
SetInputCode writes the digital input code to the DAC
func (*DAC7578) SetVoltage ¶
SetVoltage set output voltage of channel. Using the Vref the input code is calculated and then SetInputCode is called.