File Sort (SRT) and Average (AVE) instructions

Through what? I have a lot of experience, many decades, with hydraulic systems. I am a member of the International Hydraulic Fluid Power Hall of Fame.

Through a saw

What environment? Over 35+ years I think I have just about everything.

Sawmill primary breakdown


What hydraulic motion controller? I design, make and sell hydraulic motion controllers. I am familiar with many of my competitors too.

RMC

What is it pushing against? Again, is there variable friction?
Wood

So you have position feed back or are these position just chosen manually?

The motion controller positions the cylinder in position control mode. I then use the motion controllers event step tables to do the rest. The event steps look something like this.
Step 1 Extend Full stroke out normal speed out until load cell is over setpoint 1
Step 2 Retract cylinder at slower speed until load cell is under setpoint 2
Step 3Hold current position, but if load cell goes over setpoint 1 then go to step 2

I was originally planning on using the motion controllers force control mode, but in the end on the advice from the RMC people I ended up using event steps and have been much happier with the performance.


What values?
Right now I am looking for a range of 500 which is about 10% of the load cells range or greater to determine if the load cell actually picked up the force during the manual move. I didn't want to enter new setpoints into the controller if the load wasn't registering.


]quote]

I could possibly just use a min and max value. However when you move the arm manually it has a tendency to create some spikes as you push and pull it.
Why the spikes? Again, I suspect the friction is variable and you are suffering from what is commonly called slip/stick or Stribeck friction.

I tried to explain below


My thought was with the 600 samples taken every 100ms I would do something like this... Take 600 samples, sort them all from high to low. Knock off the highest 20 and the lowest 20. 20 samples would be about 2 seconds of maneuvering the guide into position Then I would take what was left and average the 20 highest and 20 lowest and see how that works.

