Colin Carpenter

MicroLogix 1100 Frequency Determination

14 posts in this topic

Hi, I wonder if I could ask for some advice regarding the accurate determination of frequency of a pulsing input on a Micrologix 1100. I have a density meter that gives out a pulse train, the frequency of which is proportional to the periodic time of the vibration of the tube. The pulse frequency will be around the 700 hz range. I need to able to accurately determine the frequency (hz or pulses per second) so that I can use this value to feed into floating point equations so that I can determine the density of the fluid in engineering units. The Micrologix 1100 has a single high speed counter (20 khz) related to inputs 0-3, and it has STI ability (Selectable Timer Interrupts), so what I need it to do is as follows: Time 0 ------ Reset ACC Value, start counting up. Time 1000 ms ------ Store ACC Value in register, reset ACC Value, start again. In essence, every 1000 ms, the number of pulses counted by the HSC would be updated into a register and I can take it from there. Sounds simple enough, but having spent a morning reading through the manual regarding HSC and STI, I still can't really "see the wood for the trees". If anyone has done anything similar, I would be grateful for some advice, as the accuracy of this number determines the accuracy of the whole job. Many thanks, Colin

Share this post


Link to post
Share on other sites
I've now sorted out the STI .... just the HSC left to do now, and wondering how to simulate it on the bench ....

Share this post


Link to post
Share on other sites
Just a thought - can you use the PWM function then wire the output back to the HSC input? I haven't used it though so I can't provide any specifics.

Share this post


Link to post
Share on other sites
You don't have to use a Counter in the MicroLogix, nor do you have to use the STI of the controller. The MicroLogix highspeed counter is usually used to trigger outputs directly in hardware, but it can also execute an interrupt to run a Program File when the account hits the High Preset, Low Preset, Underflow or Overflow conditions. There's a nice "Quick Start" for the MicroLogix 1100/1200/1400/1500 HSC on the RA Knowledgebase that describes the Auto-Start feature and the Program File Number (PFN) that gets called when the HSC reaches the High Preset. This is an Event interrupt, which is similar to the STI (timed interrupt) and the DII (discrete input interrupt) in that it executes the Program File right away. So, with a minimum configuration, the routine that you specify in the HSC.PFN field will be executed every N number of pulses, where N = the High Preset value. What you need to do in that ladder routine is measure how much time has elapsed for those number of pulses. The MicroLogix 1100/1200/1400/1500 controllers have a free-running clock whose resolution is 100 microseconds per bit (0.0001 seconds). This value is stored in the Status register as S:4. The increase in the value of this free-running clock between triggers of the HSC interrupt will be the elapsed time in 100 microsecond increments. Let's set the HSC High Preset for 1000. At 700 Hz, it will take 1.4285 seconds for 1000 pulses to arrive. The S:4 register will have increased by 14285, giving you "Seconds per 1000 pulses", which is the Period. The MicroLogix supports 32-bit division with the Long Integer data type, so you can divide 10,000,000 by the number of 100 microsecond increments from S:4 to get the Frequency in Hz. Edited by Ken Roach

Share this post


Link to post
Share on other sites
Wait.. maybe that was wishful thinking with the long division... I'm checking to make sure it works the way I say it will.

Share this post


Link to post
Share on other sites
I like to think I know the MicroLogix pretty well, but sometimes you have to do a little refresher ! I wrote a simple 7-rung program that uses the High Speed Counter in a MicroLogix 1200 to count 1000 pulses then use the elapsed time to calculate Frequency. The program, written in RSLogix 500 version 8.10, is attached to this post. The HSC will work exactly the same in the MicroLogix 1100, 1200, 1400, and 1500 controllers. I could re-do this for the MicroLogix 1000. I have tested this with a pulse train between 100 and 2500 Hz and it works well. Remember that you must change the default filtering on the Input points you're using for the High-Speed Counter; the default value is 8 milliseconds, which would limit your frequency reading to about 62.5 Hz. I used the 25 microsecond filter, which should allow 4 kHz... unfiltered, the HSC can go to whatever the controller supports. HSC_Frequency.RSS

Share this post


