high speed encoder to prm with AD-06

g.robert

Lifetime Supporting Member
Join Date
Aug 2003
Location
texas
Posts
320
Hello all.

I am into my first automation direct per a new customer's request. I must admit I thought it would be more like AB which is the brand I allways use. I am breaking a project into several groups. I have a DO-06DR-D with a 4x analog in #FO-04AD-1 and a analog volt 2in2out #FO-2AD2DA-2.

FYI, the project is a cable reel that must be moved back and forth based on the speed of the cable reel which is independent of my system. It moves slow. 0-12 RPM. I have a quadriger square wave encoder that pulses 2048 per revolution. The faster the reel turns, the faster we move it to the side. There are other aspects but I am stuck on this in part due to my inexperience with AD.

I hope someone with vast experience in Automation direct can help.

I have part of a program taken from AD examples. It works fine while the count is going up at "UDC" CT174. The count goes 0-9999 then resets to 0 and keeps going. The end result in V2011 (RPM) seems resonably close. The problem is when I reverse direction. The counter counts down to "0" then stops. No reset, no count into negative numbers. Along with that, the RPM value in V2011 goes way out of true. I don't know what to do to correct these two problems at this time. This is getting pretty long so I will post pics of program on next thread as well as program. Any ideas?

My screen pics are to large to post as well as I can't zip the program. I will adjust and try to post. If you are good with AD and interested in helping, let me know and I'll email program. Thanks for any help.
 
Last edited:
Two Questions,
1. Can you reset the counter after every revolution?
2. how fast do you want it to update?

Ad likes to do it the hard way.
 
Thanks for looking into this Rich.

1. I don't see why not. I would just set K at UDC to 2048 (PPR). I am not sure if that would effect the outcome adversely though. I don't know. I'll try that.

2. I'm not sure. Getting into this, it seems like response time should not be to critical. I have this large 12' OD reel. It will turn the encoder 0-12RPM max. As long as I am getting a relatively close RPM reference, I should be able to speed up and slow down the rate of reel shift. I do not know what is a resonable tolerance level at this time but it sure seems like a slow creature to me now.

Any ideas?
 
Wow, I could not have asked for more. Thanks alot for the help. I look forward to hearing from you tomorrow.
 
Here is the program exported in mnemonics so anyone can copy the text and import it into DirectSOFT if desired to play with:

PLC 06
// Rung 1
// Address 0
#BEGIN COMMENT
"This example calculates the RPM of a device connected to the High Speed Counter "
"inputs."
""
"Set the MODE word for power up in RUN mode and Counter Mode 20."
#END
STR SP0
LD K20
OUT V7633
// Rung 2
// Address 3
#BEGIN COMMENT
"Configure the number of pulses per revolution the encoder sends to the PLC."
#END
STR SP0
LD K2048
OUT V2010
// Rung 3
// Address 6
#BEGIN COMMENT
"Enable the High Speed Counter. Configure it for automatic reset."
#END
STR SP1
STRN SP1
STR SP0
OR CT174
UDC CT174 K9999
// Rung 4
// Address 13
#BEGIN COMMENT
"Initialize the previous count location on powerup."
#END
STR SP0
LD K0
OUTD V2000
// Rung 5
// Address 16
#BEGIN COMMENT
"Set a flag when the counter resets itself so that we don't do a calculation immediatly after "
"the reset."
#END
STR CT174
RST C0
// Rung 6
// Address 18
STR SP4
PD C4
// Rung 7
// Address 20
#BEGIN COMMENT
"If it's time to do a calculation and we have not just reset the counter then go ahead and "
"do the calculation, otherwise..."
#END
STR C4
AND C0
OUT C1
// Rung 8
// Address 23
#BEGIN COMMENT
"... update the previous sample value and set the flag so that we will do the calculation the "
"next time."
#END
STR C4
ANDN C0
LDD CTA174
OUTD V2000
SET C0
// Rung 9
// Address 28
#BEGIN COMMENT
"Read the current value of the High Speed Counter (HSC) and store it."
#END
STR C1
LDD CTA174
OUTD V2002
// Rung 10
// Address 31
#BEGIN COMMENT
"Calculate the number of pulses that have been received during the last second by "
"subtracting the previous count from the current count."
#END
STR C1
SUBD V2000
OUT V2004
// Rung 11
// Address 34
#BEGIN COMMENT
"Copy the current count into the previous count location."
#END
STR C1
LDD V2002
OUTD V2000
// Rung 12
// Address 37
#BEGIN COMMENT
"Calculate the RPM by using the formula:"
""
"RPM (x10) = DELTA * 10 * (60 sec/min) / (Counts/Rev)"
""
"The factor of 10 in the equation is there so we can get an implied decimal place in our "
"result so if the value is 2437 this really means 243.7 REV/min."
#END
STR C1
LD V2004
MUL K600
DIV V2010
OUT V2011
// Rung 13
// Address 42
END
// Rung 14
// Address 43
NOP

