11-26-2023 11:24 PM
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
11-26-2023 11:17 PM
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.
11-27-2023 03:11 AM
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.
11-27-2023 12:22 PM
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
11-28-2023 04:55 AM
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.
11-28-2023 11:07 AM
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.
11-28-2023 12:51 PM
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
04-19-2024 01:09 PM
How to solve this problem, the signals get crossed
04-20-2024 07:19 AM
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.