Variables
Variable class
The variables are maintained by the system in a specific manner:
Variable class | System handling | Creation method | Use case |
---|---|---|---|
State | Value is lost at every device reset/shutdown. | In compile time | Time dependent variable, describes internal state of process, cannot be changed by user. |
Parameter | Value is saved manually with the save command and loaded at every device boot. | In compile time | Time independent constatnt, parametrizes internal process, can be set by user. |
Permanent | Value is autsaved/restored at every device shutdown/botup. | In compile time | Usually a service reading, mileage counting, etc. |
Dynamic | Value and variable is lost at every device reset. | In run-time by command var | Scripting and custom functionality. |
State variables
A process state variable represents either an input, internal state or output of a dynamic system. State variable typically changes with time, as the process propagates. User may not modify a state variable during standard operation. State variables are volatile and do not hold their values after reset. State variables are not automatically saved to storage or loaded from it. A state variable can be displayed, logged or plotted. State variable has a type, dimension and metadata. State variables are similar to the SDOs in the CANOpen protocol. Example of state variables: actual phase current / voltage, motor RPM, actual battery current / voltage, duty cycle ...
Parametric variables
A parametric variable represents a time invariant constant, which is typically adjusted by the user and not by the process itself. Such variables typically do not change with time, as the process propagates. A user may modify a parametric variable during standard operation. Parametric variables have a type, dimension, preset values (such as default, minimum, maximum and step) as their metadata. Parametric variables are similar to the PDOs in the CANOpen protocol. If the volatile flag is set for a parametric variable, it is not saved / loaded along the other variables. Parametric variables are volatile, unless saved to storage or loaded from it. Parametric variables saved in main storage are loaded automatically during boot-up sequence. Load from main storage and save to it is done by commands load and save (without parameters). Load from backup storage and save to it is done by same commands with parameter -b. Restore to release preset values is done by command restore. Operations with parametric variables are shown in the figure below. Examples: peak / reference phase current / voltage, peak motor RPM, motor odometer threshold, peak / reference battery current / voltage, maximum duty cycle ...
Permanent variables
Permanent variable is similar to a state variable, but is treated differently by the system. Permanent Variables are persistent, not volatile, they are automatically saved to storage during power-off and loaded during boot sequence. Permanent Variable has a type, dimension and metadata. Examples: total time since factory release, total motor-hours, total energy passed through the controller, maximum ever temperature, maximum ever current, maximum ever RPM ...
Dynamic variables
A symbolic variables that were created dynamically by the user during run-time. User may create variables in his own scripts for arbitrary usage. The dynamic variables exist only in run-time and they are volatile. After the device reset, they need to be created again, if needed. By default, dynamic variables are allocated in the /vars directory. Content of dynamic variables can be stored and loaded to/from a non-volatile memory, into the user storage in similar way as parametric variable.
Variable type
The YOS system supports the following variable types:
Variable type | Range | Description |
---|---|---|
int8 | -128 to 127 | 8-bit signed integer |
uint8 | 0 to 255 | 8-bit unsigned integer |
int16 | -32768 to 32767 | 16-bit signed integer |
uint16 | 0 to 65535 | 16-bit unsigned integer |
int32 | -2147483648 to 2147483647 | 32-bit signed integer |
uint32 | 0 to 4294967295 | 32-bit unsigned integer |
float | -3.4E+38 to 3.4E+38 | 32-bit floating-point number |
Built-in variables
Dynamic variables
The system creates several default variables that can be used e.g. for scripting:
retval
return value of function. Generaly, 0 or positive number means that function ended without error, negative number means that function ended with error.debuglevel
value of this variable sets amount of debug messages printed to standard output. Value 0 means that all debug messages are printed, number 255 means that no debug messages are printed. Values 1 - 254 are reserved for application-dependent debug settings.ticks
this dynamic variable is used for time measurement. It is incremented by 1 each milisecond. It can be treaten as any other dynamic variable. Its value can be read or set to certain value.
Permanents
This is a list of permanents, registered by YOS in the device.
time
[s] Number of seconds of current device run. (From power up)totaltime
[s] Summary time of all device runs. (From the first power-up)ttl
[s] Time To Live. (0 = No limitation) Life span of device can be limited. (For example, when the device is lend for evaluation)run
[cycles] Amount of power cycles of the device. Incremented on each device startup. (only if device is powered)