Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

two counters using 6602 synchronously

I am interested in two things: 1.Linear Position of motor using counter channel ( refering to counter example: AngularPosition-buff-count.C)

                                               2. Digital pulse train output for each pulse of motor output using counter channel ( refering to counter example digpulse.c)

I am using PCI 6602 and not interested in two DAQmx since we have to use them for other purpose in similar system. 

 

If I would run each program individually, it runs fine, but I want them to use synchronously. I followed sample code for synchronization. I am confused with following things:

1. how does GetTerminalDeviceNamewith Prefix help in synchronization?

2. Program 1 above needs external clock, but program 2 doesnt, then how can I achieve one same system clock?

3. What are the key things to do for synchronization?

4. Is it at all possible to synchronize two counters on 6602 board? 

 

Please advise as early as possible  

 

0 Kudos
Message 1 of 12
(4,561 Views)

Hi sonyProj,

 

To answer your questions...

 

1. The purpose of the Get Terminal Name with Device Prefix is to take a task and a terminal and create a properly formatted device + terminal name to use as the source of the trigger for the synchronized task.

2.  Program 2 does not require a system clock, but you can include one.  Specify the same source as that used for program 1.

3.  Check out this Developer Zone Tutorial.

4.  If you mean is it possible to synchronize the counter tasks, then the answer is yes.

David
Applications Engineer
National Instruments


Digital Multimeters
0 Kudos
Message 2 of 12
(4,537 Views)

Thank you David for your reply.

 

In responce to your answer 2.

I understand that I can route system clock through the software, and I did that. But on the line of "start task" for digital pulse channel, it gives me error of "resources reserved"!

Btw, I am using digital pulse with retriggerable property and trigger source as channel A from the motor which is same channel A input to Linear position counter 0. I am using counter 0 for Position and counter 1 for pulse output. But both have same inputs.

Do counters on 6602 have any such specifications which I am not understanding here?

 

0 Kudos
Message 3 of 12
(4,532 Views)

Hi sonyProj,

 

The resources reserved error is an indication that two separate tasks are attempting to access the same resource (eg a counter input channel).

David
Applications Engineer
National Instruments


Digital Multimeters
0 Kudos
Message 4 of 12
(4,510 Views)
As I mentioned earlier, I am not using single physical channel for two tasks. channel 1 is dev1/ctr0 and channel 2 is dev1/ctr1. I hope that doesnt mean single physical channel.
Message Edited by sonyProj on 04-12-2009 07:23 PM
0 Kudos
Message 5 of 12
(4,494 Views)

Hi sonyProj,

 

Please attach a screenshot of the error message as well as the code around your DAQmx start task.

David
Applications Engineer
National Instruments


Digital Multimeters
0 Kudos
Message 6 of 12
(4,479 Views)
Message Edited by SP.Srinivas on 04-13-2009 01:41 PM
0 Kudos
Message 7 of 12
(4,473 Views)

Hello David,

 

Thank you for your suggestion. I have attached code herewith. 

1. startcallback() function creats and starts the  Linear position task

2. Timer2 is enabled always. Once the linearposition task is generated, Timercallback() function  reads channel and popoulates motor position data in text box . 

3. populatemeasurement() function creates new task for digital pulse and supposed to generate 'n' finite pulses for each pulse in the motor output and display as couter1 output.  

 

I was also trying to create pulse task in timercallback(), but it still gives me following error. 

 

"NON-FATAL RUN-TIME ERROR:   "commcallback.c", line 1104, col 9, thread id 0x00000D2C:   Function DAQmxStartTask: (return value == -50103 [0xffff3c49]). The specified resource is reserved. The operation could not be completed as specified. Task Name: _unnamedTask<1>  Status Code: -50103"

 

Regards,

Download All
0 Kudos
Message 8 of 12
(4,465 Views)

SP,

 

Do you change the default values on your FP?  I noticed that in the example program you probably got the code from:

DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI9",DAQmx_Val_Rising));

 

But in yours:

DAQmxCfgDigEdgeStartTrig(taskHandle,triggerSource,edge) where triggerSource appears to be = /Dev1/PFI35

 

Did you mean to have this as PFI35?  I noticed you had the clock source going to PFI9 is this what you intended to do?

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 9 of 12
(4,441 Views)

Hello Jason,

 

Thank you for your reply. Yes, PFI9 is system clock. I am using this as a system clock for ctr0

 

But I am interested in getting ctr1 to be triggered by motor's output, hence I have mentioned as ctr0/PFI35  i.e source input to both ctr0 and ctr1 and not to get triggered by system clock.

 

I hope it helps you to understand.

 

0 Kudos
Message 10 of 12
(4,437 Views)