Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate a pulse on x number of events PCI-6602

I am running LabVIEW 5.1 full development with a PCI-6602 counter board.

 

I would like to generate an output pulse after counting x number of input pulses. I would also like to reset the counter with an external signal.

 

My application is I am trying to generate a second index pulse for an encoder.

 

I would like to count the pulses from encoder phase A and generate an output pulse on x number of counts. Then I would like to reset the counter using the encoder’s index pulse. This way I can change the phase of the “generated” index pulse with respect to the “real” index pulse by x number of counts (degrees) and maintain that regardless of encoder rpm.

 

Thanks

 

Brian

0 Kudos
Message 1 of 9
(4,976 Views)
Hi Brian-
 
The easiest method to output a pulse based on the occurrence of input pulses of another signal is to configure a counter for pulse train generation based on "Pulse Specs (raw)" using the Counter Pulse Specs VI.  This setting allows you to specify a number of ticks of your input signal to hold the counter output low (delay ticks) and high (pulse ticks).
 
 
There is no method for resetting the counter in software- if you are performing a single pulse generation you can simply restart the task, or with continuous generations you can change the settings for pulse generation on the fly.
 
Hopefully this helps-

Message Edited by Tom W. on 10-17-2005 01:52 PM

Tom W
National Instruments
0 Kudos
Message 2 of 9
(4,950 Views)

Brian,

There actually is a way to do what  you want, but it gets a little complicated.  I don't have LV on this machine so I'll have to just describe the idea.  First a summary: the counter will repeatedly countdown to 0.  Each time it reaches 0, it will generate a brief pulse which will in turn hw-reset the counter value to N.  Then it will countdown to 0 again, etc.  The same brief pulse could also be wired to a different encoder-measuring counter to create a "delayed" reset to 0 (or some other #).

1. Configure your counter for "position measurement" instead of "simple event counting".  Set the encoder type to, um, I forget the name -- something like "two pulse encoder."  It's the setting that will increment with every SOURCE edge and decrement with every AUX edge.  Wire your encoder channel A to the counter's default AUX input (in position encoder mode, you must use the default input pins).  Hard wire from the default SOURCE input to GND.  Now every encoder edge will decrement the count, and nothing wlil ever increment it.

2. Configure the counter to use z-indexing.  Set the z-index reload value to be N-1, where N is the # of encoder counts by which to delay the encoder's real z-index pulse.  Set the z-index reload phase appropriately, probably to A low B low.  Wire the real z-index pulse to the counter's GATE input.

3.  Configure the counter to "pulse on terminal count" -- you do this using 'Counter Set Attribute.vi'.  So N encoder edges after the real z-index pulse, you'll generate a pseudo-z-index with this counter.

4. You can wire this pseudo-z-index to the GATE input of the encoder-measuring counter.  Now the encoder's z-index pulse is delayed by an amount you can program.

5. Note: this method requires the motion to be uni-directional.

Good luck!

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 9
(4,939 Views)

Thanks Kevin.

 

That looks like a good idea I will give that a try.

 

I appreciate you taking the time.

 

Brian

0 Kudos
Message 4 of 9
(4,930 Views)
Kevin,
 
Is the attached image similar to what you were talking about?
 
Thanks
 
Brian
 
 
0 Kudos
Message 5 of 9
(4,913 Views)
Hi Brian-
 
That looks pretty good with one exception.  Your first set attribute should set the encoder type rather than the source selection.  Depending on your version of NI-DAQ this should be called something like "encoder type."  Have you seen good results using this method?
 
Thanks-
Tom W
National Instruments
0 Kudos
Message 6 of 9
(4,900 Views)
Brian,
 
Adding to Tom W's comment, the 2nd 'Set Attribute' may need to change also.  I'm not near an LV PC now to check, but the online help should be able to tell you the legal combinations.  I think that the input that goes with 'Z index active' is something like a 'yes' or 'enabled' rather than a polarity setting. 
 
Actually, the Z-index polarity isn't even configurable.  The docs aren't crystal clear, but I've found in practice that it's active as long as the Z-index signal remains in the high state.  The docs (as I recall) keep referring to a pulse, kind of implying that it's edge-sensitive.  However, if you physically wire the Z-index to a +5V constant high state so there's never a pulse or and edge, you'll observe your encoder counter go 0,1,2,3,0,1,2,3,0,1,2,3,0,1...
 
This brings up something I failed to think through in my earlier reply.  Do you only need to generate the pulse?  Or do you need to use the pulse to perform a delayed reset on a 2nd counter that measures the encoder?  If the former, you can skip the next paragraph.  If the latter, read on...
 
The brief "pseudo z-index" terminal count pulse is going to be generated just after an active edge of your encoder's A-channel.  Odds are, you'll be counting on rising edges of A.  Thus, odds are also that the A channel will still be high during the "pseudo z-index" pulse.  So, if your 2nd counter is also setup as a two-pulse encoder, you'd want to hardwire the AUX input to GND, and configure its z-index reload phase as A-high B-low.
 
Good luck!
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 7 of 9
(4,887 Views)

Okay thanks Tom and Kevin.

No I haven't tried to run anything yet, just playing around with these counter settings trying to figure it out.
I haven't found any info on the legal combinations for the set attributes ID and value, it's a little confusing for me.

I will try to explain my application without being too boring.

A friend of mine is building a small scale V-twin 4 stroke model engine similar to a Harley.
We want to use LV to control things like ignition timing, fuel and monitor things like rpm and temp during the prototyping stage.

I am concentrating on ignition timing right now. I think I have the other stuff figured out.

We will have a quadrature encoder w/index mounted on the camshaft. I need to generate 2 pulses per rev of the encoder.
These pulses will fire an ignition module. The module will fire the coils and plugs.

We want to be able to adjust ignition timing during our testing.
I would like to generate the pulses delayed from index by x number of ticks(ignition timing) and the pulse widths(dwell) x number of ticks.
This way I can change timing (x number of ticks) with respect to the index. The index will keep things in sync every revolution.
If I can set the pulse width with number of ticks then the pulse width (dwell) will be linear with speed just like points on older engines.

I am concentrating on generating one pulse right now. I figure I can duplicate whatever counter configuration that works later for the second pulse.

Single direction and counting one encoder phase should be okay for now.


Thanks
 

Brian

0 Kudos
Message 8 of 9
(4,881 Views)
Hi Brian-
 
That sounds like a really cool application for LabVIEW- thanks for letting us know more about what you're working on!  Let me know if the pulse generation doesn't turn out well or if you have additional questions.
 
Thanks again-
Tom W
National Instruments
0 Kudos
Message 9 of 9
(4,863 Views)