Search code examples
embeddedcan-buscanopen

What do the CANopen STORE and RESTORE objects do?


The CiA 301 CANopen protocol specification defines two objects that a device may implement to save and restore parameters:

Object 1010h - Store Parameters

When a device implements this object, the CANopen master writes the value "save" to one of the subentries of the object to cause the corresponding set of parameters to be written to non-volatile memory.

Object 1011h - Restore Default Parameters

When a device implements this object, the CANopen master writes the value "load" to one of the subentries of the object to restore the corresponding default parameters to be restored.

Device Reset

The CiA 301 specification says that "default values shall be set valid after the CANopen device is reset" - by way of a power cycle, NMT reset node (sub-index 01h to 7Fh) or NMT reset communication (sub-index 02h).

What are 'the default values'?

Does "the default values" mean:

  • The values set by the Store Parameters object? In which case, how can the device be reset to the original factory default settings?
  • The original factory default settings? If so, when should the saved parameters be restored?
  • A combination of the above, whereby the factory default settings are restored by a device reset, and the Store Parameters values are restored by the Restore Default Parameters object?
  • Some other definition?

I understand the mechanisms for reading from the objects to obtain the device capabilities and writing the guard pattern to them to trigger the required action. I also know which values to save and which subsets to save for the different sub-indeces.

The thing I do not understand is when should the factory default values be used (if at all) rather than the saved values, and vice versa?


Solution

  • Object 1010h - Store Parameters

    This does exactly what you'd expect: it causes the specified parameters to be stored.

    Object 1011h - Restore Default Parameters

    This causes and parameters that were previously saved by the Store Parameters to be no longer saved so that the original default values are used when the device resets. It is not equivalent to 'Load Parameters' (there is no such object), as this operation occurs automatically when the device resets, rather it could be thought of as 'Delete Stored Parameters'.

    Summary

    • Object 1010h causes parameters to be saved.
    • Object 1011h causes saved parameters to be deleted.

    On reset, parameters will be loaded from their saved values, if they have been stored, or set to their default values if the default values have been restored.