07-23-2010 07:25 PM - last edited on 02-26-2024 11:33 AM by migration-bot
Hello,
I've set up my PCI-6259 with an angular encoder counter, as per the C code example at http://zone.ni.com/devzone/cda/epd/p/id/5735
This appears to work great, but I would also like to use my PCI-6259's digital lines to control a TTL switch on the encoder it's measuring (among other things). If I set up a separate task in the same program and install a new DOChan to the task, it works great: I can control the TTL and measure the encoder position at the same time.
However, I would like to be able to control the digital lines, e.g., via a script, while leaving the encoder readout running continuously. I tried running the angular encoder counter example code, and while it was running, I ran the dio/writeDigPort example.
First of all, the writeDigPort took about 3 times longer than usual to run. It wrote to the digital line successfully, but as soon as it had, it corrupted the counter somehow. The angular encoder example began to spit out garbage, rather than the measured angle.
Is this just a limitation of nidaqmxbase, wherein I cannot use the PCI-6259 resource from multiple processes? I can imagine this being the case, since I think the counter setup is using a DMA.
Or is there a workaround? Any advice is much appreciated, thanks!
-Chase
07-27-2010 11:39 AM
Hey Chase,
Could you tell me which digital lines are you using? Can you try using another counter as a test?
07-27-2010 02:56 PM
Dear Chase,
One of the limitations of DAQmx Base is that while you can run tasks simultaneously in your hardware, running tasks simultaneoulsy in software (LabVIEW ) is not supported. This means that you must use your error wires in LabVIEW as well as any other programming structure that will prevent tasks to run simultaneously in order for them to run successfully.
07-27-2010 02:59 PM
For the counter/angular encoder, I'm using the following lines:
PFI 8 -> Encoder ch. A
PFI 9 -> Encoder ch. Z
PFI 10 -> Encoder ch. B,
as documented in Table A-22 in the M Series user manual. These correspond to the virtual ctr0 port in software.
As the DIO switch, I'm using lines P0 and P1 (I have two switches.) These correspond to the virtual port0 port in software, e.g. to turn both on I am writing 0x3 to port0.
I will try setting up the angular encoder on the ctr1 port and report back with the result.
Thank you for your interest in my issue.
-Chase
07-27-2010 03:02 PM
Hi Efrain,
Sorry, looks like we posted at about the same time. My last post was in response to your previous inquiry.
Thanks for the information. However, I'm using nidaqmxbase (not LabVIEW). I'm not quite sure what to make of your advice... is there any way you can 'translate' it to nidaqmxbase/c-api terms?
07-28-2010 02:18 PM - last edited on 02-26-2024 11:34 AM by migration-bot
I think what was meant is that DAQmx Base is not multi-thread safe. From the readme:
NI-DAQmx Base is not multi-thread safe. In LabVIEW, use the error cluster to
force execution order. In C, use only one thread to make API calls; especially
for task/channel creation and deletion.
So, if using DAQmx Base, all of your functions should be in the same thread (i.e. don't make parallel calls to the driver).
Having said this, I notice you're using the PCI-6259 which is supported in DAQmx for Linux. You didn't mention what OS you're using, but if you are able to use the full version of DAQmx I would recommend doing this. DAQmx is multi-thread safe, and provides more functionality and better performance than DAQmx Base.
Best Regards,
07-28-2010 02:29 PM
Thanks John, I missed that bit about thread-safety in the docs.
I am in fact using Linux. Unfortunately, I'm using the (inexplicably) unsanctioned Ubuntu distribution, so DAQmxBase took a bit of tweaking to work.
Unless there are resources for hacking DAQmx to work on Ubuntu, I'll probably just have to write an event-loop server to give a single point of access to my card.
-Chase
07-28-2010 05:33 PM - last edited on 02-26-2024 11:35 AM by migration-bot
There are some good resources in the Linux Users Group on the ni.com Community Site (for example: NI-VISA and NI-KAL on Ubuntu Karmic and Lucid).
I haven't personally installed DAQmx on Ubuntu, but for now I'd suggest posting to the Users Group to see if anybody over there can offer more specific advice.
Best Regards,