Correctly utilizing encoder with PLC

zblum

Member
Join Date
Mar 2016
Location
Ohio
Posts
38
Hey guys, I need some help, as I am VERY confused.
I am merely trying to track bottles on a conveyor line using a Bit Shift function, with a photoeye setting the value of the passed bit, and an encoder pulse triggering the actual shifting of the data. I am relatively new to PLCs and haven't really used encoders before.
My initial thought was that if the encoder pulsed multiple times during the course of 1 logic scan, I would not be able to track every pulse. So I selected hardware such that encoder pulse time>logic scan time. I bought a 60 ppr encoder, which gives me ~0.25" resolution in regard to the conveyor line. With the speed our conveyor runs at, I should get a pulse every .0172 seconds. I changed the response time in my MicroLogix 1200 to 25 microseconds to better catch pulses. I believe my logic scan times now sit around 0.0005 seconds.
But I have a problem: my pulse counts are too low at high speeds. Let's say that at low speeds I measure 2 feet to be equal to 96 encoder pulses; if I then count pulses at full operating speed, I may only count 75 encoder pulses for that same 2 feet.
I am assuming I am missing encoder pulses out the wazoo. Is my entire approach to this problem wrong?
I have attached a trend from the PLC showing the distribution of encoder pulses AT A CONSTANT SPEED, as well as my simple logic to "catch" pulses.
Thanks

ENCODER LOGIC.PNG ENCODER PULSE TREND 2.jpg ENCODER PULSE TREND A&B.jpg
 
Last edited:
You need some more info. Get this manual 1762-rm001_-en-p.

It will show you how to use the high speed counter in the Micrologix 1200.

Can you use the HSC to just send a "pulse"?
I don't need to know the actual encoder count, just a consistent pulse to pass data to a BSL.
 
If you need a just pulses for your bit shift, you can use your fast inputs, but device that generates pulses must be equally fast or even faster.

So you are saying that instead of

scan time > time between pulses instead of time between pulses > scan time ?

Or in other words, I need more pulses per revolution?
 
If you are using normal inputs the program needs to be scanning at least twice as fast as the pulses are coming in or you will lose some. You can work around this using hardware interrupts to execute your code.

If you are using a hardware pulse input, it will count the pulses outside of the scan cycle for you and you can use a frequency that is only limited by the hardware.
 
Maybe I'm not understanding this correctly, but why not use the photoeye to set and shift the data? What are you trying to get from the bit shift? In my head I'm imagining the data being used as a fill/no fill type of thing. Or am I just enjoying the chorus of voices in my head again?

Bubba.
 
you need to use the proper high speed counter instruction and connect to the correct inputs to match. also look up a using a shiftleft regster not a bit shift.
 
If you are using normal inputs the program needs to be scanning at least twice as fast as the pulses are coming in or you will lose some. You can work around this using hardware interrupts to execute your code.

If you are using a hardware pulse input, it will count the pulses outside of the scan cycle for you and you can use a frequency that is only limited by the hardware.

Gotcha. Could you briefly explain what hardware interrupts are?
Would a "hardware pulse input" be the HSC on Allen-Bradley controllers? Or is it a separate card?

Maybe I'm not understanding this correctly, but why not use the photoeye to set and shift the data? What are you trying to get from the bit shift? In my head I'm imagining the data being used as a fill/no fill type of thing. Or am I just enjoying the chorus of voices in my head again?

Bubba.

I am dealing with bottles that are irregularly spaced and conveyor speeds that are never exactly the same. I am not sure what you mean by using just the photoeye; I need some way to "store" bottle position data (on the conveyor, for up to 20 bottles at a time) that would not be thrown off by a sudden shift in conveyor speed. Hence, why I am not even trying to use timers.

you need to use the proper high speed counter instruction and connect to the correct inputs to match. also look up a using a shiftleft regster not a bit shift.

Could you please explain a little further on the "proper" HSC instruction?
Would I use "mode 0" with a high preset of 1, or would that be effectually what I am already doing?

Thanks guys
 
I am also interested in the preferable method to work around this, even if there are a few options.
The encoder should only be pulsing at about 60Hz {(60 rpm*60 ppr)/(60s/min)}. Even with a maximum scan time (in 100 microseconds) of 14, I am still not catching all of the pulses. From the research I have done, 60Hz shouldn't be that bad.
Do I need to change how I actually try to catch the pulses with my logic? Again, I want EACH encoder pulse to shift the binary file.

Edit: Possible solution?
Would I use the HSC, mode 0, and set my High Preset to 1? This way, every time the encoder pulses, it also resets the accumulated value.
I would enable the interrupt by setting UIE to 1, and then store the logic I want executed with the interrupt in the HSC ladder file with an INT command as the first object on the rung?
 
Last edited:
ZBlum> Gotcha. Could you briefly explain what hardware interrupts are?


In the computer world, an 'interrupt' is just that. Kind of like somebody taps you on the shoulder and says you need to do 'this'. So you stop what you are doing, do 'this' and then go back to what you were doing.

In a similar fashion, there should be a way such that when your encoder pulse comes in your PLC will stop what it was doing and deal with the encoder pulse then go back to what it was doing. Perhaps, the 'interrupt routine' will, when the encoder pulse comes in, simply increment a counter. Then, when the main program determines that it is time to bit-shift for a product the main program can copy out the current pulse count, compare it to a previous pulse count and insert the appropriate numbers.
MadPoet.
 
ZBlum> Gotcha. Could you briefly explain what hardware interrupts are?


In the computer world, an 'interrupt' is just that. Kind of like somebody taps you on the shoulder and says you need to do 'this'. So you stop what you are doing, do 'this' and then go back to what you were doing.

In a similar fashion, there should be a way such that when your encoder pulse comes in your PLC will stop what it was doing and deal with the encoder pulse then go back to what it was doing. Perhaps, the 'interrupt routine' will, when the encoder pulse comes in, simply increment a counter. Then, when the main program determines that it is time to bit-shift for a product the main program can copy out the current pulse count, compare it to a previous pulse count and insert the appropriate numbers.
MadPoet.

Can I configure the HSC such that it's high preset is 1, and every time it reaches that, it jumps to an interrupt routine and adds 1 to a counter? I just tried some logic to do that (except I set the high preset much higher), and my counter in the HSC file would not increase.
Thanks
 

Similar Topics

Hi Everyone, I am supporting a system which runs on a SLC 500 (1747-L532). A fault has developed whereby the output state of some digital outputs...
Replies
10
Views
987
Hi All, I'm planning to use Rockwell Library, and I am testing the P_AIn block and P_Alarm block for the alarming functionality. I think the...
Replies
2
Views
2,238
I have an issue in Studio 5000 where occasionally a few different tags numbers will change to an -e1.444 for less than a second. I ran the cross...
Replies
15
Views
4,761
Hi, I'm developing a routine to detect and clear a watchdog major fault in a ContolLogix PLC. The software has three tasks and six programs...
Replies
3
Views
2,449
Hi All, I had replaced the drive Kinetix 300 recently due to short within the drive but now seeing watchdog fault. The watchdog timer done bit is...
Replies
6
Views
1,758
Back
Top Bottom