In the previous example, a pushbutton was "soft wired" to an LED in such a way that the LED was ON when the pushbutton was up, and OFF when the pushbutton was down. This is the reverse of what you would usually expect, so in the present system configuration (GPIO_TEST4.sys), the signal is inverted using an instance of the FB_NOT function block type so that the LED is ON when the pushbutton is down.
Monday, May 25, 2015
In this system configuration (
GPIO_TEST3), the GPIO "loopback" connection of the previous example is replaced with connections to real devices, which replace the Graphical User Interface (GUI) elements:
- Pin 3 is configured as an output connected to an LED (the yellow button) in series with a 100 Ohm resistor to ground.
- Pin 5 is configured as an input with an internal pull-up resistor, connected to a normally open pushbutton (the green button) to ground.
- The value of the pushbutton input (
BUTTON.X) is passed to the LED output (
LED.X) via the graphical connection, and the
LEDblock is notified of the current pushbutton status by the
BUTTON.CNF => LED.REQevent connection.
- When the button is up (open), the state of pin 5 is HIGH due to the internal pullup resistor on the input pin, and this is passed to the LED on pin 3 as an ON condition, as shown in the picture on the left below.
- When the button is down (closed), it pulls pin 5 LOW and this is passed to the LED on pin 3 as an OFF condition, as shown in the picture on the right below (the green button is held down with transparent tape in order to take the picture).