Introduction: Using the Static I/O With the Analog Discovery 2
Static Input/Output pins are used for either sensing or generating change-of-state instances. With the Analog Discovery 2's 16 channel I/O, you have a ton of options for doing just that.
For this Instructable you will need:
-Waveforms 2015 software
- a computer with USB port to run the software
*You may also use the original Analog Discovery or the Electronics Explorer Board with Waveforms 2015. There are some slight differences in functionality between the AD1, AD2, and EEBoard, but nothing that will prevent you from following along if you have one of the other tools.
Step 1: Static I/O.
There isn't much to cover as far as background for Static Input/Output, so let's just get started. If you want some help getting your AD2 set up and calibrated, or installing Waveforms 2015, check out this quick start I'ble collection.
Before we start, note that the AD2's digital channels are not meant to be used as sources for large loads. Don't connect much more than a single LED and resistor directly to the channel. If you need to drive larger loads, the channels can be used to trigger high current drivers such as MOSFETs, H-bridges, etc. but are not to be used as primary sources.
Once you have your AD2 and Waveforms all set up, open the Static I/O by clicking on the "Static IO" button.
The Static I/O window will open.
The first thing to note here is that unlike other tools, the Static I/O window opens with the tool running, as illustrated by the icon in the Static I/O tab at the top of the Waveforms window.
By default, none of the digital pins are set as outputs, so you shouldn't have any immediate issues with shorting but you should be aware that the pins are active. I recommend stopping the tool before doing any pin re-configuration.
There are two main areas: control options are at the top, and the channel configurations take up the bulk of the window space.
At the top you have a few options.
"File" lets you Save the current Static I/O project, Open a saved project, or Close the Static I/O tool window.
"Control" gives access to the tool's Run and Stop commands.
Under "View", there is one setting for turning on names for each I/O pin. With "Show name" checked, a small label box appears below each pin with a default name that matches the label on the 30-pin header. This name can be edited to identify the signal as it applies to your application.
Channel names can only be applied to individual channels when you have access to them. Some settings group all 8 channels into one reading, in which case you can't change the name. More on that in a bit.
"Window" lets you browse between any Waveforms tool windows you may have open, as well as the Help screen.
Step 2: Channel Configuration.
Each digital channel is set as an input, specifically a virtual LED, by default. A logic high value on any pin turns on the corresponding LED in the window to reflect the change in state on that pin in real time.
The AD2 has 16 digital logic pins, labelled 0-15. They are broken into two groups 0-7 and 8-15. On the left side you have some controls for each group of 8.
"Bit IO" is checked by default and lets you set the whole group of 8 pins as the same type.
Selecting "Last IO" resets all 8 channels to the last setting of each channel if you were to switch the whole group to one of the bus options.
"LED" is the default and sets all channels to inputs with a virtual LED displayed. The LED will light when a logic high is detected. The AD2 defaults to 3.3 V for logic high for both input and output, but all digital pins are 5 V input tolerant. In the event of accidental overvoltage on one of the digital pins, up to ±20 V overvoltage protection is supported.
"Button" contains a small menu of options for different types of buttons with various combinations of output states based on whether the button is pressed or released.
"1" corresponds to a logic high and "0" is a logic low. "Z" is a high impedance state, which means that the output value is neither high nor low. There is no output at all, so the state is undetermined. In practice, "Z" state will usually be far enough below the logic high state to turn off whatever is connected, but it is not technically considered to be in the low state. Semantics, I know. Also note that there is no way to "hold" a button in a pressed state. They are truly momentary.
"Switch" has similar options to "Button" except that the output will hold in whatever state you switch it to until you switch it out of that state. You also have the option of three-state switches, with "Z" between "1" and "0".
Each channel can also be individually configured for LED, button, or switch by clicking on the small number associated with each channel. Only that channel will be configured, letting you configure any channel however you want.
Below "Bit IO" in the group control you'll see "Slider", "Progress bar", and "7-segment". Each of these setting configures that group of channels as one 8-bit bus.
"Slider" is an 8-bit output bus. As you move the slider to the right, the equivalent decimal value will display in a small box on the right. You can directly enter any value between 0 and 255 in this box. This value will be represented in binary on the 8 corresponding pins, with the highest channel number representing the most significant bit (MSB).
"Progress bar" is an 8-bit input bus. The 8 channels are used to indicate a value represented in binary with the highest channel number representing the MSB. On the right you will see the equivalent decimal value.
The last option is "7-segment" which takes all 8 channels and assigns each to a segment in a virtual 7-segment display, including a decimal point. Each channel number is displayed on the 7-segment for ease in assigning values.
Step 3: That's It.
The Static I/O tool is extremely simple and easy to use. But I would remind you of my warning from before:
The digital channels are not meant to be used as sources for large loads. Don't connect much more than a single LED and resistor directly to the channel. If you need to drive larger loads, the channels can be used to trigger high current drivers such as MOSFETs, H-bridges, etc. but are not to be used as primary sources.
Using the pins to sink or source too much current will likely result in damage to your Analog Discovery 2. Let's not do that.
As always, thanks for reading. If you have questions, please ask them in the comments below, though PMs are always welcome as well. You just never know when someone else has the same question and that way we can all learn and help each other get better. Have fun building!
Also, please check out the Digilent blog where I contribute from time to time.