SPI with chipKIT WF32 and LabVIEW

I have recently been working on SPI and I2C with the chipKIT WF32, LabVIEW Home Bundle, and various Pmods.  Using LabVIEW MakerHub LINX, I was able to have the WF32 interface with the different Pmods and LabVIEW.  I wrote an Instructable here about how I got the PmodALS (ambient light sensor) to interface with the WF32 which also includes a section on how to read the data sheet to find what you’re looking for.  This Instructable was made as a guide so that others can understand how to read the data sheet in order to find the information required to use SPI for various sensors themselves.



First, SPI communication is initialized and configured.  Then two bytes of data are sent to PmodALS so that the two data bytes can be received.  After successfully getting the two bytes back from the PmodALS, they still have to be altered to get a meaningful reading.  To do this, the two received bytes are spliced together and then the first four and last four bits are stripped off to give an 8 bit unsigned integer that ranged from 0 (no light) to 255 (max light the PmodALS can sense).  All of this information was found in the data sheet for the PmodALS.  Check out the LabVIEW code below.



After reading my Instructable, hopefully you will have a basic idea of how to use SPI in LabVIEW.  Try a different Pmod or sensor that uses SPI and see if you can get information back from it!  Feel free to let me know if you have any questions.

Be the 1st to vote.

Leave a Reply

Your email address will not be published. Required fields are marked *