LabVIEW interface for PIC18F4550 using WinUSB - Page 1
Forum section: electronics / projects

author: johnmx
author_rank: Frequent Contributor
timestamp: June 23, 2012, 12:03:15 am
content: Have you ever wanted to interface LabVIEW with an USB microcontroller without using Virtual COMs? If so, you’re in the right place.I would like to share this demonstration program that I have done and anyone can use it for educational purposes.Use it to understand how the WinUSB driver works or as a start point for a more complex program.The LabVIEW program communicates with the PIC18F4550 through USB using WinUSB driver.It controls one LED and receives one button status.In the attached file you can find the LabVIEW program, PIC firmware and some notes.The firmware is compatible with Microchip's PICDEM Full Speed USB Demonstration Board.

author: bradleytron
author_rank: Regular Contributor
timestamp: June 23, 2012, 12:21:58 am
content: May I ask, what version of LabVIEW?

author: johnmx
author_rank: Frequent Contributor
timestamp: June 23, 2012, 12:24:49 am
content: This program was made in LabVIEW 2009 SP1 (version 9.0.1).

author: bradleytron
author_rank: Regular Contributor
timestamp: June 23, 2012, 12:48:17 am
content: Quote from: johnmx on June 23, 2012, 12:24:49 amThanks very much, I only have access to a much older version 7.0. Does your code utilize functions and or features that could be reproducible under this earlier version? If you think so would you be able to post an image of the wiring diagram?Take care and thanks for this interesting bit of code.

author: johnmx
author_rank: Frequent Contributor
timestamp: June 23, 2012, 10:22:22 am
content: I cannot save for an older version than 8.0, but I manage to print all the code. See attached document.

author: ejeffrey
author_rank: Super Contributor
timestamp: June 23, 2012, 08:28:56 pm
content: If you email your code to National Instruments with an angry letter about the irresponsible behaviour of breaking source code compatibility with every release for no reason they will convert your code to an older version by going back version-by-version. At least this worked for me in the past. It is annoying work for the poor schmuck they make handle these cases, but maybe they will get the idea that it is insane to expect to be taken seriously as a programming language with such casual disregard for the value of their customers source code. Probably pigs will fly first, but a guy can dream.

author: Unknown
author_rank: Unknown
timestamp: June 23, 2012, 10:42:06 pm
content: Even more helpful is that they broke the LabVIEW 8.0 export in 2009 (I seem to recall it crashing if the program contained an event structure). The documented solution was to export it to 8.5 and use LabVIEW 8.5 to export it to version 8. As if their customers have nothing better to do than keeping virtual machines around with every point release of LabVIEW.

author: Bored@Work
author_rank: Super Contributor
timestamp: June 24, 2012, 04:06:54 am
content: But hey, it is the industry standard. Everyone uses it. So it must be good.

author: Quiggers
author_rank: Contributor
timestamp: June 24, 2012, 02:10:22 pm
content: the word "standard" always conjures the word "average", as in"is that good or bad""ah, it's average"on a side note, elektor magazine has been running a feature on using labview with an arduino. May edition if interested.As for this project, it's a great idea, it demonstrates using the built in USB on the PIC and getting the PC communicating with it.I've just finished a 4 yr electronics degree and we only ever talked about this in lectures, it's on my summer list of remedial projects to fill in obvious gaps i've spotted in my knowledge and experience.

author: bradleytron
author_rank: Regular Contributor
timestamp: June 27, 2012, 04:27:49 am
content: Thanks johnmx for the taking the time to make a pdf.

author: hlavac
author_rank: Frequent Contributor
timestamp: June 27, 2012, 11:11:23 am
content: That is similar to what i'm trying to dohere, expect with ATmega32U4, and no labview but custom control application

author: zani
author_rank: Newbie
timestamp: April 17, 2014, 10:45:22 pm
content: Dear johnmx, i suffered a lot to understand the winUSBexample attached but I managed to make the control of 8 LEDs and 8 buttons. I wanted to deploy an AD conversion but my biggest difficulty lies in programming the PIC because I'm more familiar with the CCS compiler than the C18.If you can send an example of AD conversion with or without the use of a button has help me a lot.The parts of the firmware that I modified is attached.Thanks in advance.

author: johnmx
author_rank: Frequent Contributor
timestamp: April 17, 2014, 11:46:21 pm
content: Hi zani,Here is a simple example on how to use the ADC.I modified my main.c file to include a new command. In this case command 0x82. I see you are already using this value on your program, just change it to any other.The ADC peripheral is initialized on line number 622 to channel 0. Change this configuration if you want to use another channel.Then every time the PIC receives the 0x82 command (line 770), it will trigger a new conversion and send the result back to the PC through USB.On the LabVIEW side, just add a new button to send the new command.

author: zani
author_rank: Newbie
timestamp: April 19, 2014, 01:18:00 am
content: Thanks johnmx for this example. I managed to implement the AD conversions on 8 channels PIC, and the switchs, when are pressed, enable the channels. Johnx or does anyone know what the highest frequency of a signal that can be sampled in this example without loss of data? The timeout value in labview interferes in ADCs?I would like to convert signals from up to 100Hz + / -The changes are in the attached program.Thanks in advance.Best regards,Zani.