[/quote[
Your still aren't clear about what you will do with your high and low numbers.

When I am done with the above I end up with one high value and one low value. The two values are put in the motion controllers event steps table.


I think you need to tell us what the source is of your "noise"?
Is it really "noise" or is it variable friction?

The load cell is very accurate. That is not the noise issue. I would call the noise human error. I am creating a teaching routine to load values into the event steps table. The person doing the teaching will grab the end of the guide while the cylinder and everything is off. They will push it in to the desired deflection. The guide is made of fiberglass and metal. Imagine something like a snow ski. It has an inch or so of deflection from slight pressure on the load cell to full pressure on the load cell. When you move this by hand they could push too hard initially and then back off a little. That is why I have them hold it in the desired deflection for 10 seconds. And then when they let go the fiberglass will bounce a little on the way out creating a value that is under the at rest or "no pressure" value. I am afraid that if I used min and max The min could be too low and the max could be too high. The work instruction will be to hold it at the desired pressure for 10 seconds. My code chops off the lower values for 2 seconds worth of data and chops off the higher values for 2 seconds. As long as the hold it at the right spot for 5-10 seconds I should have a good range of values. I could possibly just remove the 2 seconds of data on each end and then use the max and min... I just felt better getting a more than one data point.



I have a sample of data collected from a a train that I just did. I will post it below and see what you guys think. I look forward to seeing how you would get the setpoints based on this data.
 
Just for fun.
I have worked with Allen Bradley for 30 years exclusively, now I'm retired.
Recently I bought and Automation Direct PLC Productivity 1000 PLC just for learning and I was surprised that they have canned instructions for sorting arrays with just one step.
I wish Allen Bradley will copy this feature from AD.
Besides they can calculate, Average, median, max, min, etc, etc. of an array.
 
Here is some data I just collected from a train mode.
The red line is the data from the load cell. The blue speed line can be ignored. At the start of the training mode the data is flat. Then when I pressed on the shoe and overshot my desired pressure you can see the short spike. Then I held the shoe where I wanted the pressure to be for a few seconds. Then when I let go I nudged the shoe in the opposite direction to indicate what might happen as someone is moving it around. I have also drawn two short yellow lines showing the high and low setpoints that my routine calculated. These setpoints are currently loaded into the event steps table of the controller and are working. What I am trying to do with my PLC logic is take all this data and calculate the two setpoints. I look forward to seeing how everyone else would do this.

data.jpg
 
Last edited:
Wow! That looks like a plot from one of our old RMC100s. I can see it isn't noise. It may be the force required to overcome the initial static friction though. After the arm starts to move the friction is dynamic friction which is much lower and almost zero. Other than that the motion looks smooth.

I can see you have position feedback or is that just force connected to the position to the RMC100 as a position? It looks like you connected the analog signal from the load cell as position input. Can you use the "speed" or rate of change in the load cell reading, the dark blue line, to tell when you are past the static friction part of the move and just use the force when the rate of change is small. I have RMCWin and can read the RMC plot files. I wish you had included the time scale.



I feel you are trying to patch around a problem which may work but it will take a lot of time instead of achieving your goal in the best way.
 
It is an RMC 100. The load cell is going to an analog input on the card.
The spike in the red in the beginning is me overshooting how much pressure I would like to demonstrate why I want to filter parts of the data.

I suppose I could use speed to know it has stopped moving. Get a Range by comparing the low and high values of when the speed has been about zero for a certain time period.

For me that seems to be the bulk of PLC programming. Figuring out something that will work when there are problems.
 
It looks like after the trainer stops pushing that it returns to the original value.

So train mode could comprise several steps:

  • Step 1: start training and do not touch it for 5s
    • those data could be used set a lower limit, so load cell data below that limit, including a small bit of noise, are ignored
  • Step 2: press, and get to holding steady pressure at or near the target value within 5s
    • Step 2.5: If they are not able to get to a steady pressure within 5s, tell them to pull the other way for 2s,
      • the load cell data will go below the limit set in Step 1, and
      • the PLC will indicate when it has detector 2s of those low data,
      • then it will wait another 2s or so, and
      • the program will repeat Step 1
  • Step 3: after 5s to get to steady pressure, with no extended times with values below the lower limit from Step 1, continue pressing at that steady level for another 10s.
    • Step 3.5: if the trainer notices that they vary the pressure e.g. they get a cramp, then pull for 2s and the program will return to Step 1 i.e. the same as Step 2.5 above
    • This is where the program starts collecting data at 10Hz (100ms/sample)
  • Step 4: after 10s at the steady pressure are complete, gradually release the pressure.
    • The program will see the data return to the Step 1 level with very few values less than the lower limit.
At that point it should be possible to calculate the two pressure levels and the setpoints between them.

There could be PLC outputs driving lights or some other indication for what Step the program is in.

I think the only difference between this and what you are doing now is the Step 1 logic to wait 5s before taking data, the the logic to return to Step 1 if the trainer pulls for 2s to indicate a need to start over. Any initial spikes would be ignored because they occur in Step 1; any later spikes would be a reason to return to Step 1.

Then again, I don't really know your process, so this is just one coder's approach to the model I have in my head from what you wrote.
 
Last edited:
There is also a calculation called an "outlier-resistant mean" or "robust mean" that is used to identify outliers (e.g. those spikes). For example see here and here (page 10 of PDF; page 652 of publication); those are applications for photometry and camera calibration, but the mathematical approach should apply anywhere.

It would be ugly to implement in ladder, but not impossible.
 
I suppose I could use speed to know it has stopped moving. Get a Range by comparing the low and high values of when the speed has been about zero for a certain time period.
Yes, use the speed ( rate of change in force ). You can see it is very consistent during normal motion. I would not say stopped is exactly a rate of change of zero. You do need some tolerance. The data gets updated 1024 times a second which is much faster than the PLC can read the RMC. Do you know how to use the step tables? Step tables can be used to test if a value is greater or less then every 1/1024 of a second.

It should be easy to tell when the initial spike is done and when the force spikes because it hit the final obstruction.

I think this will work much faster and easier than your original plan.
Please give this a shot. If you still have trouble, try to capture a plot of both the initial and final spike. Zip it up and then send it to [email protected]. Then call Delta Motion.
 
All very good ideas thank you! I may of met you or spoke with you at some point. I took a training class at Delta's facility a VERY long time ago. We have several RMC's still kicking. Yes I know how to use the steps table. The step tables are where I do the position control using the setpoints for this application.

Yes, use the speed ( rate of change in force ). You can see it is very consistent during normal motion. I would not say stopped is exactly a rate of change of zero. You do need some tolerance. The data gets updated 1024 times a second which is much faster than the PLC can read the RMC. Do you know how to use the step tables? Step tables can be used to test if a value is greater or less then every 1/1024 of a second.

It should be easy to tell when the initial spike is done and when the force spikes because it hit the final obstruction.

I think this will work much faster and easier than your original plan.
Please give this a shot. If you still have trouble, try to capture a plot of both the initial and final spike. Zip it up and then send it to [email protected]. Then call Delta Motion.
 
This is my first time doing ladder instructions with arrays and I was really surprised to find things like Max min etc to be missing. You can get them by adding a sort but I don't understand why they aren't in there as direct instructions.

Just for fun.
I have worked with Allen Bradley for 30 years exclusively, now I'm retired.
Recently I bought and Automation Direct PLC Productivity 1000 PLC just for learning and I was surprised that they have canned instructions for sorting arrays with just one step.
I wish Allen Bradley will copy this feature from AD.
Besides they can calculate, Average, median, max, min, etc, etc. of an array.
 
[Update: fixed red/blue typo]

Yes, some assembly required, and it's not Python, eh ;)? You should find this easier to do in Structured Text. The origin story of PLC comes from relay logic; the handling of multi-bit quantities is definitely hit or miss.

For MIN/MAX in Logix ladder, you can either make an AOI, or do it with a FAL instruction.

Sidebar

Below are the plotted results another approach to looking for "calm" data. The blue are your original data from Post #18; the red are a metric hovers near 0 when the data are relatively calm and larget when the data are jumping around. You could assume you have steady data in that plot when you have a contiguous sequence of some length where the filtered metrics (plotted in red below) are all less than five or so.

The filter parameter is akin to a munged first-order time constant that defines what "calm" means.

See the entire package here; porting to ladder would be non-trivial, but not too bad. Most of the code there is parsing your JPEG for the load cell data and plotting the data; the real guts of the algorithm are the half-dozen or so statements starting around "Here's the beef" here.
data_fixed_plot.png
data_fixed_plot.png
 
Last edited:
P.S. I just realized the incremental nature of that filtered "calmness" approach means you would not have to deal with arrays, min, max, etc. at all: everything it needs can be calculated on the fly each time a new load cell measurement comes in, or every 100ms, whichever you choose.


I.e. you start training mode with no hand on the shoe, the algorithm calculates the low average, and after 10s it turns on a light to show it is complete. At that point the trainer starts pushing on the shoe, which causes the calmness-filter metric to jump, and the program detects this and starts the high average step. It waits for 10 continuous seconds of the calmness-filter metric being less than 5, and then takes that as the high average, and turns the light on again to end training.

You can weight-average the low and high averages to get the low and high setpoints; that is actually going to be more consistent than the "averages of N highest and N lowest" because the character of those N extrema are going to be affected by the sharpness of the transitions out of the held position and into the released position.
 
Wow. I can't believe you took the time to code all of this up. How generous. I am also impressed that you were able to write code to import data from a image. Want a job? LOL I wish I had someone as talented as you working for me!

I have dipped my toes in python so this is a great thing to use to build my skills a little more. After the holiday weekend I want to try this and see what I get out of it.

Thanks again!


[Update: fixed red/blue typo]

Yes, some assembly required, and it's not Python, eh ;)? You should find this easier to do in Structured Text. The origin story of PLC comes from relay logic; the handling of multi-bit quantities is definitely hit or miss.

For MIN/MAX in Logix ladder, you can either make an AOI, or do it with a FAL instruction.

Sidebar

Below are the plotted results another approach to looking for "calm" data. The blue are your original data from Post #18; the red are a metric hovers near 0 when the data are relatively calm and larget when the data are jumping around. You could assume you have steady data in that plot when you have a contiguous sequence of some length where the filtered metrics (plotted in red below) are all less than five or so.

The filter parameter is akin to a munged first-order time constant that defines what "calm" means.

See the entire package here; porting to ladder would be non-trivial, but not too bad. Most of the code there is parsing your JPEG for the load cell data and plotting the data; the real guts of the algorithm are the half-dozen or so statements starting around "Here's the beef" here.
 
That Github repo has been updated:

  • Added a load cell data emulation routine in Python to detect when the training routine is ready (i.e. every 100ms) for the next load cell value and send the data from the red line of the image plot to a PLC using pycomm3
  • Added the PLC ladder logic (RSLogix 500; Studio/Logix will be similar) that implements the low-pass/high-pass filter algorithm to detect when the load cell value has been "steady" for ~10s
With the emulated data from the image plot and a filter parameter of 0.965*, the training routine comes up with values around 183, 273, and 184 for the first three steady regions; the units for those load cell proxy values are pixels offset from the bottom of the image plot.

Bottom line:

  • this code, although more efficient than the OP's sort-and-average algorithm, is pretty ugly.
  • Also note that a slow drift in the applied pressure on the shoe would still be interpreted as "steady."
  • If sort-and-average can be made to work, or @Peter Nachtwey's speed-based approach, and either is reasonably clean, then I would go with that.

* At 100ms+ per sample, I think 0.965 is equivalent to a first-order time constant of somewhere near 3s.
** which is essentially the same, mathematically, as mine, with my the filter calculation acting as a proxy for the speed value
 
Last edited:

Similar Topics

I have a machine with a tag called SP_FLT[57] with a data type of DINT. Each bit in each DINT is a machine fault of some sort. I need a way to...
Replies
12
Views
3,446
Working with a customer today and they have qualified a bunch of changes today on this 1756-L73 v20.01. It crashes with a "fatal application...
Replies
26
Views
10,546
Hello. I appreciate the insights here and the willingness to share. I've got a lot of Rockwell experience, but my Siemens experience is...
Replies
6
Views
133
Hello I am writing to request assistance with obtaining a specific GSD file for our Mitsubishi inverter type A800-E, which is connected to our...
Replies
10
Views
227
Back
Top Bottom