Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire AI signals and Ctr signals from PCI 6221 M Series,

Hi,

          I’m trying to make a VI to get different types of signals at the same time. The Multi-DAQ that I am using is PCI-6221 M-series. The signals that I’m trying to get are as follows.

 

     - Voltage signals                                              à       3 Analog Input channels

     - Signals from motor encoders (to get motor angular speed)

                            à       2 Counter Input channels

       

         How can I make sure that I will get those signals synchronously? This is very important as I run the whole system simultaneously and must be sure that I get all the correct signals at any particular point of time throughout the whole operation.

         Do I need to use Multi-function Synchronisation VI to achieve this?

 

 

     Suksun

0 Kudos
Message 1 of 9
(5,323 Views)

Hi,

  you want to synchronise up the acquisition of the analog and the counter readings.

I'm making the assumption here that you're using a pulse train from a shaft encoder and you need to tie in the voltage at every pulse generated, whilst using the counter to measure the pulse period.

You can use the incoming pulse train as the gate input for a buffered period measurement setup on the counter, and the ai sample clock for exactly when the ai aquires.

The problem with this is when each gets initialised. If the shaft is already in motion at high speed, then you'll be receiving one pulse on a setup stage (say the ai) just before the ctr stage gets setup and runs. This means your synchronisation could be out by a pulse, and you won't necessarily know, since the acquisition has to be stopped and so does the buffered period measurement, so there's going to be a lag there again, so you can't just look at the length of the data acquired, and think the longest one started first, and they finished at the same time and adjust the data.

What rate are you running at? If it's relatively slow between successive rising edges of the pulse train, then you might be lucky most of the time, since you could start both (after having initialised both tasks) within the period of the pulse, however, you could be unlucky and start say the ai first, a pulse comes in, triggering an acquire, and then start the ctr.

One option is to use the same medium for both parts, and use the ai for the speed measurement too, that way you can recreate the data.

Run at an appropriate free-running speed, and acquire the pulse train, the voltages and anything else you need.

You can then look at all the traces, and discover exactly when things changed.

The disadvantage of this is that you're time resolution is only as good as the ai acquisition rate, and you'll generate lots of data.


Since this is very hardware dependant, you could always use a counter and a digital line.

Here's my thinking :

Shaft is already running, but tied to a counter which is set for a retriggerable pulse generation on a really short pulse. This counter is gated by a digital line.

(http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=C671A9B2FB9A0EEDE034080020E74861&p_...)

The output of that counter goes to the gate of the period / frequency measuring counters and also to the ai sample clock. You setup the "measureing" counters and the ai, and start them off. Nothing will be happening at this point, since the digital line would still be low.

Now in software, you activate the digital line to high. Since this then allows the pulses to come through, you get the ai and the counters started at the same time and synchronised.

If you're using two "measuring" counters then this isn't going to work, since you'd need a third one. Also if you're measuring the pulse period and pulse semi-period, then the third counter generating the pulses would destroy this.

If this is the case, then use an external AND gate tied to the incoming pulse train and the digital line to synchronise the start.

Hope that helps.

Sacha Emery

National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 9
(5,295 Views)

Hi SachaE,

            Thank you very much for your useful information. It seems to me you suggested 3 ways to sort my problem out. The first method where the incoming pulse train from the shaft encoder is used as the gate input seems to suit my application most. I would like to ask futher questions related to that method.

      1. What does "gate input" mean? Does "being gated" mean "to set the clock"?

      2. To use pulse train from the shaft encoder as the gate input, as I will be running the shaft at different rates, the pulse train signal will then be varying. Do you think it is still OK?

      3. Can you please provide me the VI example of how to set up the pulse train as the gate input? I am quite new to Labview.

      4. You assumed that motor shaft is already in motion when we start the acquisition. What if we start acquisition before running the motor? Can we do that and is it going to help to ease the situation?

      5. The rate I am running my motor is about 250 rev/s or about 12,000 pulses/s produced by the shaft encoder. Is it OK to avoid the synchronisation problem you suggested?

      6. Could I also have VI example showing how to measure the "period" using AI pin? (Can we do this in DI part too?)

 

Thanks for your help.

          Suksun

 

0 Kudos
Message 3 of 9
(5,273 Views)

1. What does "gate input" mean? Does "being gated" mean "to set the clock"?

GATE means to allow through in a particular condition. So your pulses are only allowed through when the gate is high etc.

      2. To use pulse train from the shaft encoder as the gate input, as I will be running the shaft at different rates, the pulse train signal will then be varying. Do you think it is still OK?

