Sign in to follow this  
Followers 0
Guest tommyt

Counter Beyond 16bit In Micrologix?

14 posts in this topic

Hello all, new to this site. I am using the Micrologix 1000 and need to count ( to keep track only, not a counter, per say) past 32,767 without an overflow error. Is there an easy way to use the next N7: file to store the carry and have this display say, 32,768? Any help is appreciated, have the same problem with the SLC500 (brick) I have the RSlogix 500 software. thank you, tommyt P.S. Nice site, lots of info!

Share this post


Link to post
Share on other sites
Hi tommyt! Thanks for checking out mrplc.com. Register and stick around awhile.... Back to the question... Basically I would use two counters if it was me. I would use one counter to roll over another.          countup ----------| |------------------------------------|C5:0          |                                                             |pre 9999   |                                                                                                            c5:0/dn ----------| |------------------------------------|C5:1          |                                              |              |pre 9999   |                                              |                                              ---- ---------(RES C5:0) c5:0 would be my 1-9999 number, when that counter was DONE, I would single shot a count up on C5:1. Which represents the 10,000th place digit. So if C5:1 has a 34 in it, and C5:0 has a 5678, then my total number would be: 345,678 Then you can use TWO compares if you need to check for a greater than 40,000 or something like that:                                                             bit to come on when number is higher than                                                                                              40,000 --------------------------|GRT           |------------|GRT             |-----------(   )                                 |c5:1.ACC  |               |C5:0.ACC    |                                 |40            |               |0                 | Hope that helps.

Share this post


Link to post
Share on other sites
Uhh....wouldn't the total be 345,644 ?? (34 x 9999) + 5678

Share this post


Link to post
Share on other sites
Nah..I reset C5:0 when it mets it's preset or goes done. So when C5:0 goes done, a one shot count up of C5:1 increments the 10,000 place, and at the same time, resets C5:0 back to ZERO, so upon a "roll over". C5:1 has a value of "1", and C5:0 has a value of "0" which would represent: 10,000 or 1 = C5:1 = ten thousandth place, 0 = C5:0 Hope I explained that better.

Share this post


Link to post
Share on other sites
Nope. As I see it.... start with both counters at zero, count input off on the 9,999th false-true transition of count input, C5:0 done bit comes on C5:0 done bit increments C5:1 and resets C5:0 (clears done bit) end result after 9,999 counts is C5:1=1 and C5:0=0
1 person likes this

Share this post


