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.
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
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.
Schematic diagram of ladder diagram make persistent instruction |
Click here to download the zip file of this example program.
No comments:
Post a Comment