#BEGIN ELEMENT_DOC
"V2000","Previous Count","",""
"V2002","Current Count","",""
"V2004","Delta","",""
"V2010","Pulses per rev","",""
"V2011","RPM (x10)","",""
#END
 
Sorry, I got tired and it would not let me attach file so I uploaded it into the Download section under Automation direct RPM 2048 Count. Just repaired yours at 100X resolution. Oh I used an 05 instead of 06. Same thing.
 
Last edited:
I think you may have uploaded the wrong one.

The one I downloaded from this site looks identical to the example I started with from AD. I'm not sure if that was your intention as the UDC count is still 9999 and you said you had set at 2048.

Did you load the wrong one or am I missing something?

There are differences in the addressing between the 05 and 06 as well. I'm up on that now and can adjust a 05 program to 06. Is the one on this site's downloads the one you worked on?

I take that back, I see one change on last rung #12. It was 600 (60*10), now it's 6000. I will revise the adresses for 06 and try it out. I won't be able to that until Monday AM. I'll reply back ASAP.
 
Last edited:
I used the one that you had because the other ones I have the math did not work out for the 2048 count so I took the easy way out. The brain get's a little tired after working on a program that took me 6 months to do. I need a vacation.
(Set the MODE word for power up in RUN mode and Counter Mode 20)
I'm using mode 10 so it does not matter wich way the incoder is turning it will count up.
 
Last edited:
I did that as well in my earlier attempts. That works good. Problem is I don't have a signal to tell me I have changed directions. Do you know of a bit or anything else I could use when the encoder changes direction from the existing program?
 
I miss understood what you wanted. In mode 20 it uses two different vmem locations for direction. You want to know the RPM and Direction of the incoder, we can do that. Let me work on it and I'll get back to you.
 
Thanks Rich.

The problem I have is when I try to go mode 20 for bidirectional in that it knows rotation, the counter bottoms out at 0 then freaks out. I have tried mode 10, my count stays valid but I have no way to see the rotation has changed. All I need is to turn a bit OFF/ON so that I can make something happen depending on rotation.
 
You can use Mode 20 but don't set it up as an up/down counter but as two up counter and since they are offset by 90 degrees one counter will be higher per scan that the other depending on direction. You can use that to set an direction bit. That is what I was looking into. I've done that with Omron but don't have the code for AD at this time.
 
Thanks for the info. I'll try to work it from that angle tomorrow when I get into the office. I'll let you know what I come up with. If you happen to think of anything, please let me know.
 

Similar Topics

Hello! We have a drum rotation machine controlled by a AB SLC 500. The drum rotation inputs comes from a encoder into a 1746-HSCE. We are using 2...
Replies
0
Views
1,134
Hello! We have a drum rotation machine controlled by a AB SLC 500. The drum rotation inputs comes from a encoder into a 1746-HSCE. We are using 2...
Replies
5
Views
2,245
Greetings, I am trying to get a Incremental Shaft Encoder (white pages attached) to count on my HSC in my 1200 project. I have assigned the first...
Replies
17
Views
12,855
Hello, I am an engineering student and I am having difficulties connecting a Yaskawa SGMAH servo motor encoder to a AB Controllogix High Speed...
Replies
19
Views
3,840
I had an increment encoder (A+ A- B+ B- and Z+ Z-), for checking the encoder I use a PLC with High speed input counter (For example FP0-C16CT)...
Replies
7
Views
7,432
Back
Top Bottom