Link to post
Share on other sites
Will be giving that a try. Did something similar a while back, had trouble diplaying this to an EZtouch panel. Will try again tomorrow, thank you for the tip. (up to this point I just reset the counter at the 32,767 #) -tommyt

Share this post


Link to post
Share on other sites
Maybe we are on two different pages. I am not counting the actual PULSES. I am creating a "reference" or place holders, an imaginary 10,000 digit. So when C5:1 = 1 like you said, that means to me "10,000" plus what ever is in the C5:0 counter. So if you were to use a panel view, and you put a Numerical Data Display side by side like: C5:1.ACC, C5:0.ACC And you adjusted the spacing on your panel view to "look like" the same digit, but really it's not. Your panel view would display: 1 0000 Of course, the setting for C5:0.ACC tag would need to be "FILL with ZEROS", So if there was only a "1" in C5:0.ACC, then the number would appear as: 1 0001 or 10,001

Share this post


Link to post
Share on other sites
It would certainly seem so. The answer to tommyt's question is, of course, to use cascaded counters and it is convenient to have the cascade working to a power of 10. The point I'm trying to make is that the ladder code you posted yields an apparent value of 10,000 for only 9,999 operations of the input "countup". The C5:0 done bit will come on when the accumulator reaches the preset (9999), not one count later. Change the preset to 10,000 and it will function as you describe.

Share this post


Link to post
Share on other sites
Hi Guys- I think the MicroLogix 1000 is capable of doing a limited form of 32-bit math. Page 8-5 of the MicroLogix manual at www.ab.com talks about this. http://www.ab.com/manuals/cp/1761-um003a-en-p.pdf You have to babysit the carry bit and care of the most significant word. You also have to set status bit S:2/14. But it can be done. The question then becomes, what can you do with it. If the display device you are using doen not have the capacity to read two words from a MicroLogix and put them together to form a double you are still pretty limited. The least significant word will also be displayed in twos-complement format even if S:2/14 is set. This mens that even though you KNOW the value is supposed the be 32768 the plc will display it as -32767. Also, compares of the doubles in the plc will get kind of complicated since the compare instructions are all 16-bit signed instructions. One last issue is I think S:2/14 affects all signed math in the plc. So be careful with this as it may mess up more than it fixes. I guess what I'm saying in as many words as possible is that Chris's suggestion of displaying two counter addresses next to each other is probably the best idea. It allows you easier data manipulation and doesn't have any serious side effects. Keith Edited by Keith Menges

Share this post


Link to post
Share on other sites
Thanks, guys. used the 2 counters, only rolled over the first counter at 1000. The reason was that I could only get the 2 counters on the display so close, the 3 digits are slightly separated with numbers over 1000, like a space which would appear if I could use a comma. Thanks again for getting me on track. (Sure is a lot easier in Mitsubishi to add a D in front of a data register and use 32 bits!!) Maybe A/B will make this easier in the future. I can't believe I'm the only one who counts widgets!! tommyt

Share this post


Link to post
Share on other sites
Only the older MicroLogix 1000 controllers still have this limitation; a MicroLogix 1200 or 1500 happily uses a 32-bit "Long Integer" element. I dunno if the MicroLogix 1000 will ever be changed to use similar firmware to the 1200/1500. More likely there will be a fixed I/O "MicroLogix 5000" that will run the little Logix engine that A-B built for the CompactLogix controller.

Share this post


Link to post
Share on other sites
Hey Gerry, Sorry about that...I was going one direction, you were going another direction trying to tell me that my counter presets were off. Your correct about that. My apologizes. I was still stuck on trying to explain how it worked and over looked the presets. Thanks for pointing that out. Two heads are always better than one.

Share this post


Link to post
Share on other sites
Logic to "count" from 1 to 65536 using AND and XOR statements to replace ADD/SUB statements. For single event counter app, move CTU.ACC to N7:11. --- Rung Comment >>>>> 16-BIT ADDITION OF RELEASE PALLET CASE COUNTS >> N7:10 - Count Display (Flickerless), N7:11 - New Count Quantity, N7:12 - Actual Case Count (Working), N7:13 - Carry Bits > >> AB PLC Add/Sub functions are limited to 15-bits w/signed 16th bit, ie limited to count to only 32767. >> However, PanelViews, PanelMates, WonderWare and RSView can display 16-bit integers allowing counts displays to 65536. >> Following logic adds new count N7:11 to existing count N7:12, Result displayed from N7:10 to eleminate flicker during addition. > --- Logic, 3-rungs (Use in place of Add/Sub command) LBL 1 NEQ N7:11 0 BST AND N7:11 N7:12 N7:13 NXB XOR N7:11 N7:12 N7:12 NXB CLR N7:11 NXB OTL B3:0/0 BND BST NEQ N7:13 0 BSL #N7:13 R6:0 B3:0/1 1 NXB XIC R6:0/DN BST MOV N7:13 N7:11 NXB OTU R6:0/EN NXB JMP 1 BND BND BST XIC B3:0/0 NXB XIC S:1/15 BND BST MOV N7:12 N7:10 NXB OTU B3:0/0 BND
1 person likes this

Share this post


Link to post
Share on other sites
Logic to count with 32-digit display in N7:0 & N7:1 (Note: CTU presets set to "-1") --- Rung Comment >>>>> 16-DIGIT SINGLE EVENT COUNTER (C5:0) w/OPTIONAL 17-32 BIT DISPLAY > >>> SET COUNTER PRESET TO -1, THIS WILL ALLOW PANELVIEWS, PANELMATE, WONDERWARE, AND RSVIEW >>> TO DISPLAY COUNT FROM 1 TO 65536 (-1). > >>> Note: COUNTER.OV BIT WILL TURN-ON AT 32768, COUNTER.DN BIT WILL NEVER ENERGIZE. >>> In this example, C5:1 is the counter bits 17-32. >>> If bits 17-32 are not needed, replace the CTU C5:1 instruction with a OTU C5:0.CU instruction to advance the C5:0 "zero" count to "one". --- Logic, 1 rung XIC T4:0/DN BST CTU C5:0 -1 32760 NXB XIC C5:0/OV EQU C5:0.ACC 0 BST CTU C5:1 -1 1 NXB OTU C5:0/OV BND NXB MOV C5:0.ACC N7:1 NXB MOV C5:1.ACC N7:0 BND

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