LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx internal signal routing for counters

First - I am new to DAQmx and I am NOT A LABVIEW programmer, strickly Windows CVI, v8.5.
 
I need to measure the acceleration time of a DC motor (time period of first three revolutions after power is applied).
 
Platform - "M" Series DAQ PCI-6289 using DAQmx, v8.6 and WindowsCVI, v8.5.
 
DC motor has a 1800pulse/rev optical encoder coupled to its shaft.  Motor current is measured by reading voltage drop across a resistive shunt in series with motor leads.  It is desired to also measure motor terminal voltage but the attached example is not doing this task at this time.
 
Methodology used:
Setup a voltage measurement task with an analog level trigger that will start the current sampling and gate the internal 32-bit counters on the PCI-6289.  Counter [0] is setup for edge counting.  Its source is the optical encoder output. Setup a Pause Trigger on its gate using the "AnalogComparisonEvent" internal signal.  Preset counter [0] for 5400 (three motor shaft revolutions).
 
Up to this point the code seems to function without any errors.  
 
Counter [1] is setup for two edge seperation counting.  Its source is the 20Mhz internal timebase clock.  The first edge is to be gated by the "AnalogComparisonEvent" and the second edge is gated by the counter [0] "Ctr0InternalOutput" signal.  Thus this counter will measure the acceleration time commencing the count simultaneously with the analog trigger signal and ending after three full revolutions of the motor shaft.
 
When I try to use the "DAQmxConnectTerms" function I get various errors all with the code -89137 saying that resources I am trying to to route are already in use.  But have not allocated any of these resources so I don't understand why I am getting these messages.
 
Attached to this message is the source code for this application.  Any help will be greatly appreciated.  Would also like to know of any resources that may be out there for CVI programmers trying to use DAQmx.  I already have read all of NI DAQmx and CVI help and PCI-6289 User Manual.  Trust me, I am still very confused how to properly implement DAQmx in CVI code.     
 
Download All
0 Kudos
Message 1 of 8
(6,809 Views)
Hello Ron G,

Thanks for your post

I see that you are using the PCI-6289 and
0 Kudos
Message 2 of 8
(6,777 Views)

Sorry about that, my last post didn't go up right.

Hello Ron G,

Thanks for your post

I see that you are using the PCI-6289 and you are having some trouble with your counters.

First I would like to refer you to some great resources that are on the ni.com website.

Using NI-DAQmx in LabWindows/CVI

Learn 10 Functions in NI-DAQmx and Handle 80 Percent of Your Data Acquisition Applications

So I see that you are routing the 20MHz clock to the source of ctr1. If the input you are trying to count is to the gate of that counter then DAQmx should automatically choose the clock to use for you so try not routing the signal manually. When you get this error, what specified routes is it telling you are in use? Could you post a screen shot of the error given?

Please post back if you have any other questions.

Corby_B

 
0 Kudos
Message 3 of 8
(6,767 Views)

Hello Corby_B;

Thank you for your response.

I have managed to resolve the resource errors that I was getting.  Apparently what was happening is the DAQmxCreateCITwoEdgeSepChan() was automatically selecting these same resources that I was then trying to manually confgure.  By using the DAQmxSetChanAttribute() and referencing the assigned taskhandle for this channel I got all of the rersource errors to go away.  However my application still does not work!

Presently I am trying to figure out just what signals are truly present.  If I use the default terminal connections for counter measurements and can't seem to get any logic levels on the PFI terminals.  For example I am trying to use Ctr0 output as the second signal input to Ctr1, (tied to its Gate).  When I connect scope probe to its default output terminal on PFI12 I fail to see any signal output after I have started the acquisition tasks.  I can read the motor current and read the Ctr0 output register but cannot see the Ctr0 output signal in hardware.

Attached is the latest souce code listing of my application.

I did try routing the 20Mhz clock to the source of Ctr1 using tge ChannelAttribute() which ran without errors.  I also tried commenting this function call out, but it made no difference to my none functioning application.

 

  

 

 

Download All
0 Kudos
Message 4 of 8
(6,682 Views)
Hello Ron G,

Thanks for your post back! Glad to hear that you were able to get rid of your other errors. So if I read you correctly you are not able to see the output of your ctr0 input task on ctr0 output. This is actually a true result. Since you are using ctr0 as an input counter then the output of that is also internal and you will not see this on the ctr0 output. This pin is reserved for when you are generating finite or continuous pulse trains. So since you are wanting to use the "output" of counter 0 which is an internal output then I would suggest routing the signal internally using the "int32 DAQmxConnectTerms()" function. So I feel that in your case you are wanting to route the "internal output" of ctr 0 to the gate of ctr1. For this function there is a "source terminal" and a "destination terminal", so use "DevX/Ctr0InternalOutput" for the source and make "DevX/Ctr1Gate" as the destination. This will route the "internal output" of ctr0 to the gate input of ctr1.

Let me know if this is what you were looking for.

Cheers!

