Skip to content

99cm234/TwincatVariableNaming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

TwinCAT Variable Naming Guide

General Rules

  • Use PascalCase for all public-facing symbols (e.g., I/O, HMI mappings, FB names, methods, properties).
  • Use _camelCase for local/internal variables that are not mapped to I/O or HMI.
  • Keep physical I/O and HMI commands/status clearly separated.
  • Avoid using global variable lists (GVLs) or internal variables for HMI mapping.

Physical I/O

  • Declare in VAR_INPUT / VAR_OUTPUT sections of MAIN or in dedicated function blocks.
  • Use PascalCase nouns or noun phrases.
  • Examples:
StartButton
SystemPressure
PumpMotorCurrent

HMI Mappings

  • Declare in VAR_INPUT / VAR_OUTPUT of MAIN or FBs.
  • Use PascalCase nouns or noun phrases.
  • To help differentiate from Physical I/O:
    • Commands: Always use the Command suffix (e.g., StartCommand, StopCommand)
    • Statuses / Feedback: Use suffixes such as Status, Feedback, or Text as appropriate.

Function Blocks

  • Prefix with fb, followed by PascalCase name:
fbSumpPump
fbBurnerControl

Methods

  • Use PascalCase with a Verb or Verb–Noun pattern:
UpdateSetpoint
Reset
StartPump
StopPump

Properties

  • Use PascalCase nouns or noun phrases:
TargetTemperature
PumpRunHours
AlarmText

VAR_INPUT

  • Use PascalCase, nouns or noun phrases (e.g., StartButton, SetpointLevel, RecipeNumber). Use Command or Cmd suffix for commands (e.g., StartCommand).

VAR_OUTPUT Names

  • Use PascalCase, nouns or noun phrases (e.g., PumpStatus, LevelFeedback, AlarmText). Use Status, Feedback, or Text suffixes where applicable.

Local Variables

  • Use a leading underscore and camelCase:
_lastSetpoint
_alarmState
_previousPumpSpeed

Mapping Notes

  • Avoid exposing internal variables directly to HMI.
  • Keep physical IO → FB → HMI mapping clear and traceable.

Quick Reference Summary

- Public I/O & HMI: PascalCase
- FB instances: fbPascalCase
- Methods: VerbNoun PascalCase
- Locals: _camelCase
- Commands: Always use `Command` suffix
- Status/Feedback/Text suffixes for clarity

About

A TwinCAT variable naming standard

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors