How do pinpoint Encoder direction change.

RPax

Member
Join Date
Feb 2004
Posts
125
Hi, I was wondering if somebody could help. I'am using a mitsubishi Fx PLC where I have linked a A/B Phase encoder to the high speed counters ie Phase A to X3 and Phase B to X4 to count on counter C253.

What I'am trying to do is find out when the encoder (1000 pulses/rev) changes direction. I understand that each phase will preceed the other depending on the direction but is there a handy way or any way I can tell when the encoder has changed direction.

I tried a simple sequence program using the X3 and X4 Inputs and this seemed to work but at very slow speeds but as their not hardware depended lost it's way a higher speed. Is there high speed functions that can be used. The direction change doesn't have to be exact as long as the direction change is picked up in a reasonable time. I would grateful for anyones help even if not specific to Mitsubishi or even a previous thread that might help. Thanks
 
Assumption 1. We're talking about a quadrature encoder.

Assumption 2. C253 is an up/down counter.

Couldn't you write some logic to detect whether the counter value is increasing or decreasing?
 
ALWAYS USE THE DIFFERENCE IN COUNTS!!!!

Both CountUp and CountDn outputs will be on when the encoder rolls over.

ALWAYS USE THE DIFFERENCE IN COUNTS!!!!

nDifCounts = nHWCounter - nOldHWCounter

If nDifCounts < 0 then counting negative

if nDifCounts = 0 then stopped.

if nDifCounts > 0 then counting positive

Use the status bits from the previous subtract. IE signed, zero, positive bits that most PLCs provide that people don't use.

ALWAYS USE THE DIFFERENCE IN COUNTS!!!!
 
Peter I suppose your right, we dont do rollovers in our applications so I never noticed it. Also I'll re-vist the issue regarding using the counter the status bits. I simply didnt think of it at the time.

Thanks! Mike
 
Firstly many thanks to yee for taking the time to respond. I took your advise and did a compare command using the current count from the counter C253 and a count from a register. The count in the register was the value that occupied C253 in the previous Scan (done with a simple Move command in my program).

To compare the Counter C253 and D10 (Register Value) it was necessary to use a high speed compare command ie the HSZ (Function 55) and then use the greater than, less than or equal to bits that Peter mentioned. It's worth mentioning that the standard compare command CMP (Funtion 10) and ZCP Zone compare command (Function 11) did not work. Again thanks for your help.
 
Speed of sample will be a big problem depending on the hardware used. The limit is how fast you can run this logic and the frequency of the quad signals. In general you want to sample at least 2X the quad frequency.


(Quad A signal) XOR (Quad B signal @ 1 Sample Delay)
 
Last edited:
Hi RPAX

When using Mitsubishi FX, you could use the special register M8xxx, where xxx = HS-counter. In your case M8253.
When M8253 is "1" the counter is counting up
When M8253 is "0" the counter is counting down.

IF you want to do math operation you have to use doubleword

eks.

LD M0
DMOV C253 D0 ;Move the act. count to reg. D0-D1
LD M1
DDIV D0 D2 D4 ;Divede D0 with D2 and store in D4-D5 and dec. in D6-D7


Dariusch
 
Hi, hope you don't mind if I ask a follow up question on this as I've only realised the problem.

The encoder that I'am using has 1000 pulses/rev. Starting at a 12 o Clock position and moving anti-clockwise it counts up to 1000pulses and then resets to 0. It then repeats the count ie 0-1000 again which is what I'am looking for. However, if it goes clockwise and reaches 0 it goes into a minus count -1,-2 etc. Is there anyway that the counter (that the encoder is linked to) can be reset to keep it within the 0-1000 range ie instead of -1,-2 etc it will count down from 1000, 999, 998 etc.

I've tried writing 1000 to the counter C253 but it start counting back from -65xxx. I suppose what I'am asking is whether I can write to a high speed counter in a FX2N Mitsubishi model. Appreciate if anyone has anything on this.
 
OOP's!! Sorry about that. I missed the finer points. Realise Mistake banghead . Thanks again (y)
 
I am not familiar with that PLC but I just have to ask, Can you get the PLC with a Quadature Decoder built in ? I have used a quadrature decoder before and it always was inherent (Would add or subtract on its own) and the count value was always stored into a perticular register.

Dave
 
Hi Dave, these Mitsubishi Fx PLC's have predefined High speed counters built in. There's 1 Phase with start and reset, 2 Phase bi-directional along with the AB Phase counter. You've an option of 5/6 counters of each type but are limited to the amount you can actually use as there's only 7 High speed inputs (Depending on model).

The counter that you select will dictate the manner on how the counter counts up or down. In some counters you have to set Special relays on to count down etc but mainly the up and down counting looks after itself such as with the A/B Phase. If need more info let me know and I'll see can I dig out a few manual pages on this.
 

Similar Topics

Sorry in advance for the long post, but this requires a little back story. I work in a facility with a couple hundred VFDs Most are in a web...
Replies
13
Views
95
I have an application using an incremental encoder and then I convert it to degree (0-360) using calculation program. For a while, the calculation...
Replies
7
Views
239
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
1,000
Dears, i am trying to change the series of encoder from A to B, but the program do not has this option (Rslogix5000, 20.06 the old encoder was...
Replies
2
Views
208
Hi all, I am working with an incremental encoder (ABZ signals, 360 ppr (so 1440 counts per rev)) to replace the existing "manual" encoder wheel I...
Replies
51
Views
2,609
Back
Top Bottom