Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I wire two PWM outputs of Accelerometer into PCI-MIO-16E boad with SC-2043-SG?

I have been using counter/timer pin since the accelerometer (ADXL202AE, Analog Device) provides about 550Hz PWM signal. The purpose of the project is:

- To acquire PWM signals with Full cycle(ms) and Posity duty cycle(ms) generated in Accelerometer.

- To convert the cycles into acceleration value.

By using counte/timer(GPCTR0_Source) and Trigger(Trig1) on SC-2043-SG board, the signal was obtained.
However, after converting the PWM signal to acceleration value and plotting with labview on-line, the sampling rate was pretty low (26-28samples/sec).

Then, I began to doubt that there is a wrong wire connection. Even though I am using one counter/timer pin, the sampling rate
was low. The purpose of using the acceleration was to obtain two output using two counter/timer pins.

Could anyone help me wire pins and solve the problem?

GINO.
0 Kudos
Message 1 of 4
(3,770 Views)
Hi Gino,

Let me make sure I understand your question, and please correct me if I'm wrong. It seems as though you want to acquire a PWM signal that will have a varying positive duty cycle. You want to convert this varying duty cycle into an associated acceleration value depending on how fast the duty cycle will change.

Assuming this is correct, you will probably not be able to sample you pulse fast enough using analog inputs. I'm not sure which PCI-MIO-16E board you have but the fastest our E-1 can sample is 1.25MS/sec.

So you are correct in that you are going to need a counter to measure the pulse width (duty cycle) of your PWM signal. Since your signal is set to a fairly fast frequency you'll need to set the source of the counter to the internal 20M
Hz timebase and then set the gate of the counter to your PWM signal. This way the counter will use the internal timebase to start counting when the PWM signal goes high and stop when it goes low. You can continuously count these pulses on the PWM signal to determine your varying duty cycle.

I'm not sure if you're using LabVIEW, C, or Basic, but there are shipping examples in each. You will want to look up the examples called "measure buffered pulse" which measures only when the TTL signal is high, or "measure buffer semi-period" which measures the TTL signal when high, then measures the TTL signal when low. All these measurements are placed in a buffer which you can read.

Please take a look at these shipping examples and let me know if you have any other questions.

Erick D.
NI Applications Engineer
0 Kudos
Message 2 of 4
(3,770 Views)
Thanks. You're correct. As you suggested, I am using labVIEW example called "measure buffered pulse". The measurement seems to be placed in a buffer.

Is that the reason that sampling rate was low?
I expected to acqure a lots of signal data samples in 1 second, for example. But the sampling rate is 26-28samples/sec.

Even there happens error indicating -10920.

For a detail example, I am attaching the program based on the example that you mentioned.
I want you to have a look through my program and
give me feedback if you are available.

Thank you.

Regards,

GINO.
NC State Univ.
0 Kudos
Message 3 of 4
(3,770 Views)
Gino,

You should definitely be getting many more values in your buffer. You should actually be getting 500,000 values every second because a measurement is being taken for every pulse. I found a couple knowledgebases that describe error -10920 and how to remedy it. One is pasted below and the other can be found through the link.

But I'm not sure if you're going to be able to fix this problem because you're measuring pulses at a very high rate. What is happening is every time a pulse width measurement is taken it is put into an onboard (DAQ board) FIFO buffer that is 9 samples long. The computer then reads these samples out of the FIFO and into an a buffer that you can see in LabVIEW. I think the FIFO is filling up too fast and the computer is not able to read the data out fast enough. Therefore you are losing samples because they are being overwritten. This is all dependent on your system.

Here are some benchmarks for pulse measurements:

The following numbers were derived from a Gateway with 128 MB-RAM and an Athlon 700 for ONE counter of the PCI-6602. The number of counters you are using will affect these numbers.

Finite Buffer
Buff Period - 7.25 MHz
Buff Pulse Width - 7.25 MHz
Buff Semi-Period - 3.35 MHz

Continuous Buffer
Buff Period - 250 kHz
Buff Pulse Width - 250 kHz
Buff Semi-Period - 140 kHz


You should still be getting many more samples than 26 though. Try using this example with a very slow frequency pulse to make sure it operates correctly. Then start speeding up the pulse and determine when you get error -10920.


Here is an internal knowledgebase that may help you:

Title:
After Long Periods of Acquisition with AI and Counters, a -10920 Error Occurs

Problem:
A customer has a PCI-MIO-16E-4 and his application is acquiring analog input signals and performing event counting with the buffered event counting mode. The problem is that the buffered event counting is at some arbitrary amount of time (e.g., after 2 days) getting an error with the number -10920. The questions are:

1. Why is he getting this error?
2. Do you know how big the FIFO is for this buffered event counting?
3. When he shares a DMA channel with the floppy controller, how can we make sure they use separate DMA channels?



Solution :
Here are the answers to the above questions:

1. There is probably just some noise on the signal line coming in at some point. The STC is VERY sensitive, so if there is any fast glitching, it will attempt to transfer all of these. This can also happen if the signal does not ramp up fast enough, resulting in double-triggering in the middle region. Use a filter, or a Schmidt trigger*, to clean up the signals. Another suggestion is to use the PCI-6602 with filtering.

2. There is no FIFO used for the counters. The mMite has its own FIFO, but it is only about 9 samples long.

3. PCI does not "share" DMA channels. It may technically be the same DMA channel number, but this is just for reference. PCI cards use Bus Mastering. With Bus Mastering, the operating system gives up control of the PCI bus so that the hardware (in this case, our DAQ board) can handle its own data streaming, eliminating the extra step of having the OS monitor the transfers. The DMA channel numbers are just the "channels" that are supported by the mMite chip. You can have 3 PCI cards in the PC, each with DMA 1, 2, 3, and none of them will actually be sharing any resources.

And another knowledgebase about error -10920
http://digital.ni.com/public.nsf/websearch/8FB9091CB9BB452B8525642000554799?OpenDocument

Hopefully this all helps,

Erick D.
NI Applications Engineer
0 Kudos
Message 4 of 4
(3,770 Views)