Followers 0

# Speed/ Velocity Calculation

## 5 posts in this topic

Hello, I hope you are all having a great Wednesday.  So I was wondering if this is possible, and if so, how to do it.  What I'm trying to do is get a real time speed of my hydraulic cylinder using a transducer, a 1769-HSC high speed counter module, and a 1769-L36ERM processor.  Kind of like a speedometer in my car.  I would like the number in inches/ second.

We use a hydraulic proportional valve to control a cylinder that we use to pump molten lead into our die cast machines.  Back in the day they used to use limit switched that rest on a tail rod attached to the cylinder shaft to get an approximate stroke length.  It was very crude, but it worked for what it was.  I'll explain  a little more, in case I'm not explaining it very clearly.

So on most of our machines the maximum stroke length of a normal shot is about 11".  We have different "stages" to the shot.  Stage one is typically from 0" (when the shot is all the way returned) until about 1.5", at 1.5" the valve stops and there is a shot delay for 1 second (vacuum draws some lead into the goose neck and into the beginning of the mold), after the delay second stage starts, second stage is from 1.5" to 4", third stage is from 4" to 8" and fourth stage is from 8" to 11.5" or until the shot timer finishes timing, and then another valve switches, and the shot starts it's return.  We have the different stages because we typically shoot the cylinder slower at first, and then delay and then almost maximum velocity.  We control the velocity with an analog output to a solenoid on a hydraulic valve.  For example, for the first stage we may open it up 20%, then 0% during the delay and then 85% during second, third and fourth.  Sometimes we play around with different shot delay times, different shot velocities, sometimes 3rd may be faster than 4th, ect, to get the best die casted parts.

Anyways, so in the past they would use limit switches.  One was a button head style that when the shot cylinder shaft was all the way returned, it made the switch, and we knew the shot was fully returned.  One was set at 1.5", 4", 8" etc.  They all, except for the shot return switch, were roller style limit switches.  They were all made, and once the shot reached that stroke length, they would come off the rod and we would know we were in that next stage.  So it was very crude.  If you wanted to adjust the stages you would have to climb up on top of the very hot molten lead pot, mark where the limit switch currently was (in case you needed to put it back) loosen the bracket, try to make a measurement and guess how far you moved it.  It was crude to say the least.  Some of our older style machines that don't need much tweaking still use the limit switch style positioning system.

Most of our new machines all use a VisiTrak transducer.  The shot cylinder rod that is attached to the cylinder shaft is actually threaded and then has a very thing layer of chrome plating.  The transducer sits against the shaft and counts the threads.  It transfers those counts to a Very High Speed Counter module in our PLC I/O rack.  We have a CompactLogix L36ERM processor and we use a 1769-HSC as the VHS Counter.  Then we just do some math in the PLC program and we are able to get shot stroke in inches.  We set different compare instructions, for example when: Shot_Stroke is greater than or equal to 0 AND Shot_Stroke is less than or equal to 1.5 then 1st_Stage_Bit is active.  We set up different numbers for all the different stages and still use the button head limit switch as a second method to confirm that the stroke is fully returned.

The counter is very fast.  We are able to know what the shaft stroke is at any given point.  We currently do some math using the distance of each stage and using timers to calculate inches per second of each stage.  That way we can have a nice Speed number in inches/second that we can use to make different adjustments to the shot.  Typically the first stage is about 7"/second second is: 24"/second third is: 42"/second and fourth is 2"/second.  But I want a real-time, current speed, not just the speed that it traveled through each of the stages.

Ok, after all of that explaining, I'm finally getting to my question.  How would I logically write a set of instructions that could give me current speed in inches per second.  Like i said, I am able to calculate the speed of each stage, after the shot has completed the stage, I just divide the distance of the stage (in inches) by the time it took to travel through that stage (in seconds).  But I would like to have a real time speed, kind of like a speedometer on a car.  Is this possible?  I know that the scan time on this processor is very fast and the high speed counter module counts very fast as well.  How do I do the math to get a real time speed in inches/ second?

Sorry for the very long post.  I just thought i would give you a background on what we are doing/ would like to do.

Thank you very much.

##### Share on other sites

From your post, you seem to be interested in determining an 'instantaneous' velocity. I've supplied the definition which holds the key to your question. Given you have no form of feedback that does not require sampled data (counts), a processor and module with inherent delays (scan, data transfer), and the asynchronous timing between calculations and real data value at that instant, you will never have a true instantaneous speed. You can cut your time slice for comparing position counts and as with integration, come closer to an approximation of instantaneous speed as delta T (time) approaches "zero". Capture your delta between positions for a smaller time slice. You will eventually start getting some poor approximations of instantaneous speed when your time slice gets smaller than the inherent delays within your system. Arguably, a truer form of instantaneous speed capture would be a tachometer (analog voltage back to your speedometer reference).

Instantaneous velocity is the velocity of an object in motion at a specific point in time. This is determined similarly to average velocity, but we narrow the period of time so that it approaches zero. If an object has a standard velocity over a period of time, its average and instantaneous velocities may be the same.

##### Share on other sites

Most vehicles use a Mag pickup that pulses each time a gear tooth pases by its sensor and use a similar calculation ad described by ThePEee above to determine speed.  it looks instantaneous due to the speed of the calculation but in electronic terms is actualy delayed by a good bit severaly milliseconds in a typical road car you will have to decide what is a good balance between delay and accuacy for your application

##### Share on other sites

Hi hboyer90,

Assuming the pulse frequency is high enough, you can use the Ctr(n)CurrentRate DoubleInteger which is in the input array of the HSC Module-Defined Data Type.

The HSC module does the rate calculation for you, read the "Rate/Timer-Functionality" topic under "Module Operation" in the Compact High-speed Counter Module User Manual (1769-um006_-en-p.pdf).

The counter’s configured cycle time has to be appropriate and you will have to do some scaling.

In case the pulse frequency is low (which I suppose is not), you can measure the time between pulses and do some calculations.

I confess I haven't done this myself but it seems pretty straight forward.

Hope this helps

##### Share on other sites
10 hours ago, chantecler said:

Hi hboyer90,

Assuming the pulse frequency is high enough, you can use the Ctr(n)CurrentRate DoubleInteger which is in the input array of the HSC Module-Defined Data Type.

The HSC module does the rate calculation for you, read the "Rate/Timer-Functionality" topic under "Module Operation" in the Compact High-speed Counter Module User Manual (1769-um006_-en-p.pdf).

The counter’s configured cycle time has to be appropriate and you will have to do some scaling.

In case the pulse frequency is low (which I suppose is not), you can measure the time between pulses and do some calculations.

I confess I haven't done this myself but it seems pretty straight forward.

Hope this helps

That makes sense, I will look at that article.  Thanks!