Sign in to follow this  
Followers 0
JohnnyJupiter

Fresh meat: simple program assistance

16 posts in this topic

Greetings to all, A newbie here. I just got my brandy-new MicroLogix 1100 talking to my laptop, so now I'm on to trying to solve a simple problem as a way of getting familiar with the whole environment. I've been a C/C++/C# Microsoft programmer my entire professional career, but I always wanted to learn to program PLC's...so here I go! Here's the problem: Measure how much conveyor has passed a given point. I've got a 16 tooth/rev gear mounted on a shaft over which the web passes, with a prox to count pulses. The geometry works out to 1.0427 feet/rev. When the user pushes a button, start measuring. When the user pushes the same button, stop measuring, do the math, and display the number of feet that has passed between the two button pushes. I think I could count teeth, but the user might wait a couple of hours between button pushes so I'm concerned about overflowing a counter. I estimate it takes 2 - 3 seconds for one revolution of the shaft carrying the gear, so in three hours I could 'see' ~57k pulses. ...and I've got a bunch of questions about using the LCD display, debugging the program on my laptop before deploying, how to wire inputs, ... the list goes on. I've been searching the Web for 15 hours today, got some great but confusing info, figured I'd ask the collective wisdom of the Forum before I spent more inefficient use of time. Thanks so much for your help; I'd be glad to provide any other info that might be useful. Best, JJ

Share this post


Link to post
Share on other sites
JJ having programmed for years you know it is easier to teach someone by debugging their work than by giving them your solution to a problem. It sounds like you have a good plain english definition of your problem. Why not take a crack at writing the code, DO NOT WORRY ABOUT THE OVERFLOW FOR NOW, and post your first attempt to the forum. WE PROMISE TO BE GENTLE when reviewing it and will propose several solutions to handle the overflow once we see how your problem solving mind works. BTW -welcome to the forum and thnaks for participating.

Share this post


Link to post
Share on other sites
Hello BobLfoot, Thanks for the guidance you offered. Today was enlightening and frustrating at the same time...I learned a ton about using RSLogix Micro Starter Lite, but also realized I have long way to go. Okay, per your suggestion I wrote a program, got almost all the features I want but almost certainly wacky as far as execution is concerned. Here it is, first is a flow diagram: The second attachment is a PDF of my ladder logic. Rungs 0 and 1 are an attempt to implement a button that remembers if it was pushed per my requirements: first push starts counting, second push stops counting and then does math. Rung 2 just starts counting pulses, there's going to be a problem with more than 32767 counts but you suggested I ignore that for now...so I did! Rung 3: I'm starting to fall apart...the intent is to move the counted value into a integer register for some math in the Rung 4, where I do some math. All rightk, please rip me to shreds! Here's what I think is wrong so far: 1. I never turn off counting once it's started. 2. I don't display the output on the teeny LCD screen on my ML 1100, but working out the LCD instruction is a job in itself...that's for tomorrow. 3. The counter overflows. CONVEYOR_MEASUREMENT.VER1.pdf Thanks in advance for any suggestions you can provide. My feelings will not be hurt and sorry for being such a dork! Regards,

Share this post


Link to post
Share on other sites
Good start! Assuming I'm understanding what you are trying to do, here are a few corrections to keep you moving. Rungs 0 and 1: I and O addresses are physical inputs and outputs on the PLC. Unless they are wired together, input to output, turning O:0/2 on will not turn I:0/2 on. They are separate entities. If you need the output to be on for some reason (to interact with another piece of equipment), you could instead use the output address on the contact devices, and monitor the output that way. If you don't need an actual output, use an internal bit device, like B:0/0, and save your expensive output for another purpose. Assuming you have them wired together, this still won't quite work, because your scan time will allow the rungs to execute many times while your finger is on the button, meaning that the latching output will come off and on each scan, and will be on after you lift your finger only about half the time. Try looking into the OTL, OTU, and OSR instructions. Rung 2: A counter will only increment once each time the input goes from false to true.

Share this post


Link to post
Share on other sites
Johnny Take a look at the horner OCS and the Zelio programable relay. The zelio has a simulation mode so you can write off line. Both programs can be downloaded. I can send you sample code if you download program. Its a good place to start on PLC programming. Mike Webster Email me mike@martintenvironmental.com

Share this post


Link to post
Share on other sites
Good start, now you just have to learn the plc platform. I browsed you ladder file. Comments Rungs 0 & 1, looks like you are trying to use a pushbutton to toggle and output on and off. If so, may I recommend the following: Rung 0: Use a one shot after the input, to ensure the output only changes once per push. (Is O:0/1 needed, you can always use internal bits B3:0/1 for example.) Rung 1: You need to change the addresses to the same as the outputs. An output can be an input to another rung. So, where you have I:0/2, it should be O:0/2 Rung 2: Same as Rung 1, change to the output address . You need to use the high speed counter, the high speed counter is 32 bit, so max count is: Over 2 million, then you would do the division directly on the HSC.0.ACC with the destination a float, no over runs. Read up on the function files, and the HSC function. TwControls has a file in the download section: http://forums.mrplc.com/index.php?autocom=downloads&showfile=577 that shows an HSC in it, it was written for a ML1200, but the configuration is the same for a ML1100.

Share this post


Link to post
Share on other sites
HI Jeremy, Thanks very much for that info and encouragement. After I posted I went back at it and realized I was using the outputs as 'bit storage', if that makes sense; you're right, that's expensive!. Your suggestion to use an internal bit device came at just the right time and I will dig in tonight. And I will read and understand the instructions you referenced: OTL, OTU, and OSR. If things go well tomorrow I'll post my updated program for further review. With your support and the help of others, I'll get it sorted out. Thanks again for your help. Regards,

Share this post


