Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 830 of 909
Long-Term Storage of Variables
Each SmartMotor is equipped with a kind of solid-state disk drive, called EEPROM, reserved
just for long term data storage and retrieval. Data stored in the EEPROM will remain even
after power cycling, just like the SmartMotor's program itself. However, the EEPROM has
limitations. It cannot be written to more than about one million times without being damaged.
That may seem like a lot, but if a write command (VST) is used in a fast loop, this number can
be exceeded in a short time. Therefore, it is the responsibility of the programmer to see that
the memory limitations are considered.
The following example is a subroutine to be called whenever a motion limit is reached. It
assumes that the memory locations were pre-seeded with zeros.
NOTE: This example is a subroutine. It would be called with the command
GOSUB10.
C10 'Subroutine label
EPTR=100 'Set EEPROM pointer in memory
VLD (aa,2) 'Load 2 long variables from EEPROM
IF Br 'If right limit, then...
aa=aa+1 'Increment variable aa
Zr 'Reset right limit state flag
ENDIF
IF Bl 'If left limit, then...
bb=bb+1 'Increment variable bb
Zl 'Reset left limit state flag
ENDIF
EPTR=100 'Reset EEPROM pointer in memory
VST(aa,2) 'Store variables aa and bb
RETURN 'Return to subroutine call
Find Errors and Print Them
This code example looks at different error status bits and prints the appropriate error
information to the RS-232 channel.
NOTE: This example is a subroutine. It would be called with the command
GOSUB10.
C10 'Subroutine label
IF Be 'Check for position error
PRINT("Position Error",#13)
ENDIF
IF Bh 'Check for over temp error
PRINT("Over Temp Error",#13)
ENDIF
IF Ba 'Check for over current error
PRINT("Over Current Error",#13)
ENDIF
RETURN 'Return to subroutine call
Part 3: Examples: Long-Term Storage of Variables