Without knowing what PLC you are using, I'll give you an example with a CLICK PLC. The CLICK PLC makes this trivial as it has built in I/O on the processor and I'm using model C0-02DR-D $139 which has
- (4) 24VDC inputs
- (4) Relay outputs
- (2) Analog inputs (configurable as 4-20mA or 0-5V)
- (2) Analog outputs (configurable as 4-20mA or 0-5V)
The first thing is to scale the input. Some PLCs such as Allen Bradley's have instructions for doing this, but the CLICK makes this easier using a graphical editor. Here it is;
The temp input signal is connected to input AD1 (analog to digital). We select 0-5V option. For scaling we set 0V = 150deg F
and 5V = 350deg F
(since 25mV = 1 degree).
5V = 5000mV
5000mV/25mV = 200
150 + 200 = 350
The scaled input is saved in memory register DF1
which is a 32 bit floating value address.
Now we scale the output;
The output fan speed output is connected to output DA1 (digital to analog). Again, we select 0-5V option. 206deg F = 0V
and 215deg F = 5V
. For this output, we assign memory register DF3
, a 32 bit floating value address. Notice on both Input and Output scaling, we selected the option Enable Range Limiter
which tells the CLICK to ignore values outside of the limits.
Here is the Ladder logic. I included comments for explanation
As you can see, it took only 7 lines of PLC code. I do this for a living, so I find this trivial. Good luck!
CORRECTION: On comment of line 3 in the ladder, I meant to say copy value of DF1 into DF3 not DF2.
I think you're going to need to seal the signal pathway from the weighing platform to the printer such any physical tampering will be evident, this means some sort of cover over the moving parts and the wiring
And also restrict operator customisiation such that they cannot print false labels. If necessary move the printing code out of the PLC that's controlling the line, into a controller that is only responsible for putting marks on paper
and can be locked down. (possibly with an auxiliar output only signal path to the controlling PLC so the controller can see the weight, and some sort in input to command it to weigh and print.
Best Answer
In Figures 1 and 2, below, an external sensor is connected to a PLC input. Let's assume that the PLC input has an opto-coupler to the internal logic to isolate the sensitive logic circuitry from the outside world. The circuit, as far as external switches are concerned, is an LED with series resistor. If we short the input terminal to the common terminal we should expect about 5 to 15 mA to flow (determined by the internal series resistor).
In Figure 1. The opto-LED anode is connected to +24 V supply and the cathode is connected through the resistor to the input pin. When the input pin is connected to COMM- the LED will light giving a logic '1' to the PLC CPU. We can, of course, use a switch contact to do this but many interfaces will use a transistor. Either way, the PLC input provides or sources the current through the LED (red arrow) and is known as a "sourcing" input. Since NPN transistors can be very easily switched in this configuration they are generally used - hence "NPN" inputs.
One major advantage of this arrangement is that the transistor can be powered from a supply of different voltage to the PLC - e.g., a 5 V micro-controller and once it shares the common negative it effectively becomes a level shifter between the two systems.
The main disadvantage is that the logic is somewhat inverted. A high voltage on the input is logic 0 and a low voltage is logic 1. This can be confusing.
Figure 2 shows the PNP / sinking circuit. Here current flows from the + supply, through the transistor and the PLC "sinks" it.
The logic is the right way up now and this style of input is preferred on most industrial equipment at present.
For outputs the situation is similar. A current sourcing output will supply the current from the + supply, through the load to the COMM-. For a current sinking output the current will flow from the + supply, through the load, into the PLC input where an NPN transistor will "sink" it to COMM-.
Note some PLCs use bi-directional opto-isolators - two LEDs connected in opposite directions. By connecting the input common terminal to + or - supply the inputs can be made sourcing or sinking.