10-04-2010 11:53 AM
Hello, I am writing a vi for a usb mouse interface to measure velocity when the mouse is moved. It seems to work, however after a certain period of time the signal degrades into complete noise or seemingly so. I have attachted my code here, I am wondering if anyone can reproduce the problem, and what could be possible solutions to the degradation, I know it is a real problem code wise since I have tired to isolate as many possible external influces as possible.
Let me know if additional information is needed.
10-04-2010 04:18 PM
I cannot test your VI because I do not have suitable hardware.
Since the Analog Read VI is outside the loop and it reads one point, your conversion to an array and then integrating one point does not make any sense.
Next you are mixing many different numeric representations: U8, I8, I32, U32 and DBL. Maybe it is OK, but there may be opportunity to make conversion errors.
You are building arrays inside the while loop. This can cause memory allocation problems and can result in crashes or slowing of the program.
You close the VISA session in the Record Movement case inside the loop. Does your interrupt work correctly after that? You have the error cluster wired, but you do not check that error. You may be processing default data out of the Error case after the first loop.
Lynn
10-05-2010 12:57 PM
I have fixed some of your suggestions however it had no effect on the degradation of the signal. Since I have yet to find a work around, I am merely outputting a saved recording of the signal without going through DAQmx. It seems to work well without the output, which to me seems like a hardware (wires, card, shielding) problem. I have tested all incoming signals and changed cards (6221) and the bncs with no effect. So it seems to be a code problem, and since it starts out fine each time the program runs, I believe it must be something involving the data acquisition via DAQmx and time loops .
Nonetheless I have one last problem, which I believe is trivial yet beyond my intuitive understanding that being how to control a time loop with an external trigger. In other words I want to program to be running always but only start the loop if and only if PFI0 is set to an edge.
It seems to me that there is no direct way of doing this, I have found within DAQmx a digital counter with an edge, but I do not need a counter, only a trigger to start/stop the loop.
Thank you for your time,
DB.
10-05-2010 04:14 PM
I have one last problem, which I believe is trivial yet beyond my intuitive understanding that being how to control a time loop with an external trigger. In other words I want to program to be running always but only start the loop if and only if PFI0 is set to an edge.It seems to me that there is no direct way of doing this, I have found within DAQmx a digital counter with an edge, but I do not need a counter, only a trigger to start/stop the loop.
That sounds like a great application for a state machine architecture using the level of your digital line (no counter necessary) as the case selector to determine each subsequent state.
Hope this helps!
- Greg J
10-05-2010 05:09 PM
What specific I/O do I use for a trigger (a DAQmx one)? How can this be set up?
I will look into state machines for now, although I am not familiar with the process seems simple enough though.
Thanks for the suggestion.
10-06-2010 01:07 PM
Are you trying to use the state of your PFI line to trigger another DAQmx acquisition, or are you just wanting to execute various code depending on the state of the digital line.
- Greg J
10-07-2010 08:59 AM
I merely want to execute the timeloop iterations when the digital line (trigger) edge is detected, without the need of additional DAQmx outputs...
-DB
10-08-2010 12:31 PM
Hi DB,
Check out this forum... it seems to have an example that may be what you're looking for.
- Greg J