Author Topic: LabVIEW interface for PIC18F4550 using WinUSB  (Read 13618 times)

0 Members and 1 Guest are viewing this topic.

Offline johnmxTopic starter

  • Frequent Contributor
  • **
  • Posts: 285
  • Country: pt
LabVIEW interface for PIC18F4550 using WinUSB
« on: June 23, 2012, 12:03:15 am »
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.
« Last Edit: June 23, 2012, 12:06:48 am by johnmx »
Best regards,
johnmx
 
The following users thanked this post: sorin

Offline bradleytron

  • Regular Contributor
  • *
  • Posts: 74
  • Country: ca
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #1 on: June 23, 2012, 12:21:58 am »
May I ask, what version of LabVIEW?
 

Offline johnmxTopic starter

  • Frequent Contributor
  • **
  • Posts: 285
  • Country: pt
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #2 on: June 23, 2012, 12:24:49 am »
This program was made in LabVIEW 2009 SP1 (version 9.0.1).
Best regards,
johnmx
 

Offline bradleytron

  • Regular Contributor
  • *
  • Posts: 74
  • Country: ca
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #3 on: June 23, 2012, 12:48:17 am »
This program was made in LabVIEW 2009 SP1 (version 9.0.1).

Thanks 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.
 

Offline johnmxTopic starter

  • Frequent Contributor
  • **
  • Posts: 285
  • Country: pt
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #4 on: June 23, 2012, 10:22:22 am »
I cannot save for an older version than 8.0, but I manage to print all the code. See attached document.
Best regards,
johnmx
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 3907
  • Country: us
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #5 on: June 23, 2012, 08:28:56 pm »
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.
 

alm

  • Guest
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #6 on: June 23, 2012, 10:42:06 pm »
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.
 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #7 on: June 24, 2012, 04:06:54 am »
But hey, it is the industry standard. Everyone uses it. So it must be good.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Quiggers

  • Contributor
  • Posts: 28
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #8 on: June 24, 2012, 02:10:22 pm »
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.
 

Offline bradleytron

  • Regular Contributor
  • *
  • Posts: 74
  • Country: ca
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #9 on: June 27, 2012, 04:27:49 am »
Thanks johnmx for the taking the time to make a pdf.
 

Offline hlavac

  • Frequent Contributor
  • **
  • Posts: 536
  • Country: cz
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #10 on: June 27, 2012, 11:11:23 am »
That is similar to what i'm trying to do here, expect with ATmega32U4, and no labview but custom control application
Good enough is the enemy of the best.
 

Offline zani

  • Newbie
  • Posts: 2
  • Country: br
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #11 on: April 17, 2014, 10:45:22 pm »
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.
 

Offline johnmxTopic starter

  • Frequent Contributor
  • **
  • Posts: 285
  • Country: pt
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #12 on: April 17, 2014, 11:46:21 pm »
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.
Best regards,
johnmx
 

Offline zani

  • Newbie
  • Posts: 2
  • Country: br
Re: LabVIEW interface for PIC18F4550 using WinUSB
« Reply #13 on: April 19, 2014, 01:18:00 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf