Abdul Wajid

Encoder Program for CW & CCW rotation

11 posts in this topic

Dears

I have Connected Encoder (100 ppr)  with CP1E - NA model PLC with all the proper in-bulit settings and encoder connection with PLC input terminals (I0.00- A phase & I0.01- B phase), but i can't able to get the proper pulse reading and the reading in pulse storage word A270 keeps on decreasing only in one direction instead of other direction.

My CP1E-NA20 PLC settings were - High speed counter 0, max. circular count 1000, Software reset & input setting as Pulse+Direction. Also checked other input settings but didn't get.

A270 word in PLC starts counting from 1000 and keeps on decreasing whether if shaft rotated in both direction (Clockwise & Anti-clockwise).Also i tried using Up/Down input setting. Same situation occurs in PRV instruction also

Whether I am missing something or anything in the PLC program ? Also how can i set the count which starts from 0 to 1000, is there any possibility ? Would be better if got a sample program.

 

Thanks & Best Regards

Abdul Wajid

Edited by Abdul Wajid

Share this post


Link to post
Share on other sites

This is not working because you chose pulse and direction.  Choose Differential Phase Input (that is what Phase A and Phase B are) and it will work.

To get it to go from 0 to 1000, choose circular mode in the settings and set 1000 as the maximum as shown below.

58f919082459d_4-20-20173-46-34PM.jpg.f37

However, be aware that this is 1001 counts (0 - 1000).  If you want 1000 counts for the rollover, choose 999 as the maximum circular count.  Make sure to download this to the controller and cycle power.

Share this post


Link to post
Share on other sites

Yes Michael, you were right. But one problem i used to get that whenever i switch the PLC Off/On then the same problem occurs, most time pulses were reading keeps on decreasing from 1000 to 0 onwards if encoder rotates in CW or CCW , sometime pulse reading gets stuck initially and I also checked by interchanging the Phase input connections in the terminals. In short pulses were can't able to retain in the same state/conditions.

What i can do to get rid of all these situations ? Am i missing anything ?

Thanks

Share this post


Link to post
Share on other sites

Did you buy a battery for your CP1E-NA?  The battery is sold separately for this PLC to keep the option as low cost as possible.  The battery is only added as needed.  If you turn the power off (after 40 hours, the capacitor discharges) and need to retain any values or settings, then a battery is needed.  Here is the part number:  CP1W-BAT01

 

Share this post


Link to post
Share on other sites
13 hours ago, Michael Walsh said:

Did you buy a battery for your CP1E-NA?  The battery is sold separately for this PLC to keep the option as low cost as possible.  The battery is only added as needed.  If you turn the power off (after 40 hours, the capacitor discharges) and need to retain any values or settings, then a battery is needed.  Here is the part number:  CP1W-BAT01

 

No, i don't have battery for it. But the PLC should be able to retain the settings or values for duration of few seconds of PLC On/Off even though it's not for some hours.

Secondly, One more thing surprised me regarding input connections that without connecting the potential (24VDC) to the PLC i/p common, the encoder storage bits still shows the pulse reading whereas the i/p Phase A & B gives 0V potential to the PLC i/p terminals. After Switching PLC On/Off vice versa situation occurs (I have to give 24VDC to PLC i/p terminal for proper pulse reading). These occurs repeatedly.  How it comes ? Are there any alternative way for it ?

 

Share this post


Link to post
Share on other sites
On 4/25/2017 at 3:24 PM, Abdul Wajid said:

No, i don't have battery for it. But the PLC should be able to retain the settings or values for duration of few seconds of PLC On/Off even though it's not for some hours.

Secondly, One more thing surprised me regarding input connections that without connecting the potential (24VDC) to the PLC i/p common, the encoder storage bits still shows the pulse reading whereas the i/p Phase A & B gives 0V potential to the PLC i/p terminals. After Switching PLC On/Off vice versa situation occurs (I have to give 24VDC to PLC i/p terminal for proper pulse reading). These occurs repeatedly.  How it comes ? Are there any alternative way for it ?

 

My only guess is your encoder don't have same Common with the PLC IO? So the PLC input read is as a floating signal.

Regarding the retaining ability of the Settings will depend on the lifetime of your PLC. If it is old enough like 5 years or less depending on usage environment, you can expect the internal capacitor to deteriorate and unable to store charges anymore, thus nothing is kept when power is off.

EDIT : Your Encoder is an Open-Collector right?

Edited by innoaloe

Share this post


Link to post
Share on other sites
On 7/30/2017 at 3:46 PM, innoaloe said:

My only guess is your encoder don't have same Common with the PLC IO? So the PLC input read is as a floating signal.

Regarding the retaining ability of the Settings will depend on the lifetime of your PLC. If it is old enough like 5 years or less depending on usage environment, you can expect the internal capacitor to deteriorate and unable to store charges anymore, thus nothing is kept when power is off.

EDIT : Your Encoder is an Open-Collector right?

Dear Innoaloe

I have autonics encoder (Model : E40S6-100-3-T-24) and had the Totem pole output (not open-collector) for which the common i have connected 0V as well as PLC common. I purchased PLC few month before which are still under warranty.

