Scale an axis

I have an analog input that I have connected to a load cell that will weigh parts. I need to make a good interface on my HMI to zero and scale the axis. The zero is easy just set act position to 0 with no load on the weigh scale. The scale of the input is a little different. This is done by putting a calibrated weight on the scale. This value is entered into the HMI and sent to the RMC in Write_Var_8. From there I am calling a user program that does the following Cal.

_Axis[6].PosScale := (Write_Var_8 - _Axis[6].PosOffset)/_Axis[6].Voltage;

I think this is correct based on what I am getting from the help file. The problem I am having is that I have to go through this several times to get it scaled correctly. It’s like the values walk and get closer each time I do through. I zero first then do the scale.

You guys do this in RMC tools all the time. What’s the secret? I think the problem comes from doing one then the other.

I think the problem is that you are not taking into account the voltage at zero weight. Also, you can’t just set the actual position to zero when the weight is zero, because the actual position is in scaled position units, but the scale hasn’t been properly set yet, so it will be wrong. Anyhow, here is how to do it:

From the equation for a line, y = mx + b, the equations for calculating m and b are:

m = (y1 - y0)/(x1-x0)
b = y0 - mx0, or b = y1 - mx1

m is the scale, b is the offset, x is volts, and y is position.

The procedure for calculating these is just like our Position/Counts scaling method:

  1. With no weight (y0 = 0) on the scale, record the voltage (x0), call this something like VoltsZeroWieght.
  2. With the calibrated weight (y1), record the voltage (x1), call this something like VoltsCalWeight.
  3. Now, from the equation for m above, the scale is (CalWeight - 0)/(VoltsCalWeight-VoltsZeroWeight)
  4. From the equation for m above, the Offset is: 0 - Scale * VoltsZeroWeight

I was thinking it would have to be a two step process. I didn’t even think about setting the act pos to 0 was moving the scale. I made like your suggestions and it seems to work well.

Just downloaded the new RMC Tools. Looks like some good improvements.