Documentation ¶
Overview ¶
Package microchip implements drivers for a few SPI controlled chips produced by Microchip.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MCP3004 ¶
type MCP3004 struct { Conn *spi.Device // Vref is the voltage on the reference input of the ADC. Vref float64 InputType adc.InputType }
MCP3004 is 10-bits ADC with 4 single-ended or 2 pseudo-differential inputs. Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21295C.pdf
func (MCP3004) OutputCode ¶
OutputCode queries the channel and returns its digital output code.
type MCP3008 ¶
type MCP3008 struct { Conn *spi.Device // Vref is the voltage on the reference input of the ADC. Vref float64 InputType adc.InputType }
MCP3008 is 10-bits ADC with 8 single-ended or 4 pseudo-differential inputs. Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21295C.pdf
Example ¶
conn, err := spi.Open(&spi.Devfs{ Dev: "/dev/spidev32766.0", Mode: spi.Mode0, MaxSpeed: 3600000, }) if err != nil { panic(fmt.Sprintf("failed to open SPI device: %s", err)) } defer conn.Close() a := MCP3008{ Conn: conn, Vref: 5.0, // Optional, default value is SingleEnded. InputType: adc.SingleEnded, } // Voltage the voltage on channel 3. v, err := a.Voltage(3) if err != nil { panic(fmt.Sprintf("failed to read channel 3 of MCP3008: %s", err)) } fmt.Printf("read %f Volts from channel 3", v)
Output:
func (MCP3008) OutputCode ¶
OutputCode queries the channel and returns its digital output code.
type MCP3204 ¶
type MCP3204 struct { Conn *spi.Device // Vref is the voltage on the reference input of the ADC. Vref float64 InputType adc.InputType }
MCP3204 is 12-bits ADC with 4 single-ended or 2 pseudo-differential inputs. Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21298e.pdf
func (MCP3204) OutputCode ¶
OutputCode queries the channel and returns its digital output code.
type MCP3208 ¶
type MCP3208 struct { Conn *spi.Device // Vref is the voltage on the reference input of the ADC. Vref float64 InputType adc.InputType }
MCP3208 is 12-bits ADC with 8 single-ended or 4 pseudo-differential inputs. Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21298e.pdf
func (MCP3208) OutputCode ¶
OutputCode queries the channel and returns its digital output code.