12-08-2009 02:03 AM
Hi,
I would like to use the 6602 to divide an A B pulses from a linear encoder by a factor of X and use the division output as an external clock to the 6133 DAQ card.
To config the 6133 i have no problem but i didn't managed to use the counter on the 6602 to divide the A B inputs.
I attached a block diagram.
I need a link / example of how to config (HW & SW) the 6602 to perform this task.
12-08-2009 06:07 PM
Hello Barak,
To do this for both your A and B signal will require the use of two counters. All you just need to do is generate a continuous pulse train using the A / B signals as your source of ticks. If you are using LabVIEW, I would start with the Gen Dig Pulse Train-Continuous.vi example. Please let me know if you are using another application development enviroment and I will do my best to point you to another example you can start from. The example can be found by using the Example Finder (Help » Find Examples within LabVIEW) and navigating to Hardware Input and Output » DAQmx » Generate Digital Pulses. I've attached a picture below with the modifications you need to make to generate a divide down of one of the signals (A or B). You will need to copy this code for the 2nd signal.
As you can see from the above code, you need to change the DAQmx Create Channel to Counter Output » Pulse Generation » Ticks. This will allow you to specify the divide down (using the high and low tick input) and the source of ticks (to specify where you are inputing the A / B signals).
I hope this helps,
Paul C.
12-09-2009 12:32 AM
Hi Paul,
Thanks for you replay.
I'm using Labview 8.2.
I think I didn't described correctly my need.
The A B need to be counted as a qudrature counter.
Meaning that if the encoder have jiter of +-1 Increment of position the counter is not counting more then 1 even if the A B inputs are changing all the time.
I need one output based on the A B inputs .
12-09-2009 09:57 AM
Hello Barak,
Could you please provide a timing diagram of what you are looking for? I'm a bit confused on what the one output will look like with respect to your A and B signals.
Regards,
Paul C.
12-13-2009 01:41 AM
Hi Paul,
We want to output a pulse on the clock line when the delta position from start is 4.
The number can be change and can be any number and not only 4.
We will use the output as a clk for sampling with the 6133 card.
We will define the sampling task to sample when the clk is changing from low to high.Therefore
relative position:
0,1,2,1,2,1,2,3,2,1,2,1,2,3,4,3,4,5,6,5,6,6,6,7,6,7,8,7,8,7,8,7,8,9,10
Counter output
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0Sample point Sample point
12-14-2009 02:37 PM - edited 12-14-2009 02:41 PM
Hello Barak,
I think we might be able to offer what you are looking for. I'm a bit confused on the timing diagram in the instance that you reach 4, tick back to 3, and then tick back to 4 again. Does the counter output have to stay high throughout this or can it just pulse high on the first reaching of 4?
My guess is that either would work fine as the sample clock for the 6133. The following are some instructions on how to accomplish this:
First, take a look at the example program here. The way it works is to set the initial count and Z value to (2^32-1) minus when you want to generate your clock. In your own example, this would be 4. This makes the counter output a pulse on the terminal count event terminal after 4 ticks in one direction. The terminal count event occurs when the counter reaches 2^32-1 for 32-bit counters. It is important to note that this will reset the counter back to the initial count. Meaning, you will only get one pulse once you reach 4. To get a second pulse, you will need to move the encoder position forward by 4 again. You can use the output of the counter input to generate a sample clock for your device, but this will have to be a pre-defined number of pulses.
For example,
relative position:
0,1,2,1,2,1,2,3,2,1,2,1,2,3,4,3,4,5,6,5,6,6,6,7,6,7,8,7,8,7,8,7,8,9,10
Counter output
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0
So, our output will be a single pulse (the width of the pulse can be modified using a counter output as in the example provided) or series of pulses (if you trigger a counter output to generate more) when you reach 4, 8, 12, etc. This will only occur once and the counter is reset.
I modified the example above to be a linear encoder and set the z index value and initial position to 4294967291 (2^32-1-4). I was able to generate a single pulse each time the counter moved forward 4 ticks.
Let me know if you have trouble setting it up.
Regards,
Paul C.
12-16-2009 03:22 AM
Hi Paul,
Thanks for your answer.
It looks like what I need but there is only one issue that I'm not sure.
In the example there is a definition of the state of A and B signals when the reset arrived.
Can we be sure this will be the state even if the encoder has a jitter ( meaning +-n Position increments when the encoder is not moving )?
12-16-2009 09:34 AM - edited 12-16-2009 09:37 AM
Hello Barak,
The counter will reset when it reaches terminal count. If you set the count to terminal count (2^32-1) minus 4, this means that if the position moves to the +4 position it will reset. If you are in the +3 position and your encoder jitters to the +4 position, your counter will send a the pulse on the output and reset. Once reset, you will be in the 0 position. Jitter to -1 and +1 positions won't really matter because it won't reset the count until reaching the +4 position.
Is this due to some sort of vibration / noise in the enviroment? I think the best approach might be trying to eliminate this jitter altogether.
If the jitter is due to noise on the encoder, you might try using the digital debounce filter. This will allow you to specify a minimum pulse width for the edges counted. Take a look at the article here for more information.
If the jitter is due to vibration, there might be something you could station the encoder on to reduce the vibration.
Let me know what you think and I will do my best to help out.
Regards,
Paul C.