From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-06-2014 11:21 AM
Hi all,
I'm trying to build a vi to control a micropositioner (via .net calls), and a camera via TTL pulses, and simultaneously save the analog outputs of when the camera actually fires. My first thought is to use a timed loop to issue the .net commands (move to a series of positions defined in an array) and try to synchronize this with the ctr0 clock doing the ttl output, but I am confused on two points:
1. The easier question: I can use a for loop with a 10ms delay to step through the positions defined in the array, but I'm pretty sure that I can't just put this for loop within the timed loop since I need to send a ttl output at each iteration of the for loop. Am I correct in thinking I should just use the timed loop iterator to step through the array?
2. The bigger question is synchronization. How do I sync daqmx with the timed loop moving the positioner? Previously, I've made the camera take many frames by setting up a counter output to output a train of TTLs while acquiring the analog inputs using the counter channel as a trigger for acquisition start. Should I modify this code to output a single TTL pulse, aquire and store a short waveform within a parallel timed loop using the same timing source as the counter output? Or should I set up a separate acquisition sequence outside the original timed loop which moves the positioner?
Thanks,
Rishi
02-07-2014 11:11 AM
So, I've gotten as far as getting the timed loop to loop through the array of positioning calls, and have gotten a counter output task to output the correct number and frequency of pulses while sampling the analog input channels. But, whenever I try to synchronize the timed loop with a 'create timing source vi', I get a 50103 error. This happens if I use the control loop from task subvi using either counter output or analog input task as the source, or if I use the frequency subvi and point it to the counter output channel I am using for pulse train generation. Any ideas on the correct way to synchronize these processes?
Thanks....
02-07-2014 05:48 PM
Hi! It might be easier to debug if you attach your actual code rather than a screenshot. Which DAQmx Start Task is throwing the error? You may have already seen this KB but it goes over various reasons you might be receiving the error.
http://digital.ni.com/public.nsf/allkb/485201B647950BF886257537006CEB89?OpenDocument
02-09-2014 02:17 PM - edited 02-09-2014 02:19 PM
Here's a version of the code I tried using a control loop from task vi for synchronization with the task clock being provided by the analog acquisition task. This version, however, causes a blue screen of death. So, it's definitely not the right code. I've also tried providing the task clock from the implicit counter timer being used for pulse train generation. This seems to synchronize the ttl output and timed-loop, but the timed-loop doesn't run after the first time the code is called. Sorry for the lack of comments in the code diagrams. I'm a bit new to G....
I did come across the document on 50103 errors, but I can't tell whether my code is failing because of a case 3- or a case 7-error....
Thanks,
Rishi
02-10-2014 10:02 AM
The problem could have to do with not closing references, but the error is being thrown by your DAQ task. Can you try copying your counter output and analog input tasks to a new VI to see if you can run them successfully?
02-10-2014 11:59 AM
Hi Rob,
Here is a temporary vi with the sampling and output code. Both tasks work as expected. The only issue arises when I try and synchronize these tasks with the timed-loop in the code I posted previously.
Thanks,
Rishi
02-10-2014 04:44 PM
As I was alluding to earlier, it definitely has something to do with not closing references, i.e., I can get them to run synchronously if I use an additional counter (ctr0 for digital output and ctr1/2/3 for the timing loop) and the frequency version of the create timing vi, but it doesn't work the second time the code is triggered. I think I just need to create an addition counter task and close it when the other tasks close?
Rishi
02-11-2014 06:00 PM
Rishi,
Could you try running your code in highlight execution and let me know what your findings are? That may help to pinpoint the source of the error.
02-12-2014 11:48 AM
Without attempting to synchronize the timed loop with the acquisition tasks, highlight execution mode simply confirms that the acquisition and output tasks begin before the loop. I've attached the current version of my code. What I am still trying to figure out is how to ensure that the TTL output pulse occurs synchronously with the .NET invoke node that calls the MM_set function (within the timed loop)?
Thanks for the input,
Rishi
02-13-2014 12:45 PM
Rishi,
In terms of synchronizing the tasks, the best way to do that would be to enforce execution order by using appropriate error wire routing. I would also recommend moving your AI DAQ task into the previous frame of the flat sequence structure and moving everything up to your "DAQmx Start,vi" into the previous frame as well. This will ensure that your DAQ tasks are both set up before you call your .NET code and the counter output task will start as close as possible to the .NET call.
Let me know if this change affects anything.