Determining direction

JeffB

Lifetime Supporting Member
Join Date
Apr 2002
Location
NW Arkansas
Posts
79
Hey guys,

Could anyone tell me how, when using encoders, I could determine the direction the encoder shaft is turning. There are times when I could decrease machine cycle times, If I knew for sure the actual direction a device is moving, (I don't want to assume a device is going forward, just because I told it to).

I mostly use A/B SLC's with encoders wired to high speed counter cards.

Thanks,

Jeff
 
If you use quadrature encoders which have two channels A and B. B is 1/4 out of phase with A. By determining if A or B is leading you know direction. The HSCE card can take the quad input directly and count up or down for you. The manual for the card has more of an explanation.
 
Jeff

This is the way that I deal with determining the direction of a motor from the encoder input


I1 Encoder Pols O2
---| |--| A Greater Than B |----------| Latch |-----( )


I1 Pols Encoder O2
---| |--| A Greater Than B |---------|Unlatch|-----( )


Encoder Constant 0 Pols
---| A Add B = C |---




Key :

I1 – input that says whether the motion is running or not
Encoder – the encoder input (as a decimal number)
Pols – Position of encoder last scan
O2 – Output that states the direction running, i.e when O2 set then motion travelling forward if not set then motion travelling reverse.

The way this works is that each time the ladder is scanned, the encoder position is compared to the position recorded the previous scan (rung 3) and then the direction is determined from this simple bit of maths. Rung 3 updates the Pols with the new encoder position, by placing this rung last you then ensure that the Pols is not updated until you have done the compare with the updated encoder counts.

I have taken this from our programs written for a GE series 6 PLC, but I am sure you can adapt the general idea to use within your own PLC

Paul
 
Be careful!!!

Depending on your counter card hardware, PLC math capability, and your application, you might have to add logic to deal with 'rollover'. There are three possible conditions to test for.

1) a change in encoder position (+ or -) that has not resulted in a rollover (i.e. normal case)

2) a rollover from a large value to a zero or negative value. This can only occur in a positive direction of travel.

3) a rollover from a large negative value or zero value to a large positive value. This can only occur in a negative direction of travel.

The rollover detection is usually performed by testing for a sudden very large delta. The magnitude of the delta will be opposite in sign from the normal movement.

I usually test for rollover by using a value 1/2 of my possible rollover value. Example, if I am using a 24 bit counter card and the card counts from 0 to 16777215, I perform a test for > 8388608 and < -8388608. This insures that I catch just the rollover condition for that one scan. The next scan should be back to a 'normal' delta.
 
Greg

I do agree with you in respect to encoder rollover, but in the example I posted, although I did not make this clear, I am using double precision values (32 bit memory storage) the value range for this type of memory is -2,147,483,648 to +2,147,483,647. We use this method for determining direction over a 550 metre range and do not encounter any rollover problems.

Paul
 
Paul,

I agree as well in regards to YOUR application, but neither you or I know what Jeff (the original poster) is doing. Plus the info is good for newbies.

Rollover is not likely to happen in your example since you have made sure that your physical travel is well within the count range for your application. (But it can potentially happen, for example during the initial commisioning of the machine perhaps?)

But let's suppose the application is a continuous rotary drive i.e a conveyor. And this conveyor runs 'forever'. Now you must deal with a periodic rollover case.
 

Similar Topics

I am new to PLC programming and hope that someone in these forums may be able to assist. I am mainly using AB PICO controllers and have a need...
Replies
9
Views
5,581
We are in the process of installing a new DC drive to replace a 1373 series Speedpak drive. There are 8 leads coming out of the motor -- Two for...
Replies
5
Views
845
Good morning! I am looking for a clever method to determine the number of occurrences in a series using ladder logic. What I need to determine is...
Replies
6
Views
1,259
I have my PLC and HMI connected to my local network over DHCP just like my laptop. I can upload and download including VNC to the HMI over wifi...
Replies
2
Views
1,137
We have a DC Drive (ABB DCS800) which is running a load (initially) at a fixed speed. For testing purposes, we want to simulate a different...
Replies
20
Views
6,259
Back
Top Bottom