Sign in to follow this  
Followers 0
simon Ong SK

MicroLogix Fast Counter

37 posts in this topic

High Guys: How to access fast counter WITHOUT using the Function Files? MicroLogix 1500 can be expanded to 4 Fast Counter But the Function Files had 2 HSC? Any sample codes?? Thanks Simon

Share this post


Link to post
Share on other sites
What is the origin of such information? Unless you mean extension modules. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Ok, I’m going to post on this one time. The last time it was brought up it turned into a big argument that went no where. Some people here are going to say that you can’t use the additional high speed inputs but I have done it several times with Micrologix 1200s. You must use the EII function file in place of the HSC function file. They are pretty much the same except the HSC function file already has the logic embedded in it. It is actually better to use the EII in place of the HSC function file because it gives you much more capabilities with you counter but they are much harder to program. You can use the EII to get speed, acceleration, deceleration, position error, etc in addition to the count every time a pulse is fired. The EII can only be used on the Inputs in the base unit. You can’t use it on expansion I/O. The lower inputs will count to 20 kHz and the upper inputs will count to 1 kHz. I have physically tested this on a Micrologix 1200 to 13373 Hz. The upper inputs are scan time dependent. Ab Knowledge Base article G84943469 gives you a little more explanation on the Inputs. Keep your code lean in the routines that you assign to your EII. I have never run into any type of watchdogs or inaccuracy problems with these routines and can’t find any documentation saying that there is a limit but there could be one. Simple counters are pretty easy but if you want to use encoders and do complex motion you must have a basic understanding of how encoders work and how to translate the signals into position among other things. Pretty much you will look at the A and B of the encoder and which on turned on last to determine direction then count from there. It also allows you to write code to diagnose that an encoder is bad where as the HSC function file just sits there bouncing between two values. From there the acceleration, deceleration, updating outputs, analog values, position error, in position, etc are very easy to do. You can also use this to make one quadrature encoder on the Micrologix 1200 if you need that much accuracy. It’s really not as hard as it sounds you just need a good understanding of math. Once you learn that you can use the EII to do immediate logic when you get to a position instead of using the normal ladder to look for the output from the HSC or looking at its accumulated value. This gives you faster response time for whatever reason you might need it. Our machines are stopped when the values are reset but there is a problem resetting the values when the counter is in motion. Pretty much the counts that happen in one scan (reset code to reset code) is the variation that you could have in your value when you reset the counter. The HSC with the reset in the ladder code and the 1769-Hsc with a Compactlogix processor actually have this problem too but the error is so small most people would never notice it. The 1769-Hsc user manual explains why. I guess you could use an EII connected to external reset (home) switch to reset the values if you need that much accuracy but you will loose one of you counters doing this. The variation on the reset is minimal for our application so I have never tried this Also there may be a small problem using these with the Micrologix 1100. I have never used one of these with the EII but another person I know has. He says that there is an erratic accuracy problem when making online edits while the Micrologix 1100 is counting but I can’t confirm that. We actually played with one using a 2098 servo. It was very accurate and smooth even though the analog output was only updated at the end of every scan and the direction had to be reversed with discrete outputs. Not as good as the Controllogix but very good for the price. I would suggest people who, how should I say it, are not as good with math or not very advanced programmers stick with the HSC function file. It is very simple and straight forward. And pretty much what you can do with them is only simple stuff. If you are pretty good with math and think you have the programming skills, use the EII. Once you get the hang of it you will never use the HSC function file again. Edit - Looks like a certain person beat me to the post Edited by TWControls

Share this post


Link to post
Share on other sites
Forgot to mention that you must remove the filters off of the inputs in the I/O configuration And I should have mentioned the tech note I pointed to in the earlier post is explaining why 1769 expansion Inputs(even the fast ones) are not as fast as the embedded Inputs

Share this post


Link to post
Share on other sites
Ok, TWControls, why did not you say directly that you mean interrupts. The discussion would not "go nowhere". Of course, this is possible. I only said that there are no more formal high-speed counters available. Couple remarks. Interrupt used must refresh the inputs first. Also, two input interrupts are necessary in order to create a quadrature counter. Another way of fast counting is to have a subroutine which refreshes the input(s) and counts it/them with regular counter(s). It must be called often enough from the main program. Unlike interrups, this may be done with any input(s) on the main unit. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Hi guys: Thanks for the replies ! Yes, with Add On Module (1769-HSC), the AB Technical Data book (Bulletin 1764) stated the module had 4 Single-Input Counters or 2 Quadrature (ABZ) differential Inputs. I’m using it for flow Measurement and control. I need a total of 4 up/down counter. If the M1500 can not support, should I choose SLC5 ?? I’m interested to know the “Normal” Ladder Logic way if the HSC file could not support 4 counters. So If I decided to switch to SLC5, how should I approach or access the Fast Counter module ? Which Function or Command should I used?? Thks agains