That's what I think you need. Every rising edge gives you the buffered period measurement (have a look in the manual for a description of the timing of this) so you get your speed, and you get an analog input measurement at the same time if you've set it up to use an external clock (example finder in LabVIEW and go to the examples in Hardware input and output->Daqmx->Analog Measurements->voltage->Cont Acq&Graph Voltage-Ext Clk.vi) and you'll need to wire onto the clock source you specify on the front panel.

      3. Can you please provide me the VI example of how to set up the pulse train as the gate input? I am quite new to Labview.

Do you mean the pulse train from the shaft encoder as a gate to a counter doing the pulse generation again? (example link I posted last time does this) Or do you mean the pulse train from the shaft encoder as the gate to the buffered period measurement? ( Hardware Input and Output->DAQmx->Counter Measurements->Period or Pulse Width->Meas Pulse Width-Buffered-Cont.vi   and read the documentation in the vi properties)

      4. You assumed that motor shaft is already in motion when we start the acquisition. What if we start acquisition before running the motor? Can we do that and is it going to help to ease the situation?

Starting the acquisition first makes life so much easier, since both the AI and the counterside of things would be waiting on the pulses then.

      5. The rate I am running my motor is about 250 rev/s or about 12,000 pulses/s produced by the shaft encoder. Is it OK to avoid the synchronisation problem you suggested?

Not necessarily. It's more likely at higher speeds, but even at a very low speed, you could still do config AI, config ctr, start ai, pulse comes in, start ctr, and you're out of snych.

      6. Could I also have VI example showing how to measure the "period" using AI pin? (Can we do this in DI part too?)

You need to do a straight forward acquisition (say a finite one for easiness - Hardware Input and Output->daqmx->analog measurements->voltage->Acq&Graph VOltage-Int Clk.vi), and then use something like the pulse parameters.vi from the analyze->signal processing->time domain palette (do a search on the functions palette if you can't find it easily). You'll need to unpack the array of data from the waveform that the daqmx read returned, and that's on the waveform palette under get waveform components. Set it to extract the y array.

If you're very new to LabVIEW I'd recommend coming on one of the training courses.

If you decide to do this, then please contact your local office (the UK is 01635 572400) and ask for the course co-ordinator. We do courses right from beginners all the way up to advanced application design techniques.

Failing that, a good set of books are available for self learning - try http://www.Waterstones.co.uk and search for LabVIEW. Something like LabVIEW for everyone is a good introduction :

http://www.amazon.co.uk/exec/obidos/ASIN/013065096X/qid=1124903086/sr=1-4/ref=sr_1_9_4/026-5217188-8...

Hope that helps

Thanks

Sacha Emery

National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
Message 4 of 9
(5,270 Views)

Sorry missed a little off the last question

Can we do this in DI?

Technically yes, however, you have to know the timing on the digital input. Since there isn't a clock specifically for digital input, you would need to do correlated digital input, either to the analog input task you'd need to setup, or by providing an external clock (example in Hardware Input and Output->DAQmx->Digital Measurements->Cont Read Dig Chan-Ext Clk.vi).

You'd then need to search the array of values back for when it changes from false to true, and then from that point for true to false. Knowing the acquisition rate and the number of elements in the array inbetween, you can then multiple up, and get the total time the pulse was high. If you want the complete period, then look for the first low to high, then the second low to high, and apply the multiply of the time per sample x number of samples to get the total period.

Thanks

Sacha Emery

National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 5 of 9
(5,265 Views)
I want to measure two type of signal from my setup
 
One AI which is configured to CH-1
Counting Pulses from Encoder through CTR-0 and CTR-1(Common Encoder)
 
CTR-0 will count for each 20 pulse and Come out of the loop . Inside the same loop i am using DAQ assistants(Express LV) to acquire the AI Signal(One Sample on demand , Diff input)
 
 
same time one DO is connected to true condition when CTR-0 reads 20. also this is the output for that sub vi.
 
this true case is used for the case loop to get the count from CTR-1 and and get the angular reading from that.
 
encoder details is 2500 count for 360Deg.
 
Pls suggest is there any other method to acquire data from encoder and AI simultaneously. Also i need a count of how many time i acquired 20 pulses from encoder.
 
Pls check the program which is attached and suggest ........
Joe
Using Ver. 8.0
0 Kudos
Message 6 of 9
(5,236 Views)
Dear Suksun
 
Can you mail me the Source Code which you have developed for this application . Becouse i have the same type of application which need to acquire Single AI and Single Encoder output
 
You can have a look on my source code which is already posted in your reply or as the same Message subject i posted one more mail here .
 pls help
Joe
Using Ver. 8.0
0 Kudos
Message 7 of 9
(5,233 Views)

Hi Sacha,

            I really appreciated your answers and suggestions. In fact, I have been learning Labview for already 2 months. I learn by a book "Labview for everyone" and by labview example from NI.

           The thing that confuses me most is the synchronisation and sampling rate. From my understanding, the different channels (AI/AO, CTR) take in signals in at the rate set by their internal clock (hardware clock). We as a user can decide how often we want to pick those signals to be read or used by settting the sampling rate (by Labview software). This means that all the signals input via DAQ card via hardware clock for each different channels are already there but we only choose some signals to be used. By doing synchronisation of signals from different channels together, the hardware clocks for different channel types are linked synchronously. And now we can sample signals from different channel types at different sampling rates but still they are synchronised as the synchronisation was done from the hardware side (hardware clock). Is my understanding about synchronisation and sampling rate correct? If not, please clarfy it for me.

            Another important question I would like to ask is "how to test if signals from different channel types are successfully synchronised?" This is vital because we wouldn't know if our VI code for synchronisation is right unless we have an appropriate testing procedure.

            Finally, I would like to share the whole scope of my problem. My problem is classified as follows.

     - Vertical distance from Potentiometer (Voltage)                       -         DAQ PCI 6621 (M-series)

     - Opto-switch (Period between pulses)                                     -         DAQ PCI 6621 (M-series)

     - Shaft's angular speeds from motor encoders

        (Number of pulses/second)                                                     -         DAQ PCI 6621 (M-series)

 

     - 6 Force/Torque signals (Voltages)                                           -         DAQ PCI 6034E  (E-series)

            The idea is to synchronise all the signals effectively. From what I've known, to synchronise between the E-series and M-series, we need to set E-series as the master and use its 10MHz clock as a hardware clock for both devices. Can I use 10 MHz clock timebase with the digital trigger to synchronize all the signals from both devices (M and E-series).

Note : The reason I have to use E-series for Force/Torque signals is because it comes with the 6 axis Force/Torque sensor as a whole package. They also provide the Labview VI to get those Forces and Torques.  

 

      Thank you very much,

                  Suksun

0 Kudos
Message 8 of 9
(5,220 Views)

Hi,

  at this point, you'd need a rtsi cable to link the pci cards together. Then you need to export the appropriate signals from one card to another, but since you've a physical link in the system, you will have a phase lag down the cable.

Testing is best done with a known signal, such as a sinewave and a digital signal, such as a square wave 0-5V which you can synchronise the generation of to the sinewave going on the AI. That way, you can look at the real world signals going in on an oscilloscope, and then see how that looks in your code.

THe following links should help.

http://zone.ni.com/devzone/conceptd.nsf/webmain/BF5474CCECE506EC86256FA300686599

http://zone.ni.com/devzone/conceptd.nsf/webmain/6DC991028566309886256F990080A720

I would recommend you talk to one of the alliance members to do a proof of concept on this system. I can give pointers, and example code, but not develop the system as a whole.

Also, I think there's a misunderstanding in exactly how the cards work. You said :

The thing that confuses me most is the synchronisation and sampling rate. From my understanding, the different channels (AI/AO, CTR) take in signals in at the rate set by their internal clock (hardware clock). We as a user can decide how often we want to pick those signals to be read or used by settting the sampling rate (by Labview software). This means that all the signals input via DAQ card via hardware clock for each different channels are already there but we only choose some signals to be used.

The hardware takes a configuration from the software, and is not "free running at macimum rate". i.e. if you ask for 100 Samples per second, the onboard clock is divided down to match as close to this rate as possible. Once you start the configured setup, then the card starts to acquire (unless you're setup for triggered with no pre-trigger in which case no data is acquired onto the card. The cards have a small onboard FIFO. Once configured and acquiring the cards acquisition section puts the data to the FIFO, and the MITE chips are responsible for transfering that information over to system memory in as efficient a means as possible. The software reads then pull the information from the system memory buffer (which is used in a circular fashion if continuously acquireing) into the application memory, where it can be analysed by your process (application).

So in short, no the data is not already synchronised.

You can find information on the alliance program members here.

http://www.nationalinstruments.co.uk/worldwide/uk.nsf/web/all/273D2D6153EAD1CD80256E5A004837FA?OpenD...

Hope that helps

Sacha Emery

National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 9 of 9
(5,202 Views)