Hi,
I don't think that save and load in a usb device is very popular here, but this code is very usefull for my project, I use a USB pen as a backup flash drive for my wc32 project. In my case, i need to save var9 or load var9 from a usb flash drive every minute.
So,
Take a backup every minute or save every minute. 10 secondes is perfect in case of board rebooting.
if var3 == 0, load var9 from the usb pen
if var3 != 0 , save var9 to the usb pen
PLC code:
START
TSTEQ CS 10 # TEST IF WE ARE AT THE 10TH SECONDE OF THE MINUTE
CALLSUB SAVLOA # IF YES, CALLSUB THE SAVE AND LOAD SUBROUTINE
END
SAVLOA:
TSTEQ VAR3 0 # TEST IF VAR3 IS SET TO 0 ( THAT MEAN BOARD REBOOT )
LOAD "MyUsb" VAR9 # IF IT'S TRUE, THEN RELOAD THE "MyUsb" VALUE AND PUT IT TO VAR9
TSTNE VAR3 0 # TEST IF VAR3 AS BEEN CHANGED
SAVE "MyUsb" VAR9 # IF YES, THEN SAVE VAR9 TO "MyUsb" IN THE USB FLASH DRIVE
RET
Maybe this is not the best way to do that but it works sucessfully for me.
I don't think that save and load in a usb device is very popular here, but this code is very usefull for my project, I use a USB pen as a backup flash drive for my wc32 project. In my case, i need to save var9 or load var9 from a usb flash drive every minute.
So,
Take a backup every minute or save every minute. 10 secondes is perfect in case of board rebooting.
if var3 == 0, load var9 from the usb pen
if var3 != 0 , save var9 to the usb pen
PLC code:
START
TSTEQ CS 10 # TEST IF WE ARE AT THE 10TH SECONDE OF THE MINUTE
CALLSUB SAVLOA # IF YES, CALLSUB THE SAVE AND LOAD SUBROUTINE
END
SAVLOA:
TSTEQ VAR3 0 # TEST IF VAR3 IS SET TO 0 ( THAT MEAN BOARD REBOOT )
LOAD "MyUsb" VAR9 # IF IT'S TRUE, THEN RELOAD THE "MyUsb" VALUE AND PUT IT TO VAR9
TSTNE VAR3 0 # TEST IF VAR3 AS BEEN CHANGED
SAVE "MyUsb" VAR9 # IF YES, THEN SAVE VAR9 TO "MyUsb" IN THE USB FLASH DRIVE
RET
Maybe this is not the best way to do that but it works sucessfully for me.