Thursday, September 17, 2020

PLC make persistent ladder diagram instruction

An overview of EEPROM

Beside the program memory and RAM of the PLC (any targeted MCU with EEPROM), an EEPROM space stores a permanent user data. Similarly to the program's Flash memory, it's called non-volatile memory which mean that the data is not lost even the supply voltage is turned off. Technically, the EEPROM read/write time is slower than the flash memory technology.

PLC make persistent ladder diagram instruction
An example program shows an EEPROM reading. The display shows the value of '5' read from the EEPROM.

In LDMicro, an instruction to write the data into the EEPROM memory address is called "Make Persistent".

Make Persistent Instruction Symbol 



When the input to this instruction is true, it write the saved_var content to the internal EEPROM of the MCU. Typically, the internal EEPROM memory of most MCU in-use could perform at least 10,000 read/write cycle with a long period of time.

To read content from, the programmer uses MOV instruction. This will make a copy of content from the EEPROM source - for example the saved_var source.

Ladder Diagram Programming Example

A simple example, uses two input contacts - one's for writing to the EEPROM content, and another one for reading the content from EEPROM.



PLC make persistent ladder diagram instruction
Make Persistent Ladder Diagram Example

Since PORTB is used for display output, a one shot rising instruction activate the MOV instruction to set TRISB to 0x00, keeping it in data output mode.



A make persistent instruction named E1. E1 is an identifier of an EEPROM memory address. When the negate input contact Xwrite is true, a value of 5 will be copied to E1 of the EEPROM.

A negate input contact Xread reads the content of E1 whenever it's true. The 7-Segments instruction keeps display the value in the PLC ladder diagram program.

PLC make persistent ladder diagram instruction
Schematic diagram of ladder diagram make persistent instruction

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


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)