Tuesday, September 22, 2020

PLC piece wise linear ladder diagram instruction

In algebra, a line is created by at least two point A(x0,y0) and B(x1,y1), with a line equation y = f(x).
For a typical PLC example, we refer to the ADC reading digital value vs the analog voltage.
PLC piece wise linear ladder diagram instruction
Piece wise linear application with ADC reading

The graph above shows a function of voltage vs its ADC reading. For example,

  • f(0) = 0
  • f(512) = 2.5 V
  • f(1023) = 5 V
Now let move back to LDMicro ladder diagram, the symbol of piece wise linear instruction shown below.
PWL ladder diagram instruction symbol

The property of the instruction allow us to set the name, number of points etc.

PLC piece wise linear ladder diagram instruction
PWL instruction property

For a simple example, I use this instruction to read the analog value fed to RA0 of the PLC and send it over the UART to the host PC.

PLC piece wise linear ladder diagram instruction
PWL ladder diagram example

PIC16F876 is selected as a CPU of this PLC, clocks at 20 MHz to get its maximum computing performance.

  • The PWL table created with only two points. It output a decimal analog voltage, volt.
  • An internal output coil Rstate active for every 600 mS by a timer tick created by a cyclic on/off T0. It activates the ADC instruction to read the analog input voltage fed to RA0 of the PLC MCU.
  • The UART instruction activated by the Rstate to send the analog voltage reading value to the host PC via UART.

PLC piece wise linear ladder diagram instruction
Simulation schematic diagram

Click here to download this ladder diagram example in zip file.


No comments:

Post a Comment

Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)