LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you use the MPUSBAPI.dll?

I thought I set that...   Thank you.
0 Kudos
Message 11 of 25
(4,798 Views)
Ok, I think that the problem may be arising because I am not initializing the buffer that I am feeding the write or the buffer that I am reading from the read function .  How can I do this?  The Write function is expecting an array of type BYTE[64] and the Read function should return an array of type BYTE[64].


extern "C" __declspec(dllexport)
DWORD MPUSBRead(HANDLE handle,              // Input
                PVOID pData,                // Output
                DWORD dwLen,                // Input
                PDWORD pLength,             // Output
                DWORD dwMilliseconds);      // Input

extern "C" __declspec(dllexport)
DWORD MPUSBWrite(HANDLE handle,             // Input
                 PVOID pData,               // Input
                 DWORD dwLen,               // Input
                 PDWORD pLength,            // Output
                 DWORD dwMilliseconds);     // Input


0 Kudos
Message 12 of 25
(4,789 Views)

@mchp1 wrote:
Ok, I think that the problem may be arising because I am not initializing the buffer that I am feeding the write or the buffer that I am reading from the read function .  How can I do this?  The Write function is expecting an array of type BYTE[64] and the Read function should return an array of type BYTE[64].

Did you read my replies? That's precisely what I said in reply #5. Also, it makes no sense that it requires a fixed byte array of 64 elements. If it did, then the read would not require a separate input of how many elements are in the array. Same goes for the write. In your example C program you were pre-allocating an array of 64 bytes, but tellng the functions that the array length was 4 for the receive and 2 for the send. Made no sense to me, but whatever.

To have the read function read a maximum of 64 bytes then you would do something like this:

This allocates an array of 64 bytes and tells the function that you are providing an array of 64 bytes (not 4). The function will return how many bytes were read with its output parameters. Note that the output array will still be 64 bytes. You can use Split Array if you wish to chop off the extra zeros.


Message Edited by smercurio_fc on 08-12-2008 04:24 PM
0 Kudos
Message 13 of 25
(4,781 Views)
Thank you.  I found the problem.  I was calling the dll through the "Call Library Function" as if it were using the stdcall convention instead of the c convention.
0 Kudos
Message 14 of 25
(4,768 Views)
My comments regarding the pre-allocation requirement are still valid since you have to do that.
0 Kudos
Message 15 of 25
(4,763 Views)

HI  Mchp1

 

Please send me the correct labview code and the code of the controller for guidance.

0 Kudos
Message 16 of 25
(3,750 Views)

Hi

 

What kind of application have you developed by using mpusbapi.dll ? Are you making DAQ card , please tell me about it.

0 Kudos
Message 17 of 25
(3,730 Views)
A DAQ/Switching Matrix controlled  by a PIC32MX460F512L through LabVIEW.  Be sure to include mpusbapi.dll to the directory.
Message 18 of 25
(3,713 Views)

Thanks for your help. I want to ask some questions

 

http://www.elektor.com/magazines/2007/november/usb-data-acquisition-card.271706.lynkx

 

I found the above link of usb data acquisition card , this  daq card has eight analog channels , 8 digital inputs , 8 digital outputs and 2 pwm outputs. The software interface using this daq card is based on .NET Framework. This daq card uses PIC18f4550 microcontroller. I have understood the code of user.c but that code is compatible with Visual C++ application . I want to control this Daq card over labview8.2 . Please tell me how can i use your labview VI to control this DAQ card .

              

 

            In your driverVI , i have to add the 8 analog inputs of ADC  out of which the one i select sends a particular code to the pic18f4550 ,which recognizes that code and enables only that input channel. Similarly in your VI , i want to add two analog PWM outputs also and 8 digital inputs and outputs each.

 

  You have worked before on the MCHPUSB Framework. , please just go through  user.c  and user.h for better understanding what i am trying to say. I have attached the firmware also or you can go to the link and download it from there. 

 

Please help me in developing the labview application as i want , i am new to labview and learning call library function but i have to complete this application within a week.

 

Any help greatly appreciated

 

Regards

Simon

 

usb_novice@rocketmail.com 

0 Kudos
Message 19 of 25
(3,701 Views)

Hi mchp1

 

I sent you only the firmware of the 18f4550 , you can download the complete code from the link mentioned above.

 

Please just look into it.

 

 

Regards

 

Simon

0 Kudos
Message 20 of 25
(3,680 Views)