Showing results for 
Search instead for 
Did you mean: 

usb communication with pic18f4550

Hello everybody my problem is as follows: I am using a pic18f4550 in HID communication with the labview interface. everything works very well at the beginning but after a while the PIC reboot and the interface detects it as a new device. when i use the pic with another software like HID Terminal mikrochip its work very well. so i think that the problem is with the interface. please find attached the labview program

best regard


0 Kudos
Message 1 of 9

Hi llias,


two notes:

- why do you open and close the port with each iteration?

- why do you use a local variable, when the terminal is unused?

Best regards,
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 2 of 9

Hi GerdW

thanks for your answer

I tried to close each iteration to see if it changes anything but nothing. I send you the new schema knowing that it always gives the same problem.

0 Kudos
Message 3 of 9


Closing the port on each iteration and opening only once will almost certainly give you trouble, try moving that outside the while loop and let us know what happens.


Are you getting any error codes when you run the program itself, or does the device just spontaneously reboot?

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 4 of 9

I have already done this and the problem that i had is that the event dont close so in the visa source name i had somethink like that : 

USB0::0*1234::0*0001 :: NI-VISA-0:: RAW.

USB0::0*1234::0*0001 :: NI-VISA-0:: RAWEvent(9344).

USB0::0*1234::0*0001 :: NI-VISA-0:: RAWEvent(9345).

USB0::0*1234::0*0001 :: NI-VISA-0:: RAWEvent(9346).

USB0::0*1234::0*0001 :: NI-VISA-0:: RAWEvent(9347).





about the code error yes i had a code error but i dont remember it, i'll I send it to you as soon as I get it.

thank you very much for your help 

0 Kudos
Message 5 of 9

after leaving the system running all night I had a crash again but no error message. But in the visa source name level I had the same usb device name with a subscript as a result :

USB0::0*1234::0*0001 :: NI-VISA-0:: RAW.

USB0::0*1234::0*0001 :: NI-VISA-1:: RAW.

USB0::0*1234::0*0001 :: NI-VISA-2:: RAW.

i didn't have any error message

please help i dont know where is the PROBLEMMMMMMMMMMM 😞


0 Kudos
Message 6 of 9

Hmm, okay. Let's take a step back to see if we can get a better picture of what's going on. 



You mentioned that everything works well at the beginning of the code--what data are you expecting to see? Are you getting that data? Does it stop at any point?


Are you using USB Raw commands to communicate with your instrument? If so, can you use one of the USB Raw LabVIEW examples to see if communication still fails?


Last thing--can you describe the crash behavior a little more in depth? Does the device just disconnect, does LabVIEW itself go into a hang, what's happening there? 


Lots of questions, I know, but hopefully it'll get us somewhere!



Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 7 of 9

Hi Claire

 for your questions, the sending of data is without problem, no cut in the sending. I get my data every second without any problem.
i'll try to use the example of USB raw LabView and see if the problem persists.
At the level of the crash, the application labview does not hang, it is the name of the visa source name that changes by adding an index and I have to change the name of the visa source name manually for the acquisition continues, appart its no problem to report with the labview application.
I hope that my problem is more clear now. 
thank you very much Claire for your help
best regard
0 Kudos
Message 8 of 9



Thanks for the info! I'm not sure why you'd be getting an index on the end of your VISA resource name if everything else is running fine--is there any sign of a disconnect of the device? 


In the meantime, a workaround might be to retrieve the name of the resource programmatically, there's a good article on it located here. How did the USB Raw example go?

Claire M.
Technical Support
National Instruments
Certified LabVIEW Developer
0 Kudos
Message 9 of 9