LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between PC and ATMEL micro controller using USB ports

Hi All
 
I am Using LV8.0 FDS and VISA 3.1
I am trying to communicate my PC with ATMEL microcontroller( just writing and reading string commands) similar to serial communication. For that i need to develop a USB driver in LV.
 
As i am new to USB communication , i have gone through the USB instrument control tutorial. i had few questions from it.
  1. How to know the class of the USb device(ATMEL microcontroller)?
  2. Any h/w or s/ w needed to be installed to perform usb communcation(i have already installed the drivers CD that come with FDS)?
  3. When to use USBRaw Bulk mode and When to use USBRaw Control mode?
  4. When to use VISA write/read vi's and when to use USB control in/out vi's?
  5. Also how to detect whether it is a USBTMC device or USB Raw device?

I am trying hard with these questions. but i didn't get the solution.

So plz suggest me with solutions .and attach examples if any which may clarify my doubts

0 Kudos
Message 1 of 10
(10,998 Views)
Hi mudigondla,
Thank you for contacting National Instrument with your questions. I will do my very best to get you the information you need. You mentioned that you wished to develop a driver so that you can communicate with your USB micro-controller, are you familiar with the Driver Development Wizard that comes with NI-VISA 3.0 and higher. What it will do is create an .inf file that will allow you to use VISA commands to communicate with your device, in all essence it will act just like any other serial device. All this is explained and detailed in the USB Instrument Control Tutorial DevZone article. As for your individual questions:

1. The instrument is not a NI product, consulting the manual or contacting the manufacturer may be more fruitful. The following link may be able to help you in determining the class

2. In order to communicate with your device in LabVIEW you will need to implement the driver development wizard, which is included in NI-VISA. Other than that, I do not see any other H/W or S/W for what you've explained to me thus far

3. USB RAW Bulk and Control mode will be specific to what you want your application to do. Here are some example codes for Bulk and Control, along with more information about communicating with USB RAW

4. In the method that I have been describing, you will primarily be using VISA commands to read and write to your device

5. Refer to the Driver Development Wizard tutorial for this question

I hope that this helps you in your project
Can Wong
0 Kudos
Message 2 of 10
(10,969 Views)

Hi Can

Thanks for your reply.

i have gone through the tutorial. I need few more clarifications.

1. I created DDW for my device and every thing is fine. i.e., in the device manger it is identified as the NI USB device and also it is identified in MAX and VISIAC. Now when i plugged out the device and then plugged in for the second time. Now i find a problem. My device is identified as normal usb device in device manager. Also it does not appear in either MAX or VISIAC. My doubt is whether we need to create DDW each time we plug the device or why is it happened like above . or we need to take any steps when we plug for the repated no. of times.if so what are the steps to be taken.Plz. suggest.

2. Even after going through the USB Raw tutorial and eg ,i am not clear about the bulk and control. Can you give me two situations to work with, differentiating USB Raw Bulk and USB Raw Control because i was struck up here and waiting for a solution My application is to communicate with micro controller from PC through USB ports.(sending and receiving commands etc) .Which of the USB Raw mode will be suitable for this application. 

Plz reply soon.

Thanks

Kiran

0 Kudos
Message 3 of 10
(10,955 Views)
Hey Kiran,

Once you've created the driver that links your USB device to VISA, there should be no need to do this everytime you plug your device in. Your device should reference that driver everytime you plug it in, what it is doing now could be caused by several issues. One possibility is that the device is a Human Interface Device class, in which this link explains and details how to fix.

As for your second question, USB Raw Control and Bulk describe the transfer modes that they perform. Control transfer is primarily used for sending commands to your device or receiving status information. Bulk transfer is used to send "bulk" amounts of data to the device. It has error detection but is can get high latency, printers and scanners are some examples of this. From what you described about your application, I believe that Control would be the best method for you.


Can Wong
0 Kudos
Message 4 of 10
(10,936 Views)