But the problem are in A & B phase, i need to read (count) the pulses in both directions (CW & CCW) simultaneously if rotates in both sides (fwd & rev), but the pulse counts only in one direction either increasing continuously or decreasing and pulse count fluctuates (fwd/rev) when power cycles (sometime counts fwd and sometime counts rev) even though i had tried all the input settings in high speed counter with required connection. Am i missing anything anywhere ? Are these things occurs for any power supply (SMPS) fluctuations or Any special memory (bits or words) required apart from A270 or PRV inst. ? Same problem occurs in Z-phase also.

Also kindly clarify me the difference between Open collector & Totem pole output encoder.

 

Thanks

Edited by Abdul Wajid

Share this post


Link to post
Share on other sites
On 7/31/2017 at 5:42 AM, Abdul Wajid said:

Also kindly clarify me the difference between Open collector & Totem pole output encoder.

An Encoder with Open Collector Output means the transistor inside the cable has no load connected to the Collector. It needs a supply and load from outside source, such as a PLC Input Pin, which has an Photocoupler inside (Photocoupler act as the load for the Encoder Output). This means without being connected to a load, the Encoder Output is floating somewhere and may cause faulty signal.

With Totem-pole, the output contains back-to-back transistor. So even without connected to a load, the Encoder Output is referenced to the supply voltage. Both Open Collector and Totem-pole type should be connectable to a CP1E without problem.

 

Quote

Yes Michael, you were right. But one problem i used to get that whenever i switch the PLC Off/On then the same problem occurs, most time pulses were reading keeps on decreasing from 1000 to 0 onwards if encoder rotates in CW or CCW , sometime pulse reading gets stuck initially and I also checked by interchanging the Phase input connections in the terminals. In short pulses were can't able to retain in the same state/conditions.

That's should be how a Circular Counter works... since the set value is from 0 to 1000, if moved CCW from 0 it will rollback to 1000, vice versa.
Also, the Differential Phase method is actually counting both rising and falling edge of Phase A and B. If your encoder is 100 pulse/rotation, one rotation will be counted as 400 pulse in the PLC. Assuming your Phase Z input in PLC 0.04 is not connected, it shouldn't autoreset the value by itself.

About the reading getting stuck : Make sure there is no INI instruction execution which resets or presets the counter value.

Share this post


Link to post
Share on other sites
On 8/2/2017 at 9:58 PM, innoaloe said:

An Encoder with Open Collector Output means the transistor inside the cable has no load connected to the Collector. It needs a supply and load from outside source, such as a PLC Input Pin, which has an Photocoupler inside (Photocoupler act as the load for the Encoder Output). This means without being connected to a load, the Encoder Output is floating somewhere and may cause faulty signal.

With Totem-pole, the output contains back-to-back transistor. So even without connected to a load, the Encoder Output is referenced to the supply voltage. Both Open Collector and Totem-pole type should be connectable to a CP1E without problem.

 

That's should be how a Circular Counter works... since the set value is from 0 to 1000, if moved CCW from 0 it will rollback to 1000, vice versa.
Also, the Differential Phase method is actually counting both rising and falling edge of Phase A and B. If your encoder is 100 pulse/rotation, one rotation will be counted as 400 pulse in the PLC. Assuming your Phase Z input in PLC 0.04 is not connected, it shouldn't autoreset the value by itself.

About the reading getting stuck : Make sure there is no INI instruction execution which resets or presets the counter value.

Hi Innoaloe

Yeah,  you were right. In differential phase method, when i connects the phase A to 0.01 & Phase B to 0.00 address then it counts the pulses Inc & Dec in both direction CW & CCW. But i tried many times connecting phase A to 0.00 & Phase B to 0.01 and it won't works and perfectly, it works fine when connection shuffled and it counts 4x100=400 pulses in one rotation for both directions CW & CCW.

But how can i be able to count the same as 100 pulses for one rotation (CW & CCW) even though i tried input Up/Down method but it doesn't counts perfectly and the pulse counts fluctuates (not using INI instruction, using only PRV) and sometime the pulse keeps on counting continuously (up/down) even when shaft were kept in idle condition (immediately after rotation- occurs only in up/down method) ? How it comes and how can i be  able to count same as differential method for 100 pulses only (my encoder rating).

Also clarify me for Pulse + direction method, how can i enable the direction. When i connects Phase B, the pulse count decrease whether rotates CW or CCW and also same situation occurs if Phase B Disconnects. How can i bring the changes in it ?

 

Thanks

 

Edited by Abdul Wajid

Share this post


Link to post
Share on other sites
Quote

Yeah,  you were right. In differential phase method, when i connects the phase A to 0.01 & Phase B to 0.00 address then it counts the pulses Inc & Dec in both direction CW & CCW. But i tried many times connecting phase A to 0.00 & Phase B to 0.01 and it won't works and perfectly, it works fine when connection shuffled and it counts 4x100=400 pulses in one rotation for both directions CW & CCW.

