04-19-2007 03:41 PM
VB2005 Counter Input DAQmx Single
6052E and 6601. I am a vb.net programmer, not an engineer, nor did I write the original application.
- lots of deciphering and figuring out terms that I am very unfamiliar with.
6052e = Dev1
6601 = Dev2
Encodertype = x4
zIndexEnable = false
EncoderPhase = AHighBHigh
PulsesPerRev = 60
SampleClockSource = “/Dev2/PFI39”
Rate = 1000
Samples = 25
Taken pretty much straight from the example -
myTask.CIChannels.CreateAngularEncoderChannel(counterComboBox.Text, _
"", encoderType, zIndexEnable, zIndexValue, encoderPhase, pulsePerRev, _
0.0, CIAngularEncoderUnits.Ticks)
myTask.Timing.ConfigureSampleClock(sampleClkSourceTextBox.Text, _
Convert.ToDouble(rateTextBox.Text), SampleClockActiveEdge.Rising, _
SampleQuantityMode.ContinuousSamples, 25)
I have installed DAQmx 8.5 and have been reading the help and scanning the samples to try and figure these things out.
Specifically MeasAngularPositionBufferedCont_ExtClk, after calling and getting help, I was finally able to get this sample to work.
In my application, I have my own counter object that I instantiate and each of the four has its own task, CIChannel and reader. When a channel is selected, the task is configured, the channel added, the task timing configured and the task started, when the object is unselected, I dispose of the task and channel. In my gui I have a timer event and if that channel has been selected, then I call its getcurrentvalue method, which calls the reader to get value asynchronously and pumps it to a textbox. This same type of scheme worked for me with the AIChannels, but trying to get counter angular position, all I am able to get is error -200284 pretty consistently.
I have matched all my criteria to the working sample, but am unable to get a value returned. Better yet, after I start my app, even if I don’t enable one of my channel objects, I can no longer run the sample application.
I have found that after I run my application I can use the original application (which is using the DAQ Legacy) and initiate a read and then close the original application and everything is reset aka I can successfully run the sample application again.
QUESTIONS:
Is there a way to test the start trigger to determine that it is configured correctly?
I have the task set up for external timing and the clock works on the sample how can I verify this is working in code?
Any idea of why I would have to go into the original application in order to get the sample to work again?
Any know of other vb code examples that might relate that you could point me to?
Thanks for any help
CM
Well, time to get back to the frustration...04-20-2007 02:05 PM
Hi,
Is there a way to test the start trigger to determine that it is configured correctly? - Where are you using a start trigger? - I didn't see a mention of it in your description. When troubleshooting triggers I ussually end up checking 3 things. First, I confirm that my physical trigger source is outputting a TTL signal. Second, in Max I do count events on the PFI line I have the signal connected to in order to confirm my connections. Third, I try a simple example - if it will trigger in the example, then it will trigger in my code as long as the call is made with the same settings and configurations.
I have the task set up for external timing and the clock works on the sample how can I verify this is working in code? I would start with the first two steps from above. In your case, PFI39 is an actual enoder signal if I recall correctly. With the error that you receive, -200284, one of the causes of that is when there is not external clock signal (do a quick search on ni.com for "200284" and check out the first link) - is your encoder moving when you take these readings? If there is no clock signal present, then the task will not latch in values. One good way to work around this is to use another one of your counters to generate a pulse train and use that output as a clock signal instead of PFI 39. Also, if you just want to grab single values, you don't have to do a buffered acquisition - you can figure timing for "on demand" and not have to woory about clocked values. Either method should work.
Any idea of why I would have to go into the original application in order to get the sample to work again? That ones a little tougher. If somehow you are leaving the task in an undefined state (not stopping and clearing) it can cause some issues with the next iteration. You may want to try reseting the device at the beginning of your program.
Any know of other vb code examples that might relate that you could point me to? I think you're already looking at a good shipping example, you may want to try modifying that before trying different setups in your application.
Hope this helps, please don't hesitate to post back to this thread with additional questions,
Andrew S
National Instruments
04-20-2007 04:18 PM
04-23-2007 05:09 PM
Hi,
I usually only have to confirm if my source is outputting a trigger if steps if I can't get any sourt of response in MAX. If you are able to count up on the correct PFI line, then you have confirmed that the trigger source is generating.
With a test panel, the "Mode" drop down box should have "Pulse Train Generation" and "Edge Counting" - if one or both are not present, what version of DAQmx do you have? (MAX>>Software>>NI-DAQmx)
For Ondemand, I was thinking of setting the sample timing type to Ondemand instead of continuous. You could take out the timing call completely, or just change the mode to on demand
myTask.Timing.ConfigureSampleClock(sampleClkSourceTextBox.Text, _
Convert.ToDouble(rateTextBox.Text), SampleClockActiveEdge.Rising, _
SampleQuantityMode.OnDemand, )
You could also configure one task for ondeand reads, and another for your continuous so you don't have to reconfigure just one.
Reset is from the NationalInstruments.DAQmx.Device class. If this doesn't work, does resetting the tradtional DAQ driver help (MAX>>Devices and Interfaces right click Traditional NI-DAQ (Legacy) and select Reset Driver for Traditional NI-DAQ.
Hope this helps,
Andrew S.
04-23-2007 06:21 PM
04-23-2007 06:22 PM
04-24-2007 02:51 PM
04-25-2007 02:54 PM
Next
Update:
I have isolated the cause of the malfunction...!
I am using a com obj to control a servo motor (com6svr). This obj connects and
then you can send it commands using either the write or write blocking after it
has connected to the motor. So I have tracked the "error" down to
after the obj has connected, and I use the write blocking command. That is when
the sample app will no longer receive values. I have verified that the
sample app still gets values after the obj has connected, but before that write
blocking is sent. I have verified the settings of that com object and tried
different connect statements all to no avail. Sad thing is that the obj appears to be working just fine and the NI Driver for the analog channels is working also, only the counter channels seem to be affected by this.
I am out of ideas at this point.
I fear that my only option to continue my project would be to use the legacy
driver with .net, which should work, but would mean scrapping a lot of
time/energy already invested into utilizing the new driver.
I would be interested in any other suggestions if anyone else has any....
Thanks again,
cm
04-26-2007 02:14 PM
What kind of communication does that com6svr use (serial, usb...)? I still suspicious that we're not getting our clock signal. What I would try is to open the "Generate Continuous Pulse Train" example and have it generate at ~100 hz on ctr2. Start up the Measure Angular Postion Buffered Continious External Clock example, and specify counter 0, and the Sample Clock source as PFI28 (Ctr 2 out for the 6601). With this setup, do you still see problems with your other calls? Does this work for you? This is how you would traditionally perform a buffered counter operation - generate a clock signal and latch in values on each clock edge. This should return, independent of the motor moving, and may resolve this issue.
Let me know if this works for you.
Andrew S
04-27-2007 10:22 AM