pia-468x60

pia-728x90

Monday, September 28, 2020

PLC if-not-equal ladder diagram instruction

In the previous post we have show about an equal comparison instruction. In LDMicro ladder diagram PLC instruction set there are up to six comparison instructions. These are very easy to understand to most experienced programmers. We will not list them all due to the repetitions. 

A list of PLC comparison ladder diagram instructions

For now and final of these instructions, I will show only the example of the If-Not-Equal ladder diagram instruction. This instruction make a logical comparison of its operands whenever its input is true. If the logical operation those two operands is not equal it will output true.

A very simple example shows how to use this instruction with the UART. The PLC keep track of reading the the character from UART terminal. If the received character is letter 'A' then the output coil is off, otherwise it's true.



PLC if-not-equal ladder diagram instruction
If not equal ladder diagram instruction example


The circuit diagram show only the PIC-based PLC with its basic connections and the host PC UART terminal.

PLC if-not-equal ladder diagram instruction
Schematic diagram



Click here to download the zip file of this ladder diagram example.


Sunday, September 27, 2020

PLC piecewise linear table instruction to convert A/D value into PWM duty cycle

In the previous post, I have show to use piecewise linear table to convert between ADC value to analog voltage value. The advantage of this instruction is that the programmer could map between two value without putting any math equation into the PLC ladder diagram program.

Here, I use this instruction to map the A/D converter digital value into the PWM duty cycle that it will adjust the speed of a DC motor. I create a piecewise linear table with three points on the graph A(x0,y0) B(x1,y1) and C(x2,y2).

PLC piecewise linear instruction to convert A/D value into PWM duty cycle
A piecewise linear table that return a duty cycle value in term of the ADC0.

The main ladder diagram program keeps track of three main tasks:
  1. Reading the A/D converter value and converts it to the PWM duty cycle value via a piecewise linear table.
  2. Sending the current PWM duty cycle to the host PC via UART terminal
  3. Adjusting the motor speed via its PWM duty cycle.


PLC piecewise linear instruction to convert A/D value into PWM duty cycle
The Ladder Diagram Program

I selected PIC16F876 due a the ease of use.

PLC piecewise linear instruction to convert A/D value into PWM duty cycle
Schematic Diagram

Click here to download this ladder diagram example.



Saturday, September 26, 2020

PLC one-shot low level (OSL) ladder diagram instruction

A one-shot low level (OSL) instruction is a normally output true instruction. Whenever its input is false then it output false for a PLC scan cycle.

The one shot low level instruction symbol

For more details let see its timing diagram.
The OSL timing diagram

This instruction is useful in the case that the user needs to trigger the action on the falling to low level of the input signal.

In the following example, we create a sample monitoring of this instruction. Whenever the user switch the input contact to the ground, the contact makes a input false signal to the OSL. This OSL again trigger a low level pulse of one PLC scan cycle of 10 mS.



PLC one-shot low level (OSL) ladder diagram instruction
The OSL ladder diagram example

The output coil Y0 is normally output true in the overall PLC program. The output coil Y1 outputs true when there's nothing happen.

PLC one-shot low level (OSL) ladder diagram instruction
Circuit Diagram



Click here to download the zip file of this working example.



Labels