LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Library mpusbapi.dll

Hello, I need help, I need to know in what order the "mpusbapi" library is programmed,(open, close and read)or what are the best ways to program it. Sorry for my English

 

Javo20200_0-1701062772011.png

 

0 Kudos
Message 1 of 9
(641 Views)

hola, estoy tratando de programar con la librería mpusbapi de microchip, ya logre que funcione, el problema radica en que tengo algunos problemas con los datos.

estoy buscando ayuda para saber como puedo programar el orden de; open, read y close.

Javo20200_0-1701062388785.png

 

0 Kudos
Message 2 of 9
(639 Views)

Typically you want to open a connection to the device, then do any number of reads and/or writes to it and at the end do a close. That is pretty much universal with almost all devices, and seeing the naming of the functions for your library being the same, I would be very much surprised if it was different. You usually want to avoid doing an open/close over and over again, unless there is a long time period between subsequent communication requests (read/write).

 

Other than that, you might have some challenges with interfacing to DLLs. For instance your Call Library Node uses an uint32 for the handle parameter. This only will work without any potential problems as long as you stay in LabVIEW 32-bit and use the 32-bit DLL.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 9
(610 Views)

Could you review my program?
I am using the "producer/consumer" method I have some problems
1.- I have data loss when graphing with an "obtein notifier"
2. when I put filters it causes data loss

postscript: I can store data without loss, but when I want to graph "connect in parallel" in the addition of data I have data loss.
I am a student, and with this project I graduate, I would appreciate your help.

Attached 2 versions

v1- no data loss
v2- with data loss

 

Download All
0 Kudos
Message 4 of 9
(570 Views)

Well, those VIs are horrible to check. I'm not very impressed about the Cleanup Diagram (Ctrl+U) function in LabVIEW as it tends to mess up my own VIs beyond recognition, but for your VIs it is an extreme improvement.

 

Once you have cleaned up things you can actually start to debug things and see that there are many doublications and unused controls/indicators as well as race conditions with the initialization of variables.

 

- Why do you do the "bandera" evulation of the first bit twice in the loop?

- Why do you use the Get Date/Time String function twice to retrieve the same information?

- Why do you initialize the read_handle and write_handle to -1 and parallel to it also open the connection to it and write that value to the local variable of the same indicators. Since they happen in parallel there is no guarantee which is first, except a preference of LabVIEW to do initialization of values that come from constants at first, but that is nothing you should rely on, nor is it helpful to initialize those indicators when you go and set them to a value from a function right away anyhow.

 

Your problem why V2 doesn't work is however since you try to read twice from the device in the loop. One function has a timeout of 40 ms while the other has 100 ms. They are:

- Set to execute in the UI thread so will be serialized and the loop will likely have am execution interval of around > 140 ms. depending on the data rate that your device delivers.

- Setting these two functions to execute in any thread is however not the solution! You can't access the same resource from two locations at the same time. An IO port is also a resource. Depending if the DLL protects against parallel access or not you either get serialization anyhow or very weird results from seemingly inconsistent data being returned to hard crashes of the software. Nothing good can come from it for sure.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 9
(542 Views)

Good morning, apologies, the code was bigger, I'm reducing it, that's the reason there are things everywhere, in v2 I made the wrong program. sorry. I will clean it, upload it and if you can help me I will be very grateful.

0 Kudos
Message 6 of 9
(521 Views)

Hello, I am attaching the new vis, in v1new I do not have the filters or the graph and it saves the total data, which is 250 data per second, but when I put the filters and graph (v2new) I have data loss.

I attach the subvi

Download All
0 Kudos
Message 7 of 9
(511 Views)

Javo20200_1-1713550135966.png

How to solve this problem, the signals get crossed
0 Kudos
Message 8 of 9
(90 Views)

Debugging!

 

It's absolutely not clear what might cause this from your super brief description.

 

- Wiring not done well?

- Bug in your USB device?

- Programming of your USB interface wrong?

- Interpretation of the returned data wrong?

 

This and at least half a dozen other problems might be causing what you see. You'll have to debug that yourself.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 9
(70 Views)