Sign in to follow this  
Followers 0
markn

encoder counting

27 posts in this topic

Hi Folks, I thought this would be a simple experiment. I have an encoder which as far as I can tell is one chanel, one phase. Ihe encoder generates a square wave pattern. It has three wires: power, common, and signal. I hooked it up to a FX2n-64mr with the signal tied to X000, wrote a simple 3 line counter program to fire Y000, when the counter timed out. I am getting nothing, is there a special hookup with the use on an encoder? the encoder is an ACCU-CODER incremental type with 60 pulses per revolution, Could someone show me an example of how to write a program for something like this? Thanks

Share this post


Link to post
Share on other sites
Are the encoder pulses indicated by the plc input LED? Which counter are you using in the program?

Share this post


Link to post
Share on other sites
Hi Sergei, No action on the input LED, and I have tried using a general purpose counter (C0) and also a high speed counter (C235), thinking that perhaps the pulse timing was to fast for the PLC.

Share this post


Link to post
Share on other sites
plc can't act on input it can't see...so.. it sounds like wiring issue, either signal level or polarity don't match or maybe the S/S is not wired correctly. wiring of high speed input is not different from standard inputs (one should just consider when to use shielding).

Share this post


Link to post
Share on other sites
I would say that the pulses are too fast for the PLC to see. How fast are you turning the encoder? I have had a similar problem with a Q-series PLC.

Share this post


Link to post
Share on other sites
I doubt if it's too fast - from the manual: For FX2N & FX2NC Inputs X0 and X1 are equipped with special hardware that allows higher speed counting as follows:- Single phase or bi-directional counting (depending on unit) with C235, C236 or C246; up to 60 kHz.- Two phase counting with C251; up to 30 kHz. 30,000 pulses per second is pretty quick. Just a few simple things to look for: a) There should not be mention of X0 in the programme, just something like: LD M100 OUT C235 K 100000 would do it, where M100 is the (for no reason) bit that enables the counting to happen. (Note that it is different to a normal counter.) b) Is your encoder a PNP or NPN encoder? c) Have you got the S/S terminal linked out? Link it to 0V for PNP or 24V+ for NPN. Leaving it not connected is not an option, as the strangest things can happen.

Share this post


Link to post
Share on other sites
Thanks for the response, do the high speed counters defalt to the X000- x007 inputs? is that why there is no mention of X0 in the program? How can i check the gender of the encoder?

Share this post


Link to post
Share on other sites
The high speed counters are "hardware" linked to various specific inputs, and you need to know which counters are linked to which inputs. You can download the FX2N programming manual at this address: http://194.130.244.64/branch/database/serv...amp;portal_id=1 You can check the type of encoder in the following way: I assume that two of the three wires are for 24VDC+ and 0VDC. These will power up the encoder. (If it takes other voltages (eg 12 VDC) then you would have to interface through a solid state relay as the PLC cannot "see" anything below about 18VDC.) The third wire is the "switch wire" and will EITHER connect 24 V+ ONTO the PLC input and SINK current into the input(in which case it's PNP) and the input will light, OR it will connect 24 V+ AT the input and will connect it to the 0V, in which case it will SOURCE current from the input (in which case it's NPN) and the input will light. Personally, I hate NPN systems, as they seem counter intuitive to me. The other point is that you can't have a mix of PNP and NPN sensors on one PLC (without adding other hardware), they have to be all one type or another.

Share this post


Link to post
Share on other sites
Hey Thanks for the help, I was able to hook up the encoder and get the Input LED to flicker as I turn the shaft. I assume that I will have use the M8235 bit in order to get the PLC to actually count the pulses. I was also wondering if I what to just display the number of pulses, say with a E300 HMI, do I replace the K in the progamr line with a D and then read D register with the HMI< Thanks, again

Share this post


Link to post
Share on other sites
The function of M8235 is the direction in which C235 will count.When on C235 will count down and off C235 will count up. Changing the K to a D would only change the setting value for the count. That is what the counter would count up or down too. You would monitor C235 as an analog numeric. Rodney Edited by Rodney

Share this post


Link to post
Share on other sites
Hi Folks, I'm at it again. The input seems to receiving the encoder pulses, however something is still not working. I am using the counter to trigger an output after 20 pulses. I set the counter constant 20 on the ladder line, but nothing happens, am i missing something. I am also trying to display the counter on a e-300 HMI, using an analog numeric block, noyhing there as well. can someone tell me what is wrong? Thanks.

Share this post


Link to post
Share on other sites
Display the counter value as a 32-bit number with the counter address. And you should get the output at 20 pulses by coding the contact with the same address as the high speed counter. You can also try to high speed counter compare instructions, HSCS (high speed counter set), HSCR (high speed counter reset), HSZ (high speed zone compare). Keep in mind to be 32-bit commands all of these would be prefixed with a D (such as DHSCS).

Share this post


Link to post
Share on other sites
Hi Guys, I am about about to go bald from the hair pulling. Thanks, for your help. I,ve been looking throught the FX2 manual, and realized it is quite a bit different from the Fx3 programming manual, which I started with. One thing I am confused about is the S/S terminal, what is its purpose. Also, I have found some info about using the Run input, I don't recall the run input terminal being on my Plc, it oviously has a run switch, am I missing something?

Share this post