Link to post
Share on other sites
Thanks Ken, I'll check out the code in the morning (it's around midnight here) and will get back to you. Only thing is, I might have a problem with the version of the code as I'm pretty sure my version of Logix is V7.x, so I doubt if it will open the file, but I think there's a go chance I can sort it out now ... the info regarding the S:4 timer is invaluable. (I'm a little new to the AB world, having mostly worked with Mitsubishis in my time) Thanks again

Share this post


Link to post
Share on other sites
As a side note - if a questioner's post allows it could those posting RSS files create them for the MicroLogix 1000 or 1100. For those of us at home without the licensed work software we can use the free software to view the code. Better yet for very short logic a PDF of the output could be viewed by those who haven't downloaded the free AB software.

Share this post


Link to post
Share on other sites
Thanks for pointing that out, Bernie. I had a MicroLogix 1200 handy on the desk that I inherited with some burned-up outputs so it was ideal for this test. I'm attaching the program saved in RSLogix 500 version 8.10 for the MicroLogix 1100 (for RSLogix 500 Micro Free users) and as a PDF. The PDF is cluttered with unnecessary Function Files, but should be helpful for Colin. The main drawback I saw in this code is that when the pulse source stops and restarts you don't get an accurate measurement until the second measurement period. I haven't addressed that. Maybe I could compare the .ACC value of the HSC every several seconds and if it doesn't change I call the frequency measurement zero. This was meant just to be a proof of concept. This would be a little more difficult and limited in the MicroLogix 1000, which lacks Floating Point and Long Integer support and has a slower S:4 clock. I'm sure the essential technique of frequency measurement is possible, but it won't be as good. I was surprised that this hadn't been written up as a Knowledgebase document, since it is a fairly common question and it's not a built-in mode of the HSC. If I get some time I'll try to write it up with screencaptures, but time is scarce. HSC_Frequency.pdf HSC_FREQUENCY_1763.RSS

Share this post


Link to post
Share on other sites
Thanks for that Ken, I downloaded the PDF and typed it into my programme, and am still playing with, but while doing so, I realised that there was a simpler way, based on the work I'd done yesterday with the STI (of which the Micrologix 110 has one). Using the STI as well as the HSC means that there are only 2 lines of code, as detailed below. Set up the STI File for 1000 ms with PFN #10 (in my case) Set up the HSC File to count up, with a nominal hi preset of 20,000 (greatly more than expected) and a PFN #11 (in my case) Set auto start on for both STI and HSC so that they always run. When ever the STI timer reaches 1000 ms, it will run PFN #10, so in there type the following lines. MOV HSC:0.ACC F8.0 RAC HSC:0 0 There are no lines to type in PFN#11, but it must be there. Thus, every one second, the number of pulses that the HSC has counted are moved into F8:0. This is now the frequency. RAC (reset accumulated value) resets the HSC ACC value to 0. It seems to work fine with a magnetic switch that I've wired up. Am now looking at taking the pulsed output into the HSC input to test that way. Thanks for the "heads up" on the filtering frequency for the input 0 ... that would never have shown up with my magnetic switch as I can only get to about 15 Hz waving a magnet past it by hand. However, now that I'm using the STI for this purpose, I remembered that my PID loops have an STI or Timed option, and it's a little unclear if the STI in PID speak is the same as the one in the STI file, so I've set them for 500 ms loop update time which is about 20 times as fast as the scan time (the manual suggests at least 10 times as fast) I really appreciate your help on this .... just talking to someone else helps illuminate the black tunnel that my mind sometimes resembles.

Share this post


Link to post
Share on other sites
On ‎28‎/‎10‎/‎2009 at 0:48 PM, Colin Carpenter said:

Thanks for that Ken, I downloaded the PDF and typed it into my programme, and am still playing with, but while doing so, I realised that there was a simpler way, based on the work I'd done yesterday with the STI (of which the Micrologix 110 has one). Using the STI as well as the HSC means that there are only 2 lines of code, as detailed below. Set up the STI File for 1000 ms with PFN #10 (in my case) Set up the HSC File to count up, with a nominal hi preset of 20,000 (greatly more than expected) and a PFN #11 (in my case) Set auto start on for both STI and HSC so that they always run. When ever the STI timer reaches 1000 ms, it will run PFN #10, so in there type the following lines. MOV HSC:0.ACC F8.0 RAC HSC:0 0 There are no lines to type in PFN#11, but it must be there. Thus, every one second, the number of pulses that the HSC has counted are moved into F8:0. This is now the frequency. RAC (reset accumulated value) resets the HSC ACC value to 0. It seems to work fine with a magnetic switch that I've wired up. Am now looking at taking the pulsed output into the HSC input to test that way. Thanks for the "heads up" on the filtering frequency for the input 0 ... that would never have shown up with my magnetic switch as I can only get to about 15 Hz waving a magnet past it by hand. However, now that I'm using the STI for this purpose, I remembered that my PID loops have an STI or Timed option, and it's a little unclear if the STI in PID speak is the same as the one in the STI file, so I've set them for 500 ms loop update time which is about 20 times as fast as the scan time (the manual suggests at least 10 times as fast) I really appreciate your help on this .... just talking to someone else helps illuminate the black tunnel that my mind sometimes resembles.

Any chance you send me the PDF please, as I am embarking on a similar quest.

Share this post


Link to post
Share on other sites
On 6/28/2016 at 2:14 PM, JOHN MCKINNON said:

Any chance you send me the PDF please, as I am embarking on a similar quest.

 

On 10/27/2009 at 11:03 PM, Ken Roach said:

I couldnt find the attached PDF/File any chance to send it to this email  Fiiq143@gmail.com  Thanks.

 

Share this post


Link to post
Share on other sites
On 10/28/2009 at 4:03 PM, Ken Roach said:

I like to think I know the MicroLogix pretty well, but sometimes you have to do a little refresher ! I wrote a simple 7-rung program that uses the High Speed Counter in a MicroLogix 1200 to count 1000 pulses then use the elapsed time to calculate Frequency. The program, written in RSLogix 500 version 8.10, is attached to this post. The HSC will work exactly the same in the MicroLogix 1100, 1200, 1400, and 1500 controllers. I could re-do this for the MicroLogix 1000. I have tested this with a pulse train between 100 and 2500 Hz and it works well. Remember that you must change the default filtering on the Input points you're using for the High-Speed Counter; the default value is 8 milliseconds, which would limit your frequency reading to about 62.5 Hz. I used the 25 microsecond filter, which should allow 4 kHz... unfiltered, the HSC can go to whatever the controller supports. HSC_Frequency.RSS

Hello Ken, 

Not sure you are around here ( its an old post..) at all but if you are could yhou please forward the PDF and .RSS files to my email ?

mi-graine@charter.net

thank you!

Edited by mi-graine

Share this post


Link to post
Share on other sites

Unfortunately that post was when I still worked at Rockwell (I left in 2011) so I no longer have access to those computers or files.   MrPLC has also been through a few upgrades and crashes and restorations so if the files aren't here (and I don't see them in the Downloads section either) then I don't have them anymore.

And, I don't have a MicroLogix to test with either.

If you can describe your application and post your program and describe your specific questions, folks (including me) might be able to offer some help.

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