GPIO driver for Digital Inputs
Introduction
The GPIO driver for Digital Inputs is used to detect the level of a digital signal on a selected pin. The selected digital pin can include internal pull-up or pull-down functionality as well as internal button debouncing.
Driver Parameters
The GPIO driver for Digital Inputs has three parameters that have to be configured:
Pin
This is the pin sensing the input; any of the GP pins are suitable for this selection if not already used for other drivers.
Debouncing
What is Debouncing
Pushbuttons often generate spurious open/close transitions when pressed, due to mechanical and physical issues. These transitions may be read as multiple presses in a very short period of time which can fool the program. Debouncing puts a physical delay between the readings so it ensures that the button is really pressed again. Without debouncing, pressing the button once may cause an unpredictable result.
Possible Configurations
Debouncing Enabled:
The pin is debounced internally and will disregard mechanical feedback during a single button depression (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Debouncing-Enabled )
Debouncing Disabled:
The pin can be debounced externally with a debouncing circuit fitting the application (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Debouncing-Disabled-with-External-debouncing )
The pin can also be left just as it is, but unpredictable results might occur (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Debouncing-Disabled )
Pin Mode
What is a Pull Resistor
Let's say you have an MCU with one pin configured as an input. If there is nothing connected to the pin and your program reads the state of the pin, will it be high or low? It is difficult to tell. This phenomena is referred to as floating. To prevent this unknown state, a pull-up or pull-down resistor will ensure that the pin is in either in a high or low state, while also using a low amount of current.
Possible Configurations
Pull Down:
The pin is pulled down internally and a 3.3 voltage level has to be applied to the pin to change its state (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Pull-Down )
Pull Up:
The pin is pulled up internally and a ground level has to be applied to the pin to change its state (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Pull-Up )
Floating:
The pin can be pulled down externally with any resistor above 1000Ω depending on the application (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Floating )
The pin can be pulled up externally with any resistor above 1000Ω depending on the application (see: https://quantumintegrate.atlassian.net/wiki/spaces/HELP/pages/148308356/How+to+use+the+GPIO+driver+for+Digital+Inputs#Floating )
Note: The pin should not be left floating, this can lead to unexpected readings
Wiring
Pull Down
The pin is pulled down internally. By applying a 3.3V level it reads a high state
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
GP0 (can be any GP pin) | This pin reads the digital level and is pulled down internally |
3.3V | This pin provides the high level |
Pull Up
The pin is pulled up internally. By applying a GND level it reads a low state
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
Any GP pin | This pin reads the digital level and is pulled up internally |
GND | This pin provides the low level |
Floating
The pin is pulled up externally with a 10000Ω resistor. By applying a GND level it reads a low state
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
Any GP pin | This pin reads the digital level and is pulled up externally |
3.3V | This pin pulls the level up through the resistor |
GND | This pin provides the low level |
The pin is pulled down externally with a 10000Ω resistor. By applying a 3.3V level it reads a high state
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
Any GP pin | This pin reads the digital level and is pulled down externally |
3.3V | This pin provides the high level |
GND | This pin pulls the level down through the resistor |
Debouncing Enabled
Any of the above circuits are possible. The button is debounced internally as described in the parameter description
Debouncing Disabled
Any of the above circuits are possible. The button is not debounced internally as described in the parameter description
Debouncing Disabled with External debouncing
The pin is externally pulled up for this example with a 10000Ω resistor. By applying a GND level it reads a low state. The pin is externally debounced with an RC low pass filter which filters out the high frequencies generated by the mechanical issues
Breadboard
Schematic
Used Pins
Used Pins | Description |
---|---|
Any GP pin | This pin reads the digital level and is pulled down externally |
3.3V | This pin pulls the level up through the resistor |
GND | This pin provides the low level |
How to write an App
Navigate to the App Builder and create a new application. You can find the “Digital In” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.
Drag the “Digital In” Object onto the canvas.
Next, locate the “Switch” Object under the “Interface” tab and drag it onto the canvas.
Finally, connect the “State” port from the Digital In Object to the “State” port on the Switch Object, and save your application.
How to create a firmware
Navigate to the Firmware Builder and create a new firmware file.
Click the “+ Add Hardware” button which will open a modal window. Scroll down in the list to find the “Generic” section and select the “Digital In” hardware option.
Give your device a name, and click “Add Device”
Next, select the “GPIO” driver under the driver dropdown menu, set the Pin, the Debouncing and the Pin Mode.
For this example we select:
Pin: GP0
Debouncing: Enabled
Pin Mode: Input Pull Down
You may now save your firmware file and upload it to one of your clients.
Supported Hardware
Buttons
Contact sensors
Anything providing a digital signal
Downloads
Apps
Firmware
Assets