Link to post
Share on other sites
From a previous post regarding the S/S terminal (it stands for "sink" or "source") >>Link it to 0V for PNP (sinking) or 24V+ for NPN (sourcing). Leaving it not connected is not an option, as the strangest things can happen.<< In the early PLCs there was no RUN switch, only a RUN terminal. These days, if there is a RUN switch then there is no RUN terminal (at least not on the FX2Ns) I believe that you can designate a run terminal in the programming software if you really need one, though I've never used it.

Share this post


Link to post
Share on other sites
Hi Guys, Still no luck. I understand the importance of the S/S terminal now and have tried tying it to 0v and 24v, but it didn't make a difference. Must be my humble attempt at programming. Here is the program; 0) LD M8000 1) OUT M235 3) LD M100 4) OUT C235 K20 9) LD C235 10) OUT Y000 11) LD X003 12) RST C235. OK, I've bared my soul, would someone show me what I am doing wrong? Thanks

Share this post


Link to post
Share on other sites
Markn What input is your encoder connected to it should be X0. You are using M100 to count up M100 should be true in order that C235 can count up. There is nothing in your code to turm M100 on or off. The M235 should that be M8235 to tell C235 to count down. Rodney Edited by Rodney

Share this post


Link to post
Share on other sites
First things first .... forget the encoder for now, connect a flying lead to 24VDC+, connect the S/S terminal to 0V (PNP). Then programme the following: 0) LD M8000 1) OUT C235 K20 2) LD C235 3) OUT Y000 4) LD X003 5) RST C235 6) END If you dab the flying lead onto the X0 terminal, you should now be able to see counter C235 count up. When it gets to 20, output Y0 should come on and be reset when you touch the X3 terminal. The logic is .... when you get a problem that may be caused by a host of things, simplify it and test what you know. If this programme works with you taking the place of the encoder, then the problem may lie with the encoder.

Share this post


Link to post
Share on other sites
Hi Colin, I had suspected that the encoder was not working, so I hooked it up to an O-scope and was able to see a nice square wave pattern. Anyways, I tried your suggestion and proved that the code was working. I now think that it is the way that I have the encoder hooked up. I did some more nosing around and have learned that the output for this encoder is "pull up resitor type", would that be the sorce of my problems? Thanks

Share this post


Link to post
Share on other sites
Well, now all you have to do is stick one probe of a volt meter onto the "switch wire" of the encoder. Connect the other probe to the 0VDC terminal of the PLC and see if you have 24VDC+ on the switch wire. Slowly spin the encoder and see if you have 24 VDC+ appearing and disappearing at the switch wire. If you can then the encoder is PNP, so connect S/S to 0V and it should work. If you can't see any 24VDC+ at the encoder switch wire, then it may well be NPN, so connect the S/S terminal to 24VDC+ and try again. If neither of those options work, then you need to really read up on the wiring of the encoder to see what's going on. Try to use logic to fault find the wiring as well as to write the programmes. Break things down into manageable, testable chunks, and quite often, you can solve the problem just by thinking about it.

Share this post


Link to post
Share on other sites
before you do so, check encoder output voltage rating (you don't wan't to connect 5V output to 24V circuit...)

Share this post


Link to post
Share on other sites
:Hello All, Its working, thnaks for your support. I think it was a combination of wiring and programing errors. I have a nother quick question, when begining a project, do most of you start with a flow chart type layout and then begin working out the programming or does one just begin by writing out the process lin per line?

Share this post


Link to post
Share on other sites
congratulation on getting it to work... as for starting projects, i prefer to use excel to list everything (I/O, alarms, sequence, any calculations or sizing, generating code, traking of changes and revisions, contacts etc.). flowcharts are great for teaching etc. but too slow to use efficiently in a computer (just formating and cosmetics take too long, i can renumber things in excel in a snap). once the planing is more or less complete, "programming" is just straight data entry that can be done by almost anyone (or group of people doing different parts). passing project to someone else is much less painfull as just about everything is in a single file (even contacts, scanned hand sketches etc.) and it's common format (everyone has office installed).

Share this post


Link to post
Share on other sites
Hello panic mode, could you share an excel file example of a project and eventually the project? I make the program first and then try to make a chart of registers I've used. Can you give me some advice of how to make the program easier to understand and to maintain? Thank you.

Share this post


Link to post
Share on other sites
first i make an I/O list and sequence of operation, next step is making list of alarms every I/O must generate some sort of alarm. most alarms in my programs are watchdog timers but not all. some alarms are created straight from inputs (low pressure, overloads tripped etc, as well as monitoring of the safety functions like e-stop pressed, gate open etc.). next come blocks of alarms realted to motion, communication etc. for example just one servo axis can have anything from few dozen to few hundred alarms. this is where excel can help, it can be used to generate addresses, comments, alarm numbers, clone groups of alarms (like if more than one axis is present) etc. once the data is in excel, it is easy to manipulate, generate import lists for the PLC, do calculations (power consumption, spare i/o, transformer load, keep track of revisions, color code important or things of interest etc.) it doesn't do anything on it's own, it's just a tool that if used properly can save time and keep things organized - very important if project is to be shared. or passed on. this is why i prefer programming software that allows quick import/export. in fact this is one of the features i value most in any product.

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
Sign in to follow this  
Followers 0