Hi Can

Thanks for ur replys. They are helping me a lot.

I had the above problem when i tried with pen drive. Now it is solved. I am able to detect it when ever i plug it.

Now i am trying to communicate with my micro controller. After creating and installing th INF file using DDW, when i tried to plug in the device, windows device manager is able to detect the device as NI USB device. that is fine. Now Add New  H/w Wizard appears and i followed the instructions and selected the inf file created when it prompted to select for the device driver.

 Now the hardware wizard shows as

"Cannot start this hardware

There was a problem installing the hardware

The deivice cannot start(code 10)"

What might be the problem? i have not installed any s/w related to the controller(AT91SAM9263) in the  system.  I think, in this case it should accept the VISA drivers.Also i didn't find the device in either MAX or VISAIC. Plz suggest a solution

Thanks

Kiran

0 Kudos
Message 5 of 10
(10,927 Views)
Hey Kiran,
There are several items that can be causing the issue you are seeing, none of which can be easily narrowed down by asking quick questions. The first thing to try out is seeing whether or not you have the most updated version of drivers. It's usually best to have the most updated drivers for your system, for your case NI-VISA should be updated if not already.
If this is not the situation, it may be a corrupted driver. To test for this we would have to perform the creating driver, HID item and other tasks mentioned before on a USB Mouse. If the mouse gets the same error as your micro-controller, then it may be something to do with a problem with the inf driver that was created.
If the top two doesn't work, or yield any results, then it may be that your device may not be compatible with VISA commands. Hopefully this is not the case, I just wanted to let you know that this may be a possiblity.

Let me know,

Can Wong
0 Kudos
Message 6 of 10
(10,888 Views)

Hi Can

Thanks for your reply

I  tried to communicate with pen drive creating the inf file with DDW. And every thing is fine.It is detected as a NI USB device in Windows Device manager and also detected as a USB Raw device in MAX. But the thing is, i am not able to communicate with the device. I am in a dilema, whether to go for USB RAW Control communication or USB RawBulk communication. (My requirement is send and receive commands just like serial communication). I have seen the tutorials in the Knowledge base.But i didn't get the clear idea. Plz suggest.

The problem that i have posted before is while installing my microcontroller.

Thanks

Kiran

0 Kudos
Message 7 of 10
(10,868 Views)
Hey Kiran,
There should be example programs in LabVIEW that you can use to see if you can communicate with your device. If you open up Example Finder, by selecting Help->Find Examples..., and select Hardware Input and Output->VISA->USB RAW Control.vi. From what you've told me, I believe that you want the USB Raw Control as this type of transfer method is primarily used to send commands to your device. Bulk is primarily used for sending huge amounts of data, but subject to latency, printers are usually this type of transfer method. Try out the example program and see if you can get any response. As I mentioned before, some devices may not work with the VISA commands as they do not follow the format. This is something that I want to bring to your attention.

Regards,
Can Wong
0 Kudos
Message 8 of 10
(10,830 Views)

Hi Kiran,

 

This is Naresh..

I need some help. I am also facing same problem with our custom designed board with AT91SAM9263 ARM 9 Controller.

Controller has been shipped with some example programs for this using USB like "USB to Serial Converter".

I loaded that program and its working fine.

But the thing is that when selecting driver using NI Driver Developement Wizard, its searching and ending with error code 10.

You got any solution?, if anything is there please reply me or mail me to nareshnarra@gmail.com

 

Regards,

Bujjin

0 Kudos
Message 9 of 10
(9,225 Views)

May be this VI file will help you. It communicates with AT90USB1287 as Generic HID device using Call Library function node of LabView.

Refer ATMEL's application note "USB PC Drivers Based on Generic HID Class" 

http://atmel.com/dyn/resources/prod_documents/doc7645.pdf

You can also use ATUSBHID.DLL file to communicate with C#, VB etc.

0 Kudos
Message 10 of 10
(8,391 Views)