Scaling steps per inch

Awhile back motivated by the need to make several hundred wiring harnesses I built my most useful project to date. A wire cutting machine based on this one from element14: Arduino Automatic Wire Cutter and Stripper - YouTube

Of course I made a few changes and upsized it to handle 1000' ft wire roll's : Wire cutter and stripper - YouTube
This has been super reliable and it has cut ~8k ft of wire so far ;D Though I never finished the UI and just made it multiple choice for the sizes we needed.

I now want to finish the software so I don't have to hard code the sizes anymore. This is mostly a matter of getting it done but there is one issue left to solve.

Wire Diameter
Basically a larger diameter wire requires more steps per inch. I have worked out a calibration routine, but it would be nicer if I could just input a diameter and have a formula coded that solves for the number of steps per inch needed, but this is beyond my math skills.

Yesterday I carefully calibrated the wire sizes I have on hand.

Diameter | steps per inch

0.135" 397

0.115" 309

0.075" 269

Can this be done?

Take a look at the map() function. It will linearly interpolate between two diameters. And assuming it's not completely linear you'll need two (or more) map() functions and one or more if-statements so you can use the correct mapping depending on the size range.

Which stepper has to vary?

Scaling is multiplication.

Hutkikz:
Can this be done?

That's not a linear relationship so you will need a complex formula.

What about using a look-up table? I suspect there are not all that many different wire sizes. With a look-up table you could have exactly the right number of steps for every size.

...R

The linear measurement is the feed roller.
The OD Of the wire has no bearing on distance . Only the feed roller

Robin2:
That's not a linear relationship so you will need a complex formula.

What about using a look-up table? I suspect there are not all that many different wire sizes. With a look-up table you could have exactly the right number of steps for every size.

...R

Yes, non-linearity is the issue. I was hoping someone knew of a method to develop said formula.

Wire size has been a mixed bag. The first batch of wire rolls used were sourced at different times and suppliers. I didn't realize why at the time but between 4 rolls spec'ed the same there was up to 30 20 steps per inch difference. I wish I would have documented the actual sizes.
The second(current) batch I made sure to get all 4 rolls from a single source at the same time. This batch is a very consistent .075" with no deviation in steps per inch.
As it is I don't think I have enough data points to make a decent look up table possibly could develop one over time but it would take a long time I think.

dave-in-nj:
The linear measurement is the feed roller.
The OD Of the wire has no bearing on distance . Only the feed roller

I made this incorrect assumption also. I didn't figure it out until I picked up a 3D printer and found out they have the same issue with filament dia. messing with their extrusion rates.
But Thank You, you just helped me realize that that software does exactly what I'm trying to do. I just need to dig in there and see if i can find the implementation. Hmm not sure my skills are up for that but at least I have a direction.

EDIT: Actually I'm making assumptions too. I can't explain why it would affect distance just that my data is consistent in showing that it does.

Hutkikz:
I made this incorrect assumption also. I didn't figure it out until I picked up a 3D printer and found out they have the same issue with filament dia. messing with their extrusion rates.
But Thank You, you just helped me realize that that software does exactly what I'm trying to do. I just need to dig in there and see if i can find the implementation. Hmm not sure my skills are up for that but at least I have a direction.

EDIT: Actually I'm making assumptions too. I can't explain why it would affect distance just that my data is consistent in showing that it does.

The feed roller, like your car tire, does not care what the surface is that it contacts. your car tire rotates X times per mile regardless if you are on dirt, a bridge or a highway. as long as the surface is not altered and your tire circumference is not altered.
The feed roller circumference is exactly the calculation that determines distance.
if the feed roller compresses due to pressure, then the formula would change based on the new circumference.
if the wire slips in the roller for some reason, then the result would be changed.
search for rope distance counter. no reason you could not get an idler with some spring tension and get a more accurate reading.
since your data is showing a repeatable and consistent difference, then there is a needed correction factor in the formula. the goal would be to find what alteration occurred to the feed roller, then correct for that in software, or correct the problem in hardware.

