Sign in to follow this  
Followers 0
matt2822

Counter

15 posts in this topic

I have a micrologix 1000 that has an encoder hooked up to it on the input 0, but the funny thing is is this input is not shown on the ladder logic? But when I unhook the wire it stops working so I know its that input? Looking for some enlightenment

Share this post


Link to post
Share on other sites
Enlightenment will come as we define your problem and question better. You ahve an encoder hooked to input 0 of an ML1000. When you remove input 0 the encoder stops working. How do you determine that the encoder stops? Does the Oscilloscope attached to the wire that was hooked to input 0 cease to have a pusle train? Does some HMi readout stop displaying pulses or counts? It would also help if we knew the encoder make and model as well as oeprating specs.

Share this post


Link to post
Share on other sites
Refer to chapter 14 of your ML1000 user manual. You won't find input I:0/0 in your ladder when using the HSC. What you need to look for in your program are instructions such as HSC, HSL, RAC, HSE, HSD, etc. The HSC instruction is what sets up your high speed counter (your encoder input). Channel 0 has a hardware counter that functions independently of your PLC program, so input pulses are not lost if they arrive mid scan. The HSC instruction enables the hardware counter, and each time it is executed it updates an image of the hardware counter in C5:0 with the values coming from the hardware counter. In other words, the high speed counter is still counting between the times when the HSC instruction is executed, but C5:0.ACC is not updated until the HSC instruction is scanned. Using HLS and HSE instructions you can cause an interrupt subroutine to interrupt the user ladder and run the subroutine when a certain count on the hardware counter is reached. A full explanation is beyond the scope of a single post, so I recommend you read chapter 14. If you don't have the manual you can get it from the literature library on AB'w web site. Edited by Alaric

Share this post


Link to post
Share on other sites
Alaric, That makes sense, thanks for the help, will be sure to check out chapter 14 of the manual, thank you also BobLFoot Here is something else that perhaps you Gents can save me some time on, Im trying to add to the preset of the counter by having the operator trigger input one that then adds 1 to the C5:0.PRE, but it seems to always go in multiples

Share this post


Link to post
Share on other sites
If the trigger stays true for more then one scan it will continue to add 1 each scan. Consider a one-shot before the add instruction. Post your code and someone can take a look.

Share this post


Link to post
Share on other sites
Also, you probably shouldn't be using the C5:0.PRE (depends on the application). The HSC accumulator is updating continuously, but C5:0.ACC only updates on scan. Use the HSL and HSE instructions to load a preset value to the hardware counter. When that preset is reached the hardware counter will generate an interrupt. The HSE instruction enables the interrupt. That way our program will respond as soon as you reach the HSC preset, not wait until the C5:0.ACC is actually updated whenever the program scan gets back around to it.

Share this post


Link to post
Share on other sites
I suspected that and tried to use a timer but I don't thing the timer resolution on the ML1000 would let me get it where I need it. I tried the one shot but I don't think I addressed it correctly. I attached the program PVC_W_PV300_FINISHED.RSS

Share this post


Link to post
Share on other sites
HMM? I think I would have put the add instruction on the same rung as the input and OSR. But what you have should work. You might try increasing the filter time for the input. You may have to move to a different input so as not to affect your encoder input. See picture below

Share this post


Link to post
Share on other sites
Gave it a shot but even with the OSR and adjusting the filter the lowest I can get it to add is 6, which is better than what I was getting, but need it to be one

Share this post


Link to post
Share on other sites
It sounds to me like the input device you are using is electonically noisy. Instead of your one shot driving the B3 flag bit to add the counter try this. BST XIC Input NXB XIC T4:0/DN XIO T4:1/DN BND TON T4:0 1/2 second XIO Input TON T4:1 1/2 second Use T4:0/DN to drive the one shot and the B3 bit. See what count this give you. Sorry - I am at home and cannot post a logix file.

Share this post


Link to post
Share on other sites
I think I follow you on this when you get a chance could you post the logic

Share this post


Link to post
Share on other sites
Check out T4:6 thru T4:9 and B3:5/1 and B3:5/2. I'll leave commenting and such to you, but the code is laid in as I envisioned it. PVC_W_PV300_FINISHED_Mod_BobLFoot.RSS

Share this post


Link to post
Share on other sites
Thanks, that helped do the trick, the funny thing is instead of subtracting 1 to decrease my preset I had to add a -1. Dont really understand why but when I tried to subtract 1 it made the preset jump to a large negative number and faulted the processor.

Share this post


Link to post
Share on other sites
Now to the nitty gritty. If my modified code does a correct add and subtract, but yours did not then you have a problem with "noisy" inputs. If you can snag an oscilloscope place it on your add input and catch the input pulse. My hunch is you'll see several input spikes before it settles stable at high or low. This means it is time to check your i/o wiring and power supplies. Good Luck.

Share this post


Link to post
Share on other sites
You are correct I did find that my input was generating alot of noise. I decided to make it so that if the operator held the button it kept counting and would eventually start counting by 10's and then 100's, so I had to keep the timers anyway. Thanks for the help, have attached a copy of the logic if you would like to take a look. I ended up putting it at the end of my program. PVC_GUIL_FINISHED_WITH_LABLES_again.RSS

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