Link to post
Share on other sites
Hi Ken, Wow you guys (and girls just in case...gotta be PC!) are the best! If I can ever help any of you with C#/C++/C or Web programming, it would be my pleasure. Your suggestion to use the HSC is good. For some reason I assumed the HSC was to be used for something that was really putting out a ton of pulses/sec; in my situation I'm looking at something like 3 - 4Hz so I let my ignorance get in the way. I'm going to modify my program to use the HSC and learn about it along the way. And you and Jeremy must be on the same wavelength regarding bit storage and the one shot instruction, I'll absorb and you'll see it in my next rev of the program. Coupla follow on questions: when you referenced 'function files' I don't know what that means. I haven't had a chance to Google it yet. Also, when I unzipped the HSC file you referenced and attempted to open it, my RSLogix Micro Starter Lite whined about the wrong processor type. I have RSLogix 5000 loaded in my laptop, from a previous contracting experience, could I use that? Or, could you suggest a way I can use RSLogix Micro Starter Lite to read the code? I'm trying to be cheap and avoid spending any more than necessary. Thanks again,

Share this post


Link to post
Share on other sites
The function files are part of the project tree under RSLogix500. Under Controller, you have controller properties, then processor status, then function files, the function files are used to setup various "extra" task the ML1100 can do. I'll see if I can downlowd Tw's file and convert it from a 1200 to an 1100. HSC_4_1100.RSS Downloaded an converted, everything appears to have converted correctly. One more thing, I think your division is incorrect. You stated that you had a 16 tooth gear and one revolution was 1.0427 feet. Your counter is counting teeth, not revolutions. So you need to divide HSC.0.ACC by .06516875 (ft per tooth.)

Share this post


Link to post
Share on other sites
Hi Ken, Much appreciated. I was able to open the HSC function file, thanks for converting it for me. The contents were pretty daunting at first glance and I suspect I'll run into some issues trying to actually use it...but I'm having a blast learning this stuff. Plus, I'm sure a couple of cold brews will upgrade my attitude! Dinner time here in Neuvo England, I'll jump back on the problem later tonight. Oh, and I'm sure you're right on my math being off, once I get the logic working correctly I'll check the numbers out, I thank you for highlighting that issue...I figure that's the least of my problems. Best regards,

Share this post


Link to post
Share on other sites
Glad my colleagues did not let you or me down and were able to give you the guidance to get started. If the 32 bits of the HSC are insufficient you can add 1 rung which when the HSC reaches a preset value does the following. Adds one to an integer or float and then resets the HSC.

Share this post


Link to post
Share on other sites
Hi guys, I decided to cut down on the size of the bites I'm taking at this problem, so first I'm concentrating on the flip flop portion. Here's a snippet of ladder logic I developed tonight: Here's what I think is going to happen, please correct me if I'm wrong. The first time the pushbutton is activated: Rung 0: Bit 0/1 gets set and stays high throughout the program execution. The one shot debounces the pushbutton. Rung 1: Since B 0/1 is set and B 0/2 is not set, B 0/2 gets set...subsequently I'll use this bit to turn pulse counting on. The next time the pushbutton is activated: Rung 0: B 0/1 gets set again, but it was already set so...no impact Rung 1: B 0/1 is set, but B 0/2 is also set, so the top half of the rung is false. For the bottom of the rung, B 0/2 is set and B 0/1 is set, so the bottom half is false. Therefore, B 0/2 gets unset and counting will stop. The next time the pushbutton is activated: Just like the first time, and so on. Did I get this right? Is it true that when a sensor is false on the left hand side of a rung that the coil on the same rung will go low? Sorry to be so long winded and thanks again for your help. If I got this right, then next I'll attack the HSC and function files and suggestions on I how test this program by simulating inputs. Regards, Edited by JohnnyJupiter

Share this post


Link to post
Share on other sites
Almost, but not quite. In your logic B 0/2 will only be true for one scan. On the second scan since B 0/1 and B 0/2 are both high, so the rung will be false. 3rd Scan B 0/1 will be high, and B 0/2 low, so rung will be true again. As written, B 0/2 will change state each scan. The Fix: On Rung 0, change the B 0/1 from OTL to OTE and it will work as you expect, because on the second scan Only B 0/2 will be true, and the lower branch will be true, and keep B 0/2 latched in.

Share this post


Link to post
Share on other sites
Good morning Ken, My you're up and at 'em early today! We're getting some sun here in New England and Spring is on the way...finally! As always, thanks for your suggestion. Upon reviewing my logic it's obvious I had it wrong, so your help is invaluable. It's becoming apparent to me I need to set up a test rig to try this stuff out, so I'm going to get a momentary contact PB, a prox and a gear wheel to chuck up in a drill. Is this the approved way for testing, or is there a way to simulate this? I can't really get at the production hardware until I'm pretty close to having the program working as expected. Last night I wrote a simple program with a counter and fooled around with forcing inputs but it didn't behave exactly as expected. Ahh, more area for study...and I haven't even gotten to the HSC yet, well I did get the two helper programs from your translation of the ML 1200 program into my program. Many thanks to all and , oh yes, I'll be back. A side question: What do the 'warn' percentage and blue progress bars under my name to the left of posts mean? Thanks. Best regards,

Share this post


Link to post
Share on other sites
The warn percentage is what is says, it's an indication of the warnings you have received for bad behavior. 0% is ideal. If your warning level gets high enough, you can be banned from the sight. Warnings are usually issued for violating the sites terms. I believe only you can see your warning level.

Share this post


Link to post
Share on other sites
Hey guys, Just want to thank you all again for the support provided. For the last couple of days I've been dealing with a different job so I haven't been able to get at my new favorite programming environment...hope to get at it this weekend. Best

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