@walkerist:
Lin_Scale Block
Lin_Scale is an abbreviation for Linear Scale. The idea is that the load cell and its transducer sends out an electrical signal depending on the weight on the load cell. For example, it may send out
- 4mA when the weight is 0t (minimum weight)
- 20mA when the weight is 2t (maximum weight)
- And the electrical signal behaves in a linear fashion between weights of 0t and 2t
- E.g. the signal is 12mA (signal half-scale = (4mA+20mA)/2) at 1t (weight half-scale = (0t+2t)/2).
Note: those are only example values; your scale will behave similarly -
linearly - even if the numbers are different.
That 4-20mA signal is converted to an integral digital number (DN), also called (raw) counts, across the PLC analog input. As @parky noted, you will have to configure and wire the physical side of the analog input per the PLC user manual(s). On the digital "side" of the input i.e. inside the PLC, the analog input value available to the PLC program will be the raw counts value, typically something like
- 0 counts when the electrical signal is 4mA and the weight is 0t
- 32767 counts when the electrical signal is 20mA and the weight is 2t
- And the counts value behaves in a linear fashion between signals of 4mA and 20mA and between weights of 0t and 2t
- E.g. the counts value is 16383 (counts half-scale = (0count+32767count)/2) when the signal is at 12mA (half-scale) and the weight is at 1t (half-scale).
The "
Linear" descriptor of the Lin_Scale Block refers to the
line that represents this relationship in a plot:
PLCs cannot interpret plots, but the equation of that
lineis
Code:
([B][COLOR=blue]Var_In [/COLOR][/B]- In_Min) ([COLOR=Red][B]Lin_Scale[/B][/COLOR] - Out_Min)
----------------- = --------------------
(In_Max - In_Min) (Out_Max - Out_Min)
The Lin_Scale Block solves for the weight,
Lin_Scale, in that equation each time the analog input value,
Var_In (0-32767counts) is measured.
Those quantities are the inputs and output of the Lin_Scale block.
- Var_In = the raw count integer measurement of the analog input; this varies with the amount of material on the scale
- In_Min = 0count, the count value of the analog input at minimum weight of 0t (Out_min); this is a constant set via calibration.
- In_Max = 32767count, the count value at maximum weight of 2t (Out_Max); this is a constant set via calibration.
- Out_Min = 0t, the weight value at 0count (In_Min); this is a constant set via calibration.
- Out_max = 2t, the weight value at 32767count (In_Max); this is a constant set via calibration.
- Lin_Scale = the output weight value corresponding to the Var_In input measurement; this will vary linearly with the Var_In input value.
The actual system may be different: the max values may be 16383count and 500kg; the electrical signal may be 0-10V instead of 4-20mA; after a calibration, you may determine that non-zero values are best values for In_Min and/or Out_Min. However, the general approach described here applies. If you look at your load cell and PLC documentation, there will be a specification of the linearity of the load cell and of the PLC analog input, usually as a percentage of full range; that will tell you the accuracy you can expect from assuming (modeling) the behavior as linear via the Lin_Scale Block.
Background
All computer programs are models of something in the real world. The first design choice for a program is selecting the level of fidelity: which parts of the world are modeled, and how accurately are any of those parts of the world modeled? All other design choices flow from that fidelity choice.
PLCs are special-purpose computers that
continuously do three actions:
- read external inputs;
- make calculations of what outputs should be based on a model comprising
- the inputs,
- any state information about the model stored internal to the PLC,
- and the outputs;
- write external outputs.
That description is an extreme oversimplification of what PLCs do, but it is adequate for almost all tasks, and certainly for the present task*.
Below is a sketch of the entire process. Every line in that image that is crossed by some sort of information is an interface you will need to understand and configure. Fortunately, each can be handled mostly independently of the others, so you can break down the entire problem into a series of smaller problems and only have to consider a small part of the process at any one time.
* The weakest point of that description is the word
continuously: it would be better stated that PLCs continuously
repeat those three actions: some PLCs do them synchronously i.e. in a set sequence e.g. read, calculate, write, read, calculate, write, etc.; some PLCs do them asynchronously, so reading of inputs could happen while, and interrupt, calculating. However, because all three action happen so quickly, the PLC can be thought of as a continuous device for all but the most demanding applications (e.g. motion control).
Sidebar
@parky you probably already noticed: Rung 4 does not need the [ANDE>] OR [ANDE<] logic in the middle, because if the previous Rung 3 has not set the step to 20, then one of those ANDE>/ANDE< paths must already be true. So Rung 4 can be just two instructions: [EQ Sequence_word 10] and [MOV 15 Sequence_word].
I'm not intending to be snarky here, rather trying to contribute to make it easier for OP to understand the code.