Corby_B
http://www.in.com/support
0 Kudos
Message 5 of 8
(6,644 Views)
I tried directly routing the output of Ctr0 the the gate of Ctr1 as you can see in my original source code listing.  This resulted in one of the resource allocation erros that mentioned in my first post.  Below is a partial listing of my new code that I just posted three days ago.  It does not yield any resouce errors but it doesn't work either.  It shows that I am setting up a two edge seperation channel on Ctr1 and then by using the SetChannelAttribute() I am assigning the Ctr0 output as my second edge input into this counter (Ctr1 - gate).  My first edge is the analog trigger event that I am also using as a gate signal into Ctr0.  Can I use this internal signal in three places?  First being the Analog Voltage Read trigger, the second as the Ctr0 paused gate control for edge counting, and the third for the first edge signal on the edge seperation channel(Ctr1 - aux).  Please read the 'c' listing I posted three days ago.  The comments and code do a much better job of explaining what I am trying to accomplish.
 
Is there another way I can get direct support from National in trying to resolve this issue.  We (my company and its customer) are at a point of having to choose another data acquistion source if we cannot get this to work.  This seems like such a simple task but is extremely difficult to implement with the limited resources available for CVI implemeting applications using DAQmx.  Is there a comprehensive description of the DAQmx library functions and properties related to various predifined parameters?  I have not found it in DAQmx help, CVI help, nor the .fp help dialogs.   Would it be better to puchase the DDK for M series boards and develop my own register based driver for this board?  So much of DAQmx seems to be Labview oriented and the CVI functions hide so much of the board functionality that it is difficult to know what is really going on.   
 
 /**************************************************************************************
      // DAQmx Configure Code - Motor TIME
         -creates task for acquiring acceleration time of first three motor revolutions.
         -set counter [1] for two edge seperation counting.
         -use internal 20Mhz clock timebase as the source input for counter [1].
         -use "AnalogComparisonEvent" as the edge that starts timebase coount.
         -use internal output of counter [0] to stop counter [1].  This will occur after
          counter [0] has reached an internal down count of zero (after three revs).
       **************************************************************************************/
      DAQmxErrChk ( DAQmxCreateTask("",&taskHnd_TIME) ); 
     
      DAQmxErrChk ( DAQmxCreateCITwoEdgeSepChan(        taskHnd_TIME,
                                                         "Dev1/Ctr1",
                                                                  "",
                                                              0.0001,
                                                                 0.5,
                                                   DAQmx_Val_Seconds,
                                                    DAQmx_Val_Rising,
                                                    DAQmx_Val_Rising,
                                                                  "" ) );
     
      //DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_TwoEdgeSep_FirstTerm, "/Dev1/ai/StartTrigger", 0 );
     
      DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_TwoEdgeSep_FirstTerm, "/Dev1/AnalogComparisonEvent", 0 );
     
      DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_TwoEdgeSep_FirstEdge, DAQmx_Val_Rising, 0);
     
      DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_TwoEdgeSep_SecondTerm, "/Dev1/Ctr0InternalOutput", 0 );
      DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_TwoEdgeSep_SecondEdge, DAQmx_Val_Rising, 0);
     
      //DAQmxSetChanAttribute( taskHnd_TIME, "", DAQmx_CI_CtrTimebaseSrc, "/Dev1/20MhzTimebase", 0);
     
0 Kudos
Message 6 of 8
(6,613 Views)

Hello Ron G,

Thanks for your post back! I apologize for the delay in the response. Your question " Can I use this internal signal in three places? " is yes if you look at the device routes in Measurement and Automation Explorer (MAX). If you right click on the device in MAX you can see the "device routes" tab that tells you what signals can be routed where. According to this route you can make the direct connection of the Analog Comparison Event to almost every port available. So what I am going to do is get a PCI-6289 and try out your program. I was able to simulate the device and then run the program, as you mentioned I do not get any device route errors of any kind or any other errors for that matter. So I don't have any hardware at the moment to simulate your situation. You say the program doesn't work but do you at least see the analog trigger happen and then ctr 0 begin to count down? Is the major problem here that ctr 1 is not performing as you expect. I was also able to recreate your code in LabVIEW without any errors there either. As I mentioned I will be able to get a PCI-6289 today and try this out for you. I will let you know with a post back. I will simply use a function generator to simulate the input coming from your motor encoder.

Something to try is to simply export the Analog Comparison event to a PFI line that you are not using already and physically connect the signal to the counters externally with wires.

You could use DDK to develop a driver of your own for the M-series board however this is not supported by National Instruments and could be difficult if never done before.

Also you mentioned if there was a better way of getting direct support from Nation Instruments.  You can talk directly to Applications Engineers if you have an SSP support contract.

I will let you know my findings once I am able to perform a test with the card you are using. I know this seems difficult but we will work together to come to a solution to your application.

Cheers!

Corby_B

 
0 Kudos
Message 7 of 8
(6,540 Views)
Hello All,

Just wanted to post back with my findings!

There is no problem using the Analog comparison event in many different places as in Ron G's code.

The original problem was that the code posted above was not able to get the time between the two rising edges. To fix the problem instead of performing a using the following line:

DAQmxGetChanAttribute( taskHnd_Time, "", DAQmx_CI_Count, &Ctr0Data );

Use the actual read when taking a two edge count separation reading. This allows the hardware to convey the time it actually takes to get the two rising edges.

DAQmxReadCounterScalarF64 (taskHnd_TIME, 10.0, &Ctr1Data, 0);

It was great working with you Ron G and I wish you the best of luck on your applications!

Cheers!

Corby_B
http://www.ni.com/support

0 Kudos
Message 8 of 8
(6,434 Views)