The analog functionality currently supported by the RPiSoC API
Class: | Provides functionality for use of the general purpose analog input pins exposed on the RPiSoC |
---|---|
Example: | Define an analogPin object in the following way: My_analog_pin = analogPin(PIN)
|
Method | __init__ |
---|---|
Description | Constructs and initializes an analogPin object for general purpose analog input |
Parameters | int PIN |
PIN |
|
Returns | No return |
Method | Read |
---|---|
Description | Reads the calculated digital value after analog to digital conversion |
Parameters | None |
Returns | int counts |
counts |
|
Method | ReadVolts |
---|---|
Description | Reads the specified analog pin and converts that digital reading to a voltage in Volts, or converts a given count value to Volts |
Optional Parameters |
|
PRECISION |
|
COUNTS |
|
Returns | float volts |
volts | The converted digital value into a representative analog voltage. |
Method | SetOffset |
---|---|
Description | Sets an offset on the ADC which is used for the voltage conversion. It will subtract the given offset before making the conversion |
Parameters | int counts |
counts |
|
Returns | No return |
Method | SetResolution |
---|---|
Description |
|
Parameters | int resolution |
resolution |
|
Returns | No return |
Class: | Provides functionality for use of CapSense buttons on the RPiSoC |
---|---|
Example: | Define a CapSense object in the following way: CapSense(0)
|
Method | __init__ |
---|---|
Description | Initializes a Capsense object for use as a touch sensor |
Parameters |
|
Optional Parameters |
|
PIN |
|
THRESHOLD |
|
Returns | No return |
Notes |
|
Method | Read |
---|---|
Description |
|
Parameters | None |
Returns | bool state |
state | A True or False value when the output is determined to be touched or not touched, respectively |
Method | Sleep |
---|---|
Description | Prepares the component for the device entering a low-power mode. Disables Active mode power template bits of the sub components used within CapSense, saves nonretention registers, and resets all sensors to an inactive state |
Parameters | None |
Returns | No return |
Side Effects | This will affect all CapSense sensors, use it only if this is your intention |
Method | Start |
---|---|
Description |
|
Parameters | None |
Returns | No return |
Method | Stop |
---|---|
Description | Disables component interrupts, and calls CapSense_ClearSensors() to reset all sensors to an inactive state |
Parameters | None |
Returns | No return |
Side Effects | This will affect all CapSense sensors, use it only if this is your intention |
Method | Wakeup |
---|---|
Description | Restores CapSense configuration and nonretention register values after the device wake from a low power mode sleep mode |
Parameters | None |
Returns | No return |
Side Effects | This will affect all CapSense sensors, use it only if this is your intention |
Method | isRunning |
---|---|
Description | Checks to see if the CapSense component and all subcomponents are currently operational |
Parameters | None |
Returns | bool __running |
__running | A private boolean variable which evaluates to True if CapSense is active, or False if it is not |
Method | isTouched |
---|---|
Description | Uses the calibrated baseline and provided threshold value to determine if the requested CapSense button is being touched. This is the suggested method for touch detection. |
Parameters | None |
Returns | bool state |
state | A True or False value when the output is determined to be touched or not touched, respectively |
Method | readRaw |
---|---|
Description |
|
Parameters | None |
Returns | int val |
state | The raw value on the capsense button, which can be used to determine a touch event |
Use these for fine control of your analog input. For general analog input needs, analogPin is almost always sufficient
Class: | The ADC class provides functionality for using the Delta Sigma ADC and two Succesive Approximation ADC’s on the RPiSoC. |
---|---|
Example: | Define ADC objects in the following way: My_DELSIG = ADC('DELSIG')
My_SAR = ADC('SAR0')
My_other_SAR = ADC('SAR1')
|
Method | __init__ |
---|---|
Description | Constructs and initializes an ADC object for use of a SAR or DELSIG ADC |
Parameters | string c_type |
c_type |
|
Returns | No return |
Note | None of the ADCs are included by default in V1.2, so this class will be unavailable. You are able to add them by simply placing them in your schematic on your RPiSoC program and reprogramming the board |
Method | CountsTo_Volts |
---|---|
Description | Converts the ADC output to a Voltage, taking into account any set gains or offsets |
Parameters | int counts |
counts | Digital value to be converted to it’s analog equivalent |
Returns | float volts |
volts | The resulting voltage after conversion of counts |
Method | GetResult |
---|---|
Description | Gets the result of a conversion which has been completed. StartConvert() must be called prior to this function, and StopConvert() must be called after |
Parameters | None |
Returns | int counts |
counts | Digital value which represents the result of the most recent AD conversion |
Method | IsEndConversion |
---|---|
Description | Checks to see if the ADC is done converting |
Parameters | None |
Returns | int counts |
counts |
|
Method | Read |
---|---|
Description | Simplifies the reading process by starting conversion, waiting for conversion to complete, stopping conversion, and returing the result, when called. It is only valid for the DELSIG |
Parameters | None |
Returns | int counts |
counts | Digital value which represents the result of the most recent AD conversion |
Method | SetBufferGain |
---|---|
Description | Sets the input buffer gain |
Parameters | int gain |
gain |
|
Returns | No return |
Side Effects | Increasing the gain will lower the buffer bandwidth |
Method | SetGain |
---|---|
Description | Sets the ADC gain in counts per volt, which will be applied before voltage conversion |
Parameters | int gain |
gain | Output gain in counts per volt to be applied before conversion |
Returns | No return |
Warning | gain is set by default by the reference and input range settings. It should only be used to further calibrate the ADC with a known input or if an external reference is used |
Method | SetOffset |
---|---|
Description | Sets an offset on the ADC which is used for the voltage conversion. It will subtract the given offset before making the conversion |
Parameters | int counts |
counts |
|
Returns | No return |
Method | SetResolution |
---|---|
Description |
|
Parameters | int resolution |
resolution |
|
Returns | No return |
Side Effects |
|
Method | Sleep |
---|---|
Description | Checks to see if the component is enabled, then it stops the ADC and saves the current configuration for later use |
Parameters | None |
Returns | No return |
Method | Start |
---|---|
Description | Sets the initVar variable on the RPiSoC, calls the ADC_Init() function, and then calls the ADC_Enable() function. This function configures and powers up the ADC, but does not start conversions |
Parameters | None |
Returns | No return |
Method | StartConvert |
---|---|
Description | Forces the ADC to initialize a conversion. This is handled internally for the Delsig ADC, using the Read() function, but it is kept seperate for the SAR. However, It can also be used for the Delsig |
Parameters | None |
Returns | No return |
Method | Stop |
---|---|
Description | Disables and powers down the ADC |
Parameters | None |
Returns | No return |
Method | StopConvert |
---|---|
Description | Forces the ADC to end conversion. This is handled internally for the Delsig ADC, using the Read() function, but it is kept seperate for the SAR. However, It can also be used for the Delsig |
Parameters | None |
Returns | No return |
Method | Wakeup |
---|---|
Description | Restores and enables the most recently saved configuration of the ADC |
Parameters | None |
Returns | No return |
Method | isRunning |
---|---|
Description | Checks to see if the ADC component and all subcomponents are currently operational |
Parameters | None |
Returns | bool __running |
__running | A private boolean variable which evaluates to True if the ADC is active, or False if it is not ` |
Use these to generate analog voltages, currents, or waveforms.
Class: | The VDAC class provides functionality for using the VDAC’s available on the RPiSoC. |
---|---|
Example: | Define VDAC objects in the following way: My_VDAC = VDAC(0)
My_other_VDAC = VDAC(1)
|
Method | __init__ |
---|---|
Description | Constructs and initializes a VDAC object |
Parameters |
|
channel |
|
Returns | No return |
Method | SetRange |
---|---|
Description | Sets the full scale range for the VDAC |
Parameters | string Range |
Range |
|
Returns | No return |
Method | SetSpeed |
---|---|
Description | Sets the DAC speed, and consequently the power level |
Parameters | string speed |
speed |
|
Returns | No return |
Method | SetValue |
---|---|
Description | Sets a digital value to be converted into an analog voltage and output by the VDAC |
Parameters | int value |
value |
|
Returns | No return |
Method | SetVoltage |
---|---|
Description | Sets a voltage in Volts to be output on the specified VDAC |
Parameters | float volts |
amps | A number between 0 and the full scale range, as selected by SetRange(). This will be converted to an analog voltage and output. |
Returns | No return |
Method | Sleep |
---|---|
Description | Checks to see if the component is enabled, then it stops the VDAC and saves the current configuration for later use |
Parameters | None |
Returns | No return |
Method | Start |
---|---|
Description | Enables and powers up the VDAC |
Parameters | None |
Returns | No return |
Method | Stop |
---|---|
Description | Powers down VDAC to lowest power state and disables output |
Parameters | None |
Returns | No return |
Method | Wakeup |
---|---|
Description | Restores and enables the most recently saved configuration of the VDAC |
Parameters | None |
Returns | No return |
Method | isRunning |
---|---|
Description | Checks to see if the DAC component and all subcomponents are currently operational |
Parameters | None |
Returns | bool __running |
__running | A private boolean variable which evaluates to True if the DAC is active, or False if it is not ` |
Class: | The IDAC class provides functionality for using the IDAC’s available on the RPiSoC. |
---|---|
Example: | Define IDAC objects in the following way: My_IDAC = IDAC(0)
My_other_IDAC = IDAC(1)
|
Method | __init__ |
---|---|
Description | Constructs and initializes an IDAC object |
Parameters |
|
channel |
|
Returns | No return |
Method | SetCurrent |
---|---|
Description | Sets a current in milliamps to be output on the specified IDAC |
Parameters | float amps |
amps | A number between 0 and the full scale range, as selected by SetRange(). This will be converted to an analog current and output. |
Returns | No return |
Method | SetPolarity |
---|---|
Description | Sets the DAC output polarity |
Parameters | string polarity |
polarity | SOURCE or SINK |
Returns | No return |
Method | SetRange |
---|---|
Description | Sets the full scale range for the IDAC |
Parameters | int mode |
mode |
|
Returns | No return |
Method | SetSpeed |
---|---|
Description | Sets the DAC speed, and consequently the power level |
Parameters | string speed |
speed |
|
Returns | No return |
Method | SetValue |
---|---|
Description | Sets a digital value to be converted into an analog current and output by the IDAC |
Parameters | int value |
value |
|
Returns | No return |
Method | Sleep |
---|---|
Description | Checks to see if the component is enabled, then it stops the DAC and saves the current configuration for later use |
Parameters | None |
Returns | No return |
Method | Start |
---|---|
Description | Sets the initVar variable on the RPiSoC, calls the IDAC8_Init() function and then calls the IDAC8_Enable() function. Enables and powers up the IDAC |
Parameters | None |
Returns | No return |
Method | Stop |
---|---|
Description | Powers down IDAC to lowest power state and disables output |
Parameters | None |
Returns | No return |
Method | Wakeup |
---|---|
Description | Restores and enables the most recently saved configuration of the DAC |
Parameters | None |
Returns | No return |
Method | isRunning |
---|---|
Description | Checks to see if the DAC component and all subcomponents are currently operational |
Parameters | None |
Returns | bool __running |
__running | A private boolean variable which evaluates to True if the DAC is active, or False if it is not ` |
Class: | The WaveDAC class provides functionality for using the WaveDAC available on the RPiSoC. |
---|---|
Example: | Define WaveDAC objects in the following way: My_Wave = WaveDAC()
|
Method | __init__ |
---|---|
Description | Constructs and initializes an WaveDAC object |
Parameters | None |
Returns | No return |
Method | GenerateWave |
---|---|
Description |
|
Parameters | string waveType |
waveType |
|
Returns | No return |
Note | V1.3 intends to introduce inputting custom waveforms |
Method | GetFrequency |
---|---|
Description | Calculates the actual wave frequency based on the most recently confirmed clock divider value |
Parameters | None |
Returns | float freq |
freq | The actual frequency of the wave, not a requested frequency |
Method | SetFrequency |
---|---|
Description | Sets an approximate frequency by using an appropriate clock divider so that the resulting wave is as close to the desired frequency as possible |
Parameters | float frequency |
frequency |
|
Returns | No return |
Method | SetSpeed |
---|---|
Description | Sets the DAC speed to one of the defined settings |
Parameters | string speed |
speed |
|
Returns | No return |
Method | SetValue |
---|---|
Description | Sets a digital value to be converted into a voltage and output by the WaveDAC. |
Parameters | int val |
val | Digital number between 0 and 255 |
Returns | No return |
Warning | The WaveDAC should be stopped before using this function |
Method | Sleep |
---|---|
Description | Checks to see if the component is enabled, then it stops the DAC and saves the current configuration for later use |
Parameters | None |
Returns | No return |
Method | Start |
---|---|
Description | Performs all of the required initialization for the component and enables power to the block |
Parameters | None |
Returns | No return |
Method | StartClock |
---|---|
Description | Restarts the WaveDAC clock after it has been stopped |
Parameters | None |
Returns | No return |
Method | Stop |
---|---|
Description | Powers down the WaveDAC to its lowest power state and disables output |
Parameters | None |
Returns | No return |
Method | StopClock |
---|---|
Description | Stops the WaveDAC clock so that a value can be set without interference by the clock |
Parameters | None |
Returns | No return |
Method | Wakeup |
---|---|
Description | Restores and enables the most recently saved configuration of the DAC |
Parameters | None |
Returns | No return |
Method | isRunning |
---|---|
Description | Checks to see if the DAC component and all subcomponents are currently operational |
Parameters | None |
Returns | bool __running |
__running | A private boolean variable which evaluates to True if the DAC is active, or False if it is not ` |
Method | setAmplitude |
---|---|
Description | Modifies the class attribute associated with peak voltage of a generated wave |
Parameters | float amplitude |
amplitude | A peak amplitude, in Volts, between 0 and 4.08 |
Returns | No return |
Warning | This method will become deprecated in V1.3. There will be an alternate way of accomplishing this |
Method | setdcBias |
---|---|
Description | Modifies the class attribute associated with DC Bias of a generated wave |
Parameters | float dcBias |
dcBias | A DC bias, in Volts, between 0 and 4.08 |
Returns | No return |
Warning | This method will become deprecated in V1.3. There will be an alternate way of accomplishing this |