Sign in to follow this  
Followers 0
vitviggs

speed calculation from encoder position

9 posts in this topic

Hello! I would like someone to advise me how to write a function code which to calculate the speed (in mm/s) of a moving film ,from an encoder position ; in detail, I need to cut the film at a certain position and its speed is necessary in a computing formula for cutter blade action; the speed is variable (due to reel brakes behaviour in low speed), and I would like to calculate the speed at every 20 ms , and to update this value in general cutting action formula; one encoder pulse is one mm traveling of the film; the problem is that I need speed samples at every 20 ms; the encoder position increases from 0 to one certain number when is reset back to zero by a photoeye ; again, as the speed is oscilating i wanna know at every 20 ms the film speed; P.S. I work in RSLogix 5000 thank you! with regards!

Share this post


Link to post
Share on other sites
I have a suggestion for you but for make it work, number of pulse between each photoeye reset must be egal. You can increment a counter each time photoeye have to reset your high speed counter [controller tag]. Then create a periodic task at 20msec rate. In this task use a formula to get speed. Don't forget to write last current count for offset in the next scan (use controller tag and write 0 to it at first scan). e.g. Distance = ((photoeye * pulse_per_reset) + actual count - Last_count_offset) * mm_per_pulse Speed in mm/sec = Distance * 5 //Because 5 * 20msec = 1sec Reset photoeye counter and write current count to offset tag at the end of logic

Share this post


Link to post
Share on other sites
Thanks for your time! Imagine that on the film there is a mark at every 200 mm and that`s the point where I need to cut; when machine is preparing to cut is slowing down the speed at about 100-300 mm/s(varies);to make my blade cut in a fix point(at the mark) I need to know the speed enveloping an entire lenght at at least 20 ms sample (for accuracy); in between two marks(photoeye`s resets occurs at about 0.5 -1.5 s repetition according to the speed) I need samplings every 20 ms of my film_speed tag which then goes in another formula; so , the reset of encoder pulses to zero wouldn`t help in calculation, this period being much larger than the samples I need in speed calculation (between two resets the speed can take a dramatic change and the cutting might be "ordered" at any time inside them); thanks again!

Share this post


Link to post
Share on other sites
If you're using a high-speed counter card, just look at the "Rate" information in the input array. I believe there is an "instantaneous" and an "average" version. That should give you what you need.

Share this post


Link to post
Share on other sites
Rate refresh in HSC card is 1sec and 20msec update is requested

Share this post


Link to post
Share on other sites
Ah. Then I second the periodic task. Since the distance between resets is variable, then can you take the encoder pulses into two channels on the card and use the second channel for the speed calculation? Set up the second channel as rotary with a fixed rollover value that you can use in the calculations.

Share this post


Link to post
Share on other sites
You really should get a M02AE and an encoder that provides MUCH higher resolution. What you have will not work unless your positioning requirements are very lax.

Share this post


Link to post
Share on other sites
I would run the periodic task more often than every 20msec. And its just a matter of saving the encoder value during the transitions of the sensor...there should not be a reset. Then you subtract to measure the distance travelled and deal with the rollover position of the HSC card, Do this every 5ms, and you will exceed spec, as well as have a few sample to average if necessary for display purposes to remove jitter. Resetting the accumulator of a moving HSC value while in motion is almost always a bad idea. Just find the delta of the position...Store that,and accumulate it elsewhere in whole counts...scale into engineering units if necessary, but use the raw accumulated counts in your separate tag for driving the automation it triggers for optimum precision. Your code to do this is about five or six rungs and will run in probably <2ms peak.

Share this post


Link to post
Share on other sites
Uhm, if this is a flying shear, then I retract my other comments and defer to what Peter said.

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