It's weird that exchanging phase A and B in Differential Phase solved the issue. If that's the case, then having phase A connected to 0.00 and phase B to 0.01 should also work properly, only with reversed count direction.
 

Quote

(not using INI instruction, using only PRV)

Have you compared the result of using PRV and reading directly from A270? Don't forget that it is actually A270 and A271 together that saved the value, so you should monitor A270 as a DINT or DWORD value. Try looking at it from the Watch Window (shortcut Alt+3, see screenshot below). I usually avoid using PRV for reading count value.

Capture.JPG.57caec0e70c2a529ed3c01841cf4

 

Quote

But how can i be able to count the same as 100 pulses for one rotation (CW & CCW)
How it comes and how can i be  able to count same as differential method for 100 pulses only (my encoder rating).

A differential phase will always read 4 times your Encoder PPR. Nothing can change that except you make a Divide instruction (/L) in the ladder to divide the read value by 4. The thing is you actually got more precision with Differential Phase. Say your 100 PPR Encoder, logically you only get 360 degree/100 pulse or 3.6 degree/pulse of precision.

Having Differential Phase counting means you have 360 degree/400 pulse or 0.9 degree/pulse of precision. Unless you're not using your encoder for positioning, I cannot see why you want to keep the value back to 100.

 

Quote

even though i tried input Up/Down method
Also clarify me for Pulse + direction method, how can i enable the direction.

Your Encoder output is Differential Phase, so in good way you can use it for Up/Down or Pulse + Direction method. Let me clarify :
 

  1. Up/Down mode typically used for counters. You had one switch wired to Up Input and another one to the Down Input. You press Up switch, it counts Up by 1. You press Down switch, it counts Down by 1. Encoder has differential phase which means halfway when A is on, B starts to went On. Halfway when B is on, A starts to went Off. This means you will never have a proper Up/Down counting, only full of noise.
  2. Pulse + Direction mode : So one input is to receive Pulse (should be the 0.00 one) which you can wire either Phase A or B from the encoder as the counting input. The Direction input (0.01) is just a simple On/Off from a switch. When Direction input is off, the received pulse will be read as counting up. When Direction input is on, the received pulse will be read as counting down. You're not wiring both Encoder phase at the same time. That's why this method also typically won't be used for Phase A+B output Encoder.
1 person likes this

Share this post


Link to post
Share on other sites
On 8/9/2017 at 8:16 PM, innoaloe said:

It's weird that exchanging phase A and B in Differential Phase solved the issue. If that's the case, then having phase A connected to 0.00 and phase B to 0.01 should also work properly, only with reversed count direction.
 

Have you compared the result of using PRV and reading directly from A270? Don't forget that it is actually A270 and A271 together that saved the value, so you should monitor A270 as a DINT or DWORD value. Try looking at it from the Watch Window (shortcut Alt+3, see screenshot below). I usually avoid using PRV for reading count value.

Capture.JPG.57caec0e70c2a529ed3c01841cf4

 

A differential phase will always read 4 times your Encoder PPR. Nothing can change that except you make a Divide instruction (/L) in the ladder to divide the read value by 4. The thing is you actually got more precision with Differential Phase. Say your 100 PPR Encoder, logically you only get 360 degree/100 pulse or 3.6 degree/pulse of precision.

Having Differential Phase counting means you have 360 degree/400 pulse or 0.9 degree/pulse of precision. Unless you're not using your encoder for positioning, I cannot see why you want to keep the value back to 100.

 

Your Encoder output is Differential Phase, so in good way you can use it for Up/Down or Pulse + Direction method. Let me clarify :
 

  1. Up/Down mode typically used for counters. You had one switch wired to Up Input and another one to the Down Input. You press Up switch, it counts Up by 1. You press Down switch, it counts Down by 1. Encoder has differential phase which means halfway when A is on, B starts to went On. Halfway when B is on, A starts to went Off. This means you will never have a proper Up/Down counting, only full of noise.
  2. Pulse + Direction mode : So one input is to receive Pulse (should be the 0.00 one) which you can wire either Phase A or B from the encoder as the counting input. The Direction input (0.01) is just a simple On/Off from a switch. When Direction input is off, the received pulse will be read as counting up. When Direction input is on, the received pulse will be read as counting down. You're not wiring both Encoder phase at the same time. That's why this method also typically won't be used for Phase A+B output Encoder.

 

Hi Innoaloe

Thanks for your clarification for Pulse+Direction method.

Actually i have to connect address as 0.00 & 0.02 (instead of 0.01) to work perfectly.

-->When i connects Phase A to 0.00 & Phase B to 0.02 or vice versa then pulse count increases & decreases based on CW and CCW rotation for 100 pulses.

-->When i connects Phase A or B to 0.00 and Switch to 0.02, then pulse counts decrease if Switch OFF and increase if Switch activates (hold on)

Also the input Up/Down method works on the switches, but seems like it's not mandatory to use up/down method , hope other methods would enough for almost applications.

Anyway i am really grateful for helping me to sort out the issue.

 

 

 

Edited by Abdul Wajid

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now