Pmods™ are small I/O interface boards that offer an ideal way to extend the capabilities of our FPGA/CPLD and embedded control boards. Pmods communicate with system boards using 6 or 12-pin connectors. Pmods include sensors, I/O, data acquisition & conversion, connectors, external memory, and more.
All of the Pmods that Digilent sells can be found here.
For this demo, the PmodACL (accelerometer), PmodALS (ambient light sensor), PmodCMPS (compass), PmodGYRO (gyroscope), PmodJSTK (joystick), PmodMIC3 (microphone), PmodTC1 (thermocouple), and PmodTMP3 (ambient temperature sensor) are supported.
This demo uses LabVIEW, LabVIEW MakerHub LINX, chipKIT WF32, 2x 4.7k resistors (pull-up resistors) and the Pmods mentioned above. The pull-up resistors are used to pull up the data lines SCL and SDA for I2C communication. If you're not sure how to connect these resistors, check out this Instructable that contains a description on how to connect the pull-up resistors.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Basic Idea
The idea for this program is to allow users to plug in a Pmod to either the I2C or SPI cable, select the Pmod they are using on the front panel, change any settings they wish for that specific Pmod, and click run and see the readings from the sensor.
The above picture is the front panel for the LabVIEW VI. All you need to do for the LINX setup is choose the COM port the chipKIT WF32 is connected to and then select the Pmod you're using the first time you open the program. In the picture above, the SPI PmodALS is selected and ready to be read.
Step 2: Set Up Required Software
Follow this Instructable to get all the software you need and your chipKIT WF32 up and running on LabVIEW.
Step 3: Wiring and Jumper Setup
Refer to the picture above to make sure you have the jumpers in their correct positions.
For SPI, there is a CS (chip select) line, MOSI (master out slave in) line, MISO (master in slave out) line, SCL (serial clock) line, ground line and 3.3V line. CS, MOSI, MISO, and SCL will connect to digital channels 10, 11, 12, and 13 on the chipKIT WF32 respectively. This is the default SPI configuration on the chipKIT WF32 and corresponds to SPI channel 0 for LabVIEW. Also make sure you connect ground and 3.3V to the Pmod as well.
For I2C, there is a SCL (serial clock) line, SDA line, ground line, and 3.3V line. Connect SCL and SDA to analog channel 5 and analog channel 4 respectively.
When everything is connected, your setup should look something like the picture above. Check the notes on the pictures if you aren't sure what the connections are.
Step 4: LabVIEW Code
Plug in an SPI or I2C Pmod. In the attached zip file, there is the main VI called PlugandPlayPmod and then all of the subVIs that are used. When opening PlugandPlayPmod, LabVIEW may start searching for where the subVIs are located on your computer. If this happens, just wait until a window pops up that prompts you for a specific VI (ie PmodALSOpen.vi) find where this is located on your computer (wherever you extracted the .zip file), select it and click "OK." This will ensure that the main VI knows where all the subVIs are located on your computer.
In the LINX settings, make sure the SPI and I2C channels are set to 0 and the CS channel is set to 10. You only need to do this when you first open the VI.
Here is a listing of the SPI vs I2C Pmods that are supported for this demo.
Now just choose either SPI or I2C depending on the Pmod you plugged in and then select the specific Pmod.
For some Pmods, there are extra settings you can change using the controls on the front panel. When you're done changing those, click the run arrow on the front panel.