Routine for determining direction of rotation.

mathewsg

Member
Join Date
May 2007
Location
Warragul, Victoria
Posts
3
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 for a simple routine that only perform an output when two inputs occur in a certain order.

I am using two inputs but input 1 must happen before input 2 for the output to occur.

This routine is needed to determine which direction a wheel is rotating i.e. if input 1 closes before input 2 then direction of rotation is forward. If input 2 closes before input 1 then directionof rotation is reversed.

A suggested program routine would be appreciated.
 
Can you describe the setup a little more carefully?

Does the wheel turn more than once?
Do the inputs overlap? That is - while input 1 is on can input 2 come on?
If the wheel were to turn at a constant rate what would you expect to see at the 2 inputs?

These answers will help in the suggestions.
 
Bernie,

Thanks for your reply.

The wheel is constantly turning.

Image 50 spokes on the wheel. The sensors that trigger inputs 1 & 2 are appproximatly 75mm (3") apart.

As the wheel is rotating forward each spoke passes the pair of sensors (inputs 1 & 2). The spoke triggers an output because input 1 was triggered before input 2.

When the wheel is reversed each spoke would trigger sensor 2 before sensor 1.

I hope this helps clarify my enquiry.
 
If the signals conform the the following diagram, then your logic must use the rising/falling edges to determine the direction. Assume forwards is left to right and reverse is right to left on the diagram, then the direction can be established as follows:

Rising Edge of A, If B=0 direction=fwds else direction=rev
Falling edge of A, If B=0 direction=rev else direction=fwds
Rising Edge of B, If A=0 direction=rev else direction=fwds
Falling edge of B, If A=0 direction=fwds else direction=rev

view7.JPG



I'm not familiar with the pico so I can't offer the code.
 
You did not address the 'possibly overlapping' issue. If you have the option please place the sensors so that the relationship which the previous poster showed exists. This relationship is called 'quadreature' and makes determination of of direction easy as the poster showed.

If they must be separated then do not make their inputs equal in spacing. If A is relatively close to 2 then you can use a time relationship between actuations as the determiner.

(And by the way - I think an online name should at least be somewhat pronouncible. How do I get my mind around 'which L D[AR2,P#0.0] posted'?)
 
Last edited:
You can give this a try. It was done using Picosoft 3.0.
The timers can be quite short (500ms for a simulation) but depending on rotational speed you might have timing issues.
This will indicate forward and reverse. Just run the Pico desktop simulation to get an idea of how it functions. And be sure to use the impulse relay type for M1 & M2.


pico1.jpg
 
bernie_carlton said:
You did not address the 'possibly overlapping' issue. If you have the option please place the sensors so that the relationship which the previous poster showed exists. This relationship is called 'quadreature' and makes determination of of direction easy as the poster showed.

If they must be separated then do not make their inputs equal in spacing. If A is relatively close to 2 then you can use a time relationship between actuations as the determiner.

(And by the way - I think an online name should at least be somewhat pronouncible. How do I get my mind around 'which L D[AR2,P#0.0] posted'?)
Bernie,

The "wheel" that I refer to is a rotary platform for milking cows; approximately 12 metres in diameter.

The "spoke" of the wheel is approximately 100mm wide and the sensors are positioned approximately 75mm apart.

With the sensors 75mm apart and a 100mm "spoke" the sequence of events for a forward rotating wheel as the spoke passes both sensors would be Input 1 triggered, inputs 1 & 2 triggered, input 2 triggered, neither input triggered.

If the "wheel" is reversed the sequence would be input 2 triggered, inputs 1 & 2 both triggered, input 1 triggered, neither input triggered.
 
Where is Terry when we need him?

I will spare everyone the kmap stuff.

Code:
State   x0 x1 
  A	 0   0
  B	 0   1
  C	 1   1
  D	 1   0

There are only four states and only two inputs. The input that changes determines the direction.

y0 is positive
y1 is negative
Code:
y0 = not lastx0 and not lastx1 and x1 or
	 not lastx0 and lastx1 and x0 or
	 lastx0 and lastx1 and not x1 or
	 lastx0 and not lastx1 and not x0

y1 = not lastx0 and not lastx1 and x0 or
 	 not lastx0 and lastx1 and not x1 or
 	 lastx0 and lastx1 and not x0 or
 	 lastx0 and not lastx1 and x1

lastx0 = x0
lastx1 = x1
I thought about doing it like Terry using his is/was technique.
Code:
y0 = x0 was off and x1 was off and x1 is on  or
 	 x0 was off and x1 was on  and x0 is on  or
 	 x0 was on  and x1 was on  and x1 is off or
 	 x0 was on  and x1 was off and x0 is off
Which is clearer? I think Terry's way reads better.

Note on could always use one shots too. One shots would shorten the logic a bit but would chew up 8 one shots and internal bits or would it. Would it really take 8 one shots? See the multiple one shot thread. I just thought I would bring this up to make people think.

I would stick to my first example.
 

Similar Topics

Hi All, I am looking to copy and paste a routine. I know this has to be done offline. My question is, when I go back online, these tags are...
Replies
6
Views
549
Dear all, I want to use the interrupt service routine in FATEK PLC using WinproLadder Software. I had configured the interrupt in software as...
Replies
17
Views
1,557
I intend to pass a BOOL array to an ST routine (for loop) to count the true bits. (should never have used a Bool array, lesson learned) The ST...
Replies
10
Views
846
Hi all, I have a project which utilizes an L-33ER CompactLogix (v32), which will communicate with a RIO rack with a 1769-AENTR card in its Slot...
Replies
4
Views
782
I have a fault routine set up in my 1769-L36ERM. Is this routine called repeatedly when there's a fault, or is it only called once? It seems that...
Replies
7
Views
1,563
Back
Top Bottom