public abstract class MCP3x0xGpioProvider extends AdcGpioProviderBase implements GpioProvider
This GPIO provider implements the base functionality for the MCP3004 & MCP3008 & MCP3204 & MCP3208 SPI ADC as native Pi4J GPIO pins. It is a 10-bit ADC providing between 4 and 8 input channels. More information about the ADC chip can be found here: http://ww1.microchip.com/downloads/en/DeviceDoc/21295d.pdf
The MCP3x0x family is connected via SPI connection to the Raspberry Pi and provides 4/8 GPIO pins that can be used for analog input pins. The values returned are in the range from 0 to the highest number (e.g. 1023 or 4095) depending on the ADC resolution. Note: This implementation currently only supports single-ended inputs.
| Modifier and Type | Field and Description |
|---|---|
int |
MAX_VALUE |
int |
MIN_VALUE |
int |
RESOLUTION |
allPins, conversionDelay, monitor, monitorInterval, thresholdcache, DEFAULT_CACHE_SIZE, isshutdown, listenersDEFAULT_MONITOR_INTERVAL, DEFAULT_THRESHOLD, INVALID_VALUE, MIN_MONITOR_INTERVAL| Constructor and Description |
|---|
MCP3x0xGpioProvider(Pin[] pins,
SpiChannel channel,
int speed,
int resolution,
SpiMode mode)
Create new instance of this MCP3x0x provider.
|
| Modifier and Type | Method and Description |
|---|---|
double |
getImmediateValue(Pin pin)
This method will perform an immediate data acquisition directly to the ADC chip to get the requested pin's input
conversion value.
|
double |
getMaxSupportedValue()
Get the maximum supported analog value for the ADC implementation.
|
double |
getMinSupportedValue()
Get the minimum supported analog value for the ADC implementation.
|
getEventThreshold, getEventThreshold, getImmediateValue, getMonitorEnabled, getMonitorInterval, getPercentValue, getPercentValue, getValue, setEventThreshold, setEventThreshold, setMonitorEnabled, setMonitorInterval, shutdownaddListener, dispatchPinAnalogValueChangeEvent, dispatchPinDigitalStateChangeEvent, export, export, getMode, getName, getPinCache, getPullResistance, getPwm, getState, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, unexportclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, export, export, getMode, getName, getPullResistance, getPwm, getState, getValue, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, shutdown, unexportpublic final int MAX_VALUE
public final int MIN_VALUE
public final int RESOLUTION
public MCP3x0xGpioProvider(Pin[] pins, SpiChannel channel, int speed, int resolution, SpiMode mode) throws IOException
pins - the collection of all GPIO pins used with this ADC provider implementationchannel - spi channel the MCP3x0x is connected tospeed - spi speed to communicate with MCP3x0xmode - spi mode to communicate with MCP3x0xIOException - if an error occurs during initialization of the SpiDevicepublic double getImmediateValue(Pin pin) throws IOException
getImmediateValue in interface AdcGpioProvidergetImmediateValue in class AdcGpioProviderBasepin - requested input pin to acquire conversion valueIOExceptionpublic double getMinSupportedValue()
getMinSupportedValue in interface AdcGpioProviderpublic double getMaxSupportedValue()
getMaxSupportedValue in interface AdcGpioProviderCopyright © 2012–2018 Pi4J. All rights reserved.