The fact that two wire spools with the same diameter (though maybe insulation isn't the same) need a different number of steps strongly suggests to me that the issue is mechanical - slippage, roller tension, missed steps or whatever.

In consequence, I don't think that you will find a formula to solve your problem.

Hutkikz:
...it would be nicer if I could just input a diameter and have a formula coded that solves for the number of steps per inch needed...

...Can this be done?

Yes.

Assuming that you are not dissuaded by the previous comments and still want to take this approach...

...one simple way is to plot the data in Excel and then use Excel's "trendline" to determine the formula.

If you try it with the current three points, you will see that a 2nd order polynomial perfectly fits the points, but it doesn't behave well. You need at least one more point (between 75 and 115 mils). The more points, the better, obviously.

Click "Display Equation on chart" to show the formula. Also, the "R-squared" gives you some idea about the goodness of fit; closer to 1.00 = better.

dave-in-nj:
if the feed roller compresses due to pressure, then the formula would change based on the new circumference.

This could very well explain whats going on. I am highly confident all slippage issues were addressed long ago and yes consistency and repeatability are spot on.

There is no formula now just steps per inch based on the measured result and the correction factor is what I'm hoping to find. It is not linear.

I could try using a spring instead of a bolt to apply pressure to the rollers. It may be worth a shot.

wildbill:
The fact that two wire spools with the same diameter (though maybe insulation isn't the same) need a different number of steps strongly suggests to me that the issue is mechanical - slippage, roller tension, missed steps or whatever.

In consequence, I don't think that you will find a formula to solve your problem.

It was 3 spools spec'ed at 18awg 300v each showing a different OD meaning that the insulation was not the same and each required different steps per inch. The 4th roll's OD was the same as one of the others and produced identical results. There is no slippage.

DaveEvans:
Yes.

Assuming that you are not dissuaded by the previous comments and still want to take this approach...

...one simple way is to plot the data in Excel and then use Excel's "trendline" to determine the formula.

If you try it with the current three points, you will see that a 2nd order polynomial perfectly fits the points, but it doesn't behave well. You need at least one more point (between 75 and 115 mils). The more points, the better, obviously.

Click "Display Equation on chart" to show the formula. Also, the "R-squared" gives you some idea about the goodness of fit; closer to 1.00 = better.

Now we're talking! Unfortunately I've never used anything like Excel and had to look up exactly what a 2nd order polynomial is. Is there any chance I could impose on you? I have some 3D printer filament here that measures .069" that might run thru it ok. Would that give you enough to go on?
In either case Thank You.

There are a number of online curve fitting website, too. Here's a free one: https://mycurvefit.com/

69 mils is rather close to 75, but it's better than nothing...

DaveEvans:
There are a number of online curve fitting website, too. Here's a free one: https://mycurvefit.com/

69 mils is rather close to 75, but it's better than nothing...

I had a play with that site and the basic exponential curve looks closer to what I would expect. The 2nd order polynomial has a dip that doesn't look right. Of coarse I have no idea what I'm looking at and even less of one on how it could be implemented in my program.

Any tips on how to translate any of this into code?

stepsPerInch = 263.7934 + 0.09048765e^(+54.03291wireDiameter)

If the curve pictured above is the correct one than this should be the equation to use?

I don't understand the center section " *e^ "

"e" is the interesting Euler number, approximately 2.718
In your code, to get e raised to the x power, or e^x, use the function exp(x).
So...float stepsPerInch=blah+blahblahexp(54.03wireDia);

float stepsPerInch = 263.79 + 0.09 * exp(54.03*wireDia);

So this is it then? Assuming of coarse that this is the correct curve.

I will try to get more data points and try to refine this further.

You have been a great help. Karma to ya :slight_smile:

Would this work as well?
to keep stepsPerInch an integer.

uint16_t stepsPerInch = (26379 + 9 * exp(5403*(wireDia * 100))) / 100;

You're welcome. Yes, the float formula looks ok. Regarding the integer-ized formula - I don't know. Give both a try and see if they give the same results. But my hunch is that speed and program size is not all that important for your application; if so, I'd stick with floats.

@Hutkikz, I don't think you have ever told us what is the maximum acceptable error in the measurements.

If you apply a formula you will have to do a lot of tests with different samples of wire to verify that it is giving the required results. Note that it would NOT be sufficient to verify the formula using the same rolls of wire from which the formula is derived.

It still seems to me that a lookup table would be the simplest option. If you get a new roll of wire you can run off a test and, if necessary, add another entry to the look-up table that's specific to that roll.

...R

DaveEvans:
You're welcome. Yes, the float formula looks ok. Regarding the integer-ized formula - I don't know. Give both a try and see if they give the same results. But my hunch is that speed and program size is not all that important for your application; if so, I'd stick with floats.

Speed is no issue but program size may be. Time will tell. Of coarse if necessary I will have to move to another micro. Thanks again you have been very helpful!

Robin2:
@Hutkikz, I don't think you have ever told us what is the maximum acceptable error in the measurements.

If you apply a formula you will have to do a lot of tests with different samples of wire to verify that it is giving the required results. Note that it would NOT be sufficient to verify the formula using the same rolls of wire from which the formula is derived.

It still seems to me that a lookup table would be the simplest option. If you get a new roll of wire you can run off a test and, if necessary, add another entry to the look-up table that's specific to that roll.

...R

You are absolutely correct and while I plan to dig up as many different sizes of wire as I can find here the # of data points will still be small.

Maybe the way to go here is to combine all the ideas and have a look up table for known sizes and if the new wire does not match then perform a calibration using the equation to derive the steps per inch for the initial calibration cut. This would require the look up table to be in Eeprom witch I plan to use for saving job data. Hmmm Always with the compromises ::slight_smile:

Thank You!

EDIT: It is already far more accurate than is necessary. After a wire has been calibrated I currently cannot detect any inaccuracy with a tape measure and really +/- 1/8" would be fine. but without calibration it quickly exceeds this. My guess is as long as the equation is somewhat close it would be ok, but as you mentioned verifying this would require more sizes than I currently have.