LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the Pulse Count for Incremental Encoder

Solved!
Go to solution

First, both A & B have the same number of pulses and the total pulses per revolution are the same for A as B.  If the number of pulses per revolution is 10 then both A & B have 10 pulses.  A system with the Z will fire a pulse for every 10 pulses of A or B which is the same point.  It has been a while, and I am uncertain if the pulse width for Z is the same as the others.

Minions_0-1712234530304.png

For a 10 pulse per revolution encoder it will have 10 * 4 steps ==> 40 steps = [360 degrees/40 steps] = 9 degrees of resolution = 9 degrees per step.

 

You must make sure that your sample rate is quick enough to take at least two samples at each step otherwise you might actually be below the Nyquist sampling frequency without knowing it.

 

Your program should:

  • Begin your timer [set t0]
  • Track the change in states or steps [only four states tracking forward and back for jitter]
  • Total those steps over some period of time to derive velocity [delta steps / delta time]
  • Acceleration is the change in velocity over time [delta velocity / delta time]
  • Angular velocity is velocity multiplied by the degrees per step [(degrees per step) (velocity)] 
  • repeat using the last timer reading at the current step
Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 11 of 50
(202 Views)

Do you check the code attached in the previous reply ? Does it make sense to calculate the angular Velocity.

0 Kudos
Message 12 of 50
(198 Views)

I am trying to calculate the motor velocity using Incremental Encoder. I understand how its work and the method to calculate the pulses, also when it will take clockwise turn and anticlockwise turn.

Based on the above understanding I wrote a code to count the pulses of Channel A and B. 

But when I am running it the value of the count is showing -1 only instead of giving the motor any RPM.

Can you please let me know where I am going wrong ? Please Ignore the comment if it does not make sense to you ? 

I believe the condition of counting the pulse for A and B is not written properly. 

 

Pls : I am using Incremental Encoder attached on the DC Motor, I am writing the code on FPGA. 

 

0 Kudos
Message 13 of 50
(269 Views)

Try the shipping example <LabVIEW>\examples\CompactRIO\FPGA Fundamentals\Counters\Quadrature Decoder\Quadrature Decoder.vi

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 14 of 50
(240 Views)

I just wanted to understand, what's the wrong with this code. I am supposing that it should count the number of pulses for a specific period of time.  And that I can use for calculating the Velocity. 

I really want to understand it. As far my understanding is concern, I am not able to relate this code with the conceptual understanding. 

 

If someone is really good at FPGA codding, please look this out.

0 Kudos
Message 15 of 50
(147 Views)

Ran a simulation with your code [Using two booleans, non-FPGA code & a looped state machine in its place].  It looks like it should work.  I would recommend that you preset your shift registers to get the initial results.

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 16 of 50
(148 Views)

Can anyone help me to understand the potential reason this cause.

Basically I am using the below code to calculate the increment count and velocity ( 2nd image of SubVI for velocity calculation, I thought the loop frequency is getting affected by it so i made it)

host.PNG

Subvi.PNG

Basically I am trying to validate my Encoder Increment count and Velocity using Motion Manager 6 of Faulhaber. Whenever I am giving the less position count to my motor let say 400, 500,  600 my Encoder Increment count is also coming near by value and it is fluctuating. But when ever I am giving so high position to my motor let say 5000 then using the labview I am getting 4200 as a position count. 

 

Similarly, I am trying for velocity and giving some less value let say 100 then using labview encoder code I am able to read it around 98 and near by values but when ever I am giving it. let, say 400 RPM through motion manager and reading it through the sbRIO it is coming near 300.

 

Pls Note : I am trying to validate my encoder reading by giving the command to the motion manager and reading those values in the SbRIO using the above code which I have shared earlier.

 

 

It would be a great help if some will let me what could be the possible reason for it. 

My Point of View on it : Either the code have not all condition to count the pulses or it could be because of the frequency of calculation ( I tried this but helped me ). 

 

Please correct me I am not making any sense.

 

0 Kudos
Message 17 of 50
(130 Views)

If you are trying to debug your code, start simple.

  1. Do you know what a count is (pulse, step, other)?
    • Take a reading
    • Rotate the encoder shaft 90 degrees
    • Take another reading
    • Does the count equate to 90 degrees?
  2. What does your velocity reading look like if you turn it 90 degrees in under a second?
    • Does that seem right?
Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
0 Kudos
Message 18 of 50
(122 Views)

Hello, 

Can anyone help me to convert this VI for SbRIO 9627 ?

I mean can someone create the given VI usable fort FPGA. 

0 Kudos
Message 19 of 50
(138 Views)

1. The count is varying in thousands. let say When I am rotating the shaft by 45 degrees the count is 27413 and another 45 degrees the count is 28131.

2. When I am rotating the shaft under a second the velocity increases and then decreases to zero. 

 

I feel, this code fails to calculate the count of my encoder, I have a myRIO in which there is Encoder inbuilt block is given in the myRIO toolkit it gives precise count. I wanted to have that level of accuracy for my application.

0 Kudos
Message 20 of 50
(104 Views)