Share this post


Link to post
Share on other sites
TW-Thank you for continuing the topic. Because of it I managed to figure out the HSC and basic interrupt operation. Having worked with 8 bit micros, I continue to be frustrated by the lack of speed and variable scan times on PLCs. I now have a new tool.

Share this post


Link to post
Share on other sites
When counting flow meter pulses with a SLC, I prefer the 1746sc-CTR4 from spectrum, it is similar in function to the CFM module for the PLC-5's. The counts are stored in a double word arrangement, and the max counts are somewhere around 8 million. This module makes it easy to accumalate total flow, and flow rate. You can get a four channel card for less than a single HSCE from AB, you can see it here: http://www.spectrumcontrols.com/ab-1746.html

Share this post


Link to post
Share on other sites
Ok Sergei, I said I was only going to post one time but looks like I've got to post again to correct you just like the last forum. I really wish you would quite posting on matters you aren't familiar with. You are causing confusion. First of all, if you had actually read the last post you would have seen I said you had to use methods other than the HSC to do it. I mainly wanted to see if you would go try to figure it out yourself or were just blabbering on. And once again, incorrect statements from Sergei Ignore this whole statement if you are trying to do fast counting. The only thing this leads to is a fast mess. All it leads to is lost counts, watchdogs, and slow programs and is a completely different world from what I'm talking about. Also in theory, I have never managed to do it, the EII will set a fault if it counts too fast. The numerous jumping to sub method does not have this Also one thing he made a little confusing. The EII can be used on any inputs of the base unit. But you are limited by the number of them you can do. You can only have as many EIIs as you have high speed inputs because that is what they were designed to be used on. But they can be assigned to any input And yes simon Ong SK, the micrologix 1500 can do exactly 4 up down counters. That is the limit for 20 kHz counting Edited by TWControls

Share this post


Link to post
Share on other sites
Well, my statement was incomplete. Actually inputs have to be refreshed in the interrupt if the high-speed counter simulated is a quadrature counter and/or a counter with hardware reset from non-interrupt input. I don't know what you will consider a true quadrature counter, but a fully functional quadrature encoder counter with reset can be done with only two interrupts and I have done this more than once. Concerning refresh and count subroutine method. Yes, it slows down the scan but is not intended to count on limit frequencies. It is very good when you need relatively many high-speed counters and the frequencies are on the border between regular and high-speed count. And I want also to assure, that whatever I suggest is always tested in real life, although not always on Allen Bradley. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
Sergei I think you are mistaking an EII for a ladder base interrupt. They are completely different. The EII is fired when whatever input you configure sees a rising edge or falling edge (kind of like an ONS) depending of which edge you configure it for. Doing an Input refresh does no good and will actually severely hurt you. The I/O Refresh instruction not only refreshes I/O but also services the communications ports (for network I/O, Panelview, etc). This typically takes over 1 millisecond without expansion I/O. It gets worse if you have expansion I/O. You have immediately cut your maximum counter resolution to by doing this. UNDER NO CIRCUMSTANCES DO AN I/O REFRESH IF YOU NEED TO DO HIGH SPEED COUNTING WITH THE MICROLOGIX. Here is a definition of a quadrature encoder I found. As you can see to there are 4 state changes. A and B both rising and falling. You end up with 4 times the resolution. Using only the A and B rising is usually called a A-B counter or a count + direction counter. Now some of you are probably asking why not just use a 2000 count encoder in place of the 500 count encoder. The reason for doing this is how the high resolution encoders are constructed. Many of your low resolution encoders will have a steel etched disk inside of it for counting that is nearly indestructible. As you get into high resolution encoders, they go to a glass disk that isn’t nearly as tough. It allows you to do high resolution positioning with more industrial encoder. I have done many more high speed counting applications with the Mitsubishi than I have done with the AB and I promise you that while there capabilities are similar the methods for implementing them are very different. I know where you are coming from with you thoughts but they just aren’t true here. What is true for Mitsubishi is not true for AB and what is true for AB is not true for Mitsubishi. Please make sure the statements you make in a particular section are true for that type of Plc. If you are in the general topics section specify the type of Plc you are talking about to keep the confusion down.

Share this post


Link to post
Share on other sites
Actually I just checked in AB publication 1762-rm001-E-EN-P and you can't do the REF anyway. According to page 17-4 The REF instruction cannot be executed from an STI subroutine, HSC subroutine, EII subroutine, or a user fault subroutine

Share this post


Link to post
Share on other sites
I know how interrupts work. The refresh suggested was not REF but IIM, which only refreshes embedded inputs. Yes, maybe you are right about impossibility to refresh in interrupt, but the manual is clear as mud for this. I'll better try on live PLC and report the result. If this is true, then an A-B counter really requires 4 interrupts (probably even more for hardware reset). In Mitsubishi, however, the refresh in interrupt works and I have done quadrature encoder counter with hardware reset with only 2 interrupts. I will be more careful in the future when suggesting solutions based on different platform.

Share this post


Link to post
Share on other sites
I found it. The IIM will limit you to around 4000 Hz on the counter. Without it you would be able to get the full 20 kHz. An normal A-B counter, which is what 99% of people use, requires 2 interrupts. And yes a precise reset would require a 3rd interrupt. In the high resolution mode, which I must have lost atleast one person on judging by the email I got, you would need 5 interrupts to have the precise hard reset. This mode is seen more on true servo applications. Most don't even know what it is doing but if you have a servo that has 4096 resolution then it is a 1024 encoder or resolver. But realisticly do you really need the interrupt for the reset. All expansion counters have this same problem and there is no real way to fix it with them either. I honestly doubt most people are even aware of this issue. Do any of you have Micrologix applications that require super precision of the reset? Just curious

Share this post


Link to post
Share on other sites
But yes, you can use the IIM in an EII, just doesn't do much good

Share this post


Link to post
Share on other sites
Wouldn't it be limited to 2 since adding direction will take 2 inputs per meter, one for chA and one for chB? Or maybe I am misunderstanding up/down? For the app I am working on I only need to monitor 2 channels without direction, but saw no purpose in using HSC and setting count to 1 to call the interrupt for every pulse. EII seemed the better choice.

Share this post


Link to post
Share on other sites
He is asking about a 1500. It has 8 high speed inputs. 2 for each up/down counter The 1200 only has 4 high speed inputs

Share this post


Link to post
Share on other sites
Thanks TW: Input 0 to 4 have 20khz capabilities. But How can I perform the counting ? The Ladder Logic using "CTU or CTD " or by using "ADD"?? Should I make some adjustment at the Input Filter ? Thanks

Share this post


Link to post
Share on other sites
I have some good sample code I'm debating on whether to post or not. On one hand I am very proud of it. Its definately worth some bragging rights. It not only calculates position, velocity, etc but also has a very nice servo loop in it. We use it to do positioning with AC drive but it is also the code that we used with the 2098 servo. But one the other hand, I'm very proud of it. It took many hours of staring at a eraser board to figure out the velocity curve calculations, gain calculation, etc before I even started writing the program. But let me think about it for a few days. I use ADD and SUB but I guess you could use CTU and CTD if you are more comfortable with that. AND YES PUT THE INPUT FILTERS ON ZERO. THE HSC AND EII FUNCTION FILES WILL NOT WORK PROPERLY WITHOUT DOING THAT

Share this post


Link to post
Share on other sites
simon Ong SK - I lied. In a count up/down application I think it would be better to use the ADD and SUB. The CU and Cd bits would need to be cleared before it would count again. I was thinking that in an encoder application you might be able to use this as your flag for direction but with a count up/down you just use one input for up and another for down.

Share this post


Link to post
Share on other sites
Are the states of the high speed inputs updated in the data table immediatelly? For bi-directional I would assume you would need to know the status of the other input, but I am unsure if a scan would have to take place before it's true status would be availiable.

Share this post


Link to post
Share on other sites
Thats a very good question and I don't have a definate answer but a pretty good guess. I've never actually addressed an Input in the routine. I use internal logic to keep track. And the rungs are and should be unconditional as far as the Input associated with the routine since the Input change triggers it. My first guess would be no. Traditional thinking says that a processor scan consist of Inputs being scanned, then the logic processed, and then the output are updated. But if you look at the worksheet for calculating scantimes, it addresses calculations for additional time for expansion I/O but nothing about the built in I/O. I get the feeling that it is built into the housekeeping overhead. Plus in normal logic you would not want your inputs changing state in the middle of the scan. And the EII does address a normal routine. And since we bring up that it is executing a normal routine, make sure that you do not put a JSR in for the EII like you do normal routines. It will execute that additional time each scan. Before I started using the EII I used the brute force method of multiple scans of the routine. When I converted to the EII I left the JSR in there. Took me forever to figure out why my values were not accurate.

Share this post


Link to post
Share on other sites
Actually I thought you were doing an Up/Down Counter. On those usually one input is Up and one is Down. You shouldn't need to address the other Input. Or is this something else you are thinking about? Also your 1500 has 8 high speed inputs. The 1200 has 4 Edited by TWControls

Share this post


Link to post
Share on other sites
TW: The Input Filter had various value including one default. There is no Zero. So should I enable the "Input Latch"? The cTU and CTD acc value were not match with count using ADD ! ADD value had higher count ! hope you can share your experience with us. Thks

Share this post


Link to post
Share on other sites
Sorry should have been more specific about the filters. Set them at their lowest settings(25 uS on the 1200, not sure about the 1500) I posted this earlier in this thread - You ADD/SUB values are probably correct

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