├── inc
├── plc_cr.h
├── plc_io.h
├── plc_cfg.h
├── plc_comm.h
├── plc_mem.h
├── plc_stat.h
├── plc_debug.h
├── plc_define.h
├── plc_std_fb.h
├── plc_std_fc.h
├── plc_timer.h
└── plc_type_define.h
├── src
├── plc_cr.c
├── plc_io.c
├── plc_cfg.c
├── plc_comm.c
├── plc_main.c
├── plc_mem.c
├── plc_stat.c
├── plc_debug.c
├── plc_std_fb.c
├── plc_std_fc.c
└── plc_timer.c
├── port
├── plc_port.c
└── plc_port.h
├── docs
├── images
│ ├── coil.png
│ ├── add_task.gif
│ ├── contact.png
│ ├── plc_menu.png
│ ├── LD_edit
│ │ ├── 1.png
│ │ ├── 10.png
│ │ ├── 11.png
│ │ ├── 12.png
│ │ ├── 13.png
│ │ ├── 14.png
│ │ ├── 15.png
│ │ ├── 16.png
│ │ ├── 17.png
│ │ ├── 18.png
│ │ ├── 2.png
│ │ ├── 3.png
│ │ ├── 4.png
│ │ ├── 5.png
│ │ ├── 6.png
│ │ ├── 7.png
│ │ ├── 8.png
│ │ ├── 9.png
│ │ ├── ld_edit.gif
│ │ ├── ld_edit_by_menu.gif
│ │ ├── ld_call_function.gif
│ │ └── ld_call_function_block_instance.gif
│ ├── add_program.gif
│ ├── cross_link.png
│ ├── edit_menu.png
│ ├── file_menu.png
│ ├── help_menu.png
│ ├── ld_example.png
│ ├── ld_toolbar.PNG
│ ├── main_window.PNG
│ ├── new_program.PNG
│ ├── new_project.PNG
│ ├── new_project.gif
│ ├── pou_ld_page.png
│ ├── task_insert.gif
│ ├── tool_menu.png
│ ├── view_menu.png
│ ├── add_resource.gif
│ ├── app_directory.PNG
│ ├── main_toolbar.PNG
│ ├── new_function.PNG
│ ├── output_window.png
│ ├── plctoc_output.PNG
│ ├── pou_text_page.PNG
│ ├── project_tree.png
│ ├── resource_page.png
│ ├── task_example.PNG
│ ├── c_files_generate.gif
│ ├── ld_param_modify.png
│ ├── options_dialog.PNG
│ ├── pou_param_insert.gif
│ ├── resource_insert.gif
│ ├── software_model.png
│ ├── configuration_page.PNG
│ ├── main_window_marked.PNG
│ ├── new_function_block.PNG
│ ├── var_global_insert.gif
│ ├── add_program_instance.gif
│ ├── ld_right_button_menu.png
│ ├── plcapp_directory_show.PNG
│ ├── new_rtt_project_config.PNG
│ ├── program_instance_insert.gif
│ ├── character_representations.PNG
│ ├── program_instance_example.PNG
│ ├── software_model_example_code.png
│ ├── software_model_example_graph.png
│ ├── communication_function_blocks.png
│ ├── communication_via_access_paths.png
│ ├── plc_language_elements_combination.PNG
│ ├── communication_via_global_variables.png
│ └── data_flow_connection_whthin_a_program.png
├── PLC集成开发环境使用示例1.md
├── PLC集成开发环境用户手册.md
├── plccore软件包移植及使用说明.md
└── IEC61131-3标准PLC编程参考手册.md
├── .project
├── examples
└── plcapp
│ ├── dataType.h
│ ├── configuration.c
│ ├── pou.h
│ ├── resource.h
│ ├── PROGRAM0.c
│ ├── configuration.h
│ └── resource.c
├── .gitignore
├── README.md
└── LICENSE
/inc/plc_cr.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_cr.h
--------------------------------------------------------------------------------
/inc/plc_io.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_io.h
--------------------------------------------------------------------------------
/src/plc_cr.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_cr.c
--------------------------------------------------------------------------------
/src/plc_io.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_io.c
--------------------------------------------------------------------------------
/inc/plc_cfg.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_cfg.h
--------------------------------------------------------------------------------
/inc/plc_comm.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_comm.h
--------------------------------------------------------------------------------
/inc/plc_mem.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_mem.h
--------------------------------------------------------------------------------
/inc/plc_stat.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_stat.h
--------------------------------------------------------------------------------
/src/plc_cfg.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_cfg.c
--------------------------------------------------------------------------------
/src/plc_comm.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_comm.c
--------------------------------------------------------------------------------
/src/plc_main.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_main.c
--------------------------------------------------------------------------------
/src/plc_mem.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_mem.c
--------------------------------------------------------------------------------
/src/plc_stat.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_stat.c
--------------------------------------------------------------------------------
/inc/plc_debug.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_debug.h
--------------------------------------------------------------------------------
/inc/plc_define.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_define.h
--------------------------------------------------------------------------------
/inc/plc_std_fb.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_std_fb.h
--------------------------------------------------------------------------------
/inc/plc_std_fc.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_std_fc.h
--------------------------------------------------------------------------------
/inc/plc_timer.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_timer.h
--------------------------------------------------------------------------------
/port/plc_port.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/port/plc_port.c
--------------------------------------------------------------------------------
/port/plc_port.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/port/plc_port.h
--------------------------------------------------------------------------------
/src/plc_debug.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_debug.c
--------------------------------------------------------------------------------
/src/plc_std_fb.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_std_fb.c
--------------------------------------------------------------------------------
/src/plc_std_fc.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_std_fc.c
--------------------------------------------------------------------------------
/src/plc_timer.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/src/plc_timer.c
--------------------------------------------------------------------------------
/docs/images/coil.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/coil.png
--------------------------------------------------------------------------------
/inc/plc_type_define.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/inc/plc_type_define.h
--------------------------------------------------------------------------------
/docs/images/add_task.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/add_task.gif
--------------------------------------------------------------------------------
/docs/images/contact.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/contact.png
--------------------------------------------------------------------------------
/docs/images/plc_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/plc_menu.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/1.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/10.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/11.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/12.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/13.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/14.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/15.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/16.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/17.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/18.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/2.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/3.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/4.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/5.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/6.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/7.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/8.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/9.png
--------------------------------------------------------------------------------
/docs/images/add_program.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/add_program.gif
--------------------------------------------------------------------------------
/docs/images/cross_link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/cross_link.png
--------------------------------------------------------------------------------
/docs/images/edit_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/edit_menu.png
--------------------------------------------------------------------------------
/docs/images/file_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/file_menu.png
--------------------------------------------------------------------------------
/docs/images/help_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/help_menu.png
--------------------------------------------------------------------------------
/docs/images/ld_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/ld_example.png
--------------------------------------------------------------------------------
/docs/images/ld_toolbar.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/ld_toolbar.PNG
--------------------------------------------------------------------------------
/docs/images/main_window.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/main_window.PNG
--------------------------------------------------------------------------------
/docs/images/new_program.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_program.PNG
--------------------------------------------------------------------------------
/docs/images/new_project.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_project.PNG
--------------------------------------------------------------------------------
/docs/images/new_project.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_project.gif
--------------------------------------------------------------------------------
/docs/images/pou_ld_page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/pou_ld_page.png
--------------------------------------------------------------------------------
/docs/images/task_insert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/task_insert.gif
--------------------------------------------------------------------------------
/docs/images/tool_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/tool_menu.png
--------------------------------------------------------------------------------
/docs/images/view_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/view_menu.png
--------------------------------------------------------------------------------
/docs/images/add_resource.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/add_resource.gif
--------------------------------------------------------------------------------
/docs/images/app_directory.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/app_directory.PNG
--------------------------------------------------------------------------------
/docs/images/main_toolbar.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/main_toolbar.PNG
--------------------------------------------------------------------------------
/docs/images/new_function.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_function.PNG
--------------------------------------------------------------------------------
/docs/images/output_window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/output_window.png
--------------------------------------------------------------------------------
/docs/images/plctoc_output.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/plctoc_output.PNG
--------------------------------------------------------------------------------
/docs/images/pou_text_page.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/pou_text_page.PNG
--------------------------------------------------------------------------------
/docs/images/project_tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/project_tree.png
--------------------------------------------------------------------------------
/docs/images/resource_page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/resource_page.png
--------------------------------------------------------------------------------
/docs/images/task_example.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/task_example.PNG
--------------------------------------------------------------------------------
/docs/images/LD_edit/ld_edit.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/ld_edit.gif
--------------------------------------------------------------------------------
/docs/images/c_files_generate.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/c_files_generate.gif
--------------------------------------------------------------------------------
/docs/images/ld_param_modify.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/ld_param_modify.png
--------------------------------------------------------------------------------
/docs/images/options_dialog.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/options_dialog.PNG
--------------------------------------------------------------------------------
/docs/images/pou_param_insert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/pou_param_insert.gif
--------------------------------------------------------------------------------
/docs/images/resource_insert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/resource_insert.gif
--------------------------------------------------------------------------------
/docs/images/software_model.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/software_model.png
--------------------------------------------------------------------------------
/docs/images/configuration_page.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/configuration_page.PNG
--------------------------------------------------------------------------------
/docs/images/main_window_marked.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/main_window_marked.PNG
--------------------------------------------------------------------------------
/docs/images/new_function_block.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_function_block.PNG
--------------------------------------------------------------------------------
/docs/images/var_global_insert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/var_global_insert.gif
--------------------------------------------------------------------------------
/docs/images/add_program_instance.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/add_program_instance.gif
--------------------------------------------------------------------------------
/docs/images/ld_right_button_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/ld_right_button_menu.png
--------------------------------------------------------------------------------
/docs/images/plcapp_directory_show.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/plcapp_directory_show.PNG
--------------------------------------------------------------------------------
/docs/images/LD_edit/ld_edit_by_menu.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/ld_edit_by_menu.gif
--------------------------------------------------------------------------------
/docs/images/new_rtt_project_config.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/new_rtt_project_config.PNG
--------------------------------------------------------------------------------
/docs/images/program_instance_insert.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/program_instance_insert.gif
--------------------------------------------------------------------------------
/docs/images/LD_edit/ld_call_function.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/ld_call_function.gif
--------------------------------------------------------------------------------
/docs/images/character_representations.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/character_representations.PNG
--------------------------------------------------------------------------------
/docs/images/program_instance_example.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/program_instance_example.PNG
--------------------------------------------------------------------------------
/docs/images/software_model_example_code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/software_model_example_code.png
--------------------------------------------------------------------------------
/docs/images/software_model_example_graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/software_model_example_graph.png
--------------------------------------------------------------------------------
/docs/images/communication_function_blocks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/communication_function_blocks.png
--------------------------------------------------------------------------------
/docs/images/communication_via_access_paths.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/communication_via_access_paths.png
--------------------------------------------------------------------------------
/docs/images/plc_language_elements_combination.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/plc_language_elements_combination.PNG
--------------------------------------------------------------------------------
/docs/images/communication_via_global_variables.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/communication_via_global_variables.png
--------------------------------------------------------------------------------
/docs/images/data_flow_connection_whthin_a_program.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/data_flow_connection_whthin_a_program.png
--------------------------------------------------------------------------------
/docs/images/LD_edit/ld_call_function_block_instance.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyafz/plccore/HEAD/docs/images/LD_edit/ld_call_function_block_instance.gif
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
357 | 下列基本数据类型可以配置是否支持,其它基本数据类型默认支持。 358 | LINT 359 | ULINT 360 | REAL 361 | LREAL 362 | LWORD 363 | STRING 364 | WSTRING 365 | TIME 366 | DATE 367 | TOD 368 | DT 369 | 导出数据类型可以配置是否支持 370 |371 | */ 372 | #define DT_REAL_EN 1 373 | 374 | #define DT_64BIT_EN 0 /**< 支持64位长度数据类型的选项(0: 不支持, 1: 支持) */ 375 | #if (DT_64BIT_EN > 0) 376 | #define DT_LINT_EN 0 377 | #define DT_ULINT_EN 0 378 | #define DT_LREAL_EN 0 379 | #define DT_LWORD_EN 0 380 | #endif 381 | 382 | #define DT_STRING_EN 0 383 | #define DT_WSTRING_EN 0 384 | #define DT_TIME_EN 1 385 | #define DT_DATE_EN 0 386 | #define DT_TOD_EN 0 387 | #define DT_DT_EN 0 388 | 389 | #define DT_DVD_EN 0 /**< 支持导出数据类型的选项(0: 不支持, 1: 支持) ,目前必须为0*/ 390 | 391 | /*与配置相关的选项*/ 392 | 393 | /*与资源相关的选项*/ 394 | #define MAX_TASK_NUM_PER_RSC 4 /**< 每个资源中允许的最大任务数目*/ 395 | #define PLC_TASK_RUN_TASK_STK_SIZE 512 396 | #define PLC_TASK_HIGHEST_PRIORITY 2 397 | #define PLC_TASK_LOWEST_PRIORITY 30 398 | /*与POU相关的选项*/ 399 | 400 | /* 与数据类型相关的选项 */ 401 | 402 | /* 与编程语言相关的选项 */ 403 | 404 | /* 与IL语言相关的选项 */ 405 | 406 | /* 与LD语言相关的选项 */ 407 | 408 | /* 其它选项 */ 409 | 410 | #endif /* PLC_PORT_H */ 411 | 412 | ``` 413 | 414 | ### 修改plccore/port/plc_port.c文件 415 | > ***本文件基本上都是nano版本移植才需要修改*** 416 | 417 | 从Stm32CubeMX生成工程的src目录下的main.c文件中复制片上外设配置函数至plc_port.c,并实现各硬件相关的函数接口。例如: 418 | ``` 419 | /** 420 | * @file plc_port.c 421 | * @brief PLC处理器接口相关的实现 422 | * @author hyafz 423 | */ 424 | #include "board.h" 425 | #include "plc_port.h" 426 | 427 | #ifndef RT_USING_DEVICE 428 | #include "plc_comm.h" 429 | #include "plc_timer.h" 430 | #include "plc_io.h" 431 | 432 | TIM_HandleTypeDef htim3; 433 | UART_HandleTypeDef huart1; 434 | 435 | /** 436 | * @brief TIM3 Initialization Function 437 | * @param None 438 | * @retval None 439 | */ 440 | static void MX_TIM3_Init(void) 441 | { 442 | 443 | /* USER CODE BEGIN TIM3_Init 0 */ 444 | 445 | /* USER CODE END TIM3_Init 0 */ 446 | 447 | TIM_ClockConfigTypeDef sClockSourceConfig = {0}; 448 | TIM_MasterConfigTypeDef sMasterConfig = {0}; 449 | 450 | /* USER CODE BEGIN TIM3_Init 1 */ 451 | 452 | /* USER CODE END TIM3_Init 1 */ 453 | htim3.Instance = TIM3; 454 | htim3.Init.Prescaler = 83; 455 | htim3.Init.CounterMode = TIM_COUNTERMODE_UP; 456 | htim3.Init.Period = 1000; 457 | htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; 458 | htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; 459 | if (HAL_TIM_Base_Init(&htim3) != HAL_OK) 460 | { 461 | Error_Handler(); 462 | } 463 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; 464 | if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK) 465 | { 466 | Error_Handler(); 467 | } 468 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; 469 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; 470 | if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK) 471 | { 472 | Error_Handler(); 473 | } 474 | /* USER CODE BEGIN TIM3_Init 2 */ 475 | 476 | /* USER CODE END TIM3_Init 2 */ 477 | 478 | } 479 | 480 | /** 481 | * @brief USART1 Initialization Function 482 | * @param None 483 | * @retval None 484 | */ 485 | static void MX_USART1_UART_Init(void) 486 | { 487 | 488 | /* USER CODE BEGIN USART1_Init 0 */ 489 | 490 | /* USER CODE END USART1_Init 0 */ 491 | 492 | /* USER CODE BEGIN USART1_Init 1 */ 493 | 494 | /* USER CODE END USART1_Init 1 */ 495 | huart1.Instance = USART1; 496 | huart1.Init.BaudRate = 115200; 497 | huart1.Init.WordLength = UART_WORDLENGTH_8B; 498 | huart1.Init.StopBits = UART_STOPBITS_1; 499 | huart1.Init.Parity = UART_PARITY_NONE; 500 | huart1.Init.Mode = UART_MODE_TX_RX; 501 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 502 | huart1.Init.OverSampling = UART_OVERSAMPLING_16; 503 | if (HAL_UART_Init(&huart1) != HAL_OK) 504 | { 505 | Error_Handler(); 506 | } 507 | /* USER CODE BEGIN USART1_Init 2 */ 508 | 509 | /* USER CODE END USART1_Init 2 */ 510 | 511 | } 512 | 513 | /** 514 | * @brief GPIO Initialization Function 515 | * @param None 516 | * @retval None 517 | */ 518 | static void MX_GPIO_Init(void) 519 | { 520 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 521 | 522 | /* GPIO Ports Clock Enable */ 523 | __HAL_RCC_GPIOC_CLK_ENABLE(); 524 | __HAL_RCC_GPIOH_CLK_ENABLE(); 525 | __HAL_RCC_GPIOA_CLK_ENABLE(); 526 | __HAL_RCC_GPIOB_CLK_ENABLE(); 527 | 528 | /*Configure GPIO pin Output Level */ 529 | HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15, GPIO_PIN_RESET); 530 | 531 | /*Configure GPIO pin Output Level */ 532 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET); 533 | 534 | /*Configure GPIO pin Output Level */ 535 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 536 | |GPIO_PIN_7, GPIO_PIN_RESET); 537 | 538 | /*Configure GPIO pins : PC13 PC14 PC15 */ 539 | GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15; 540 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 541 | GPIO_InitStruct.Pull = GPIO_NOPULL; 542 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 543 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); 544 | 545 | /*Configure GPIO pins : PA0 PA1 PA2 PA3 546 | PA4 PA5 PA6 PA7 */ 547 | GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 548 | |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; 549 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 550 | GPIO_InitStruct.Pull = GPIO_NOPULL; 551 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 552 | 553 | /*Configure GPIO pin : PB0 */ 554 | GPIO_InitStruct.Pin = GPIO_PIN_0; 555 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 556 | GPIO_InitStruct.Pull = GPIO_NOPULL; 557 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 558 | 559 | /*Configure GPIO pin : PA15 */ 560 | GPIO_InitStruct.Pin = GPIO_PIN_15; 561 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 562 | GPIO_InitStruct.Pull = GPIO_NOPULL; 563 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 564 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 565 | 566 | /*Configure GPIO pins : PB3 PB4 PB5 PB6 567 | PB7 */ 568 | GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 569 | |GPIO_PIN_7; 570 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 571 | GPIO_InitStruct.Pull = GPIO_NOPULL; 572 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; 573 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 574 | 575 | } 576 | 577 | /** 578 | * @brief This function handles USART1 global interrupt. 579 | */ 580 | void USART1_IRQHandler(void) 581 | { 582 | /* USER CODE BEGIN USART1_IRQn 0 */ 583 | uint16_t rxCnt = huart1.RxXferCount; 584 | /* USER CODE END USART1_IRQn 0 */ 585 | HAL_UART_IRQHandler(&huart1); 586 | /* USER CODE BEGIN USART1_IRQn 1 */ 587 | if(rxCnt != huart1.RxXferCount){ 588 | plcCommDataReceived(); 589 | } 590 | /* USER CODE END USART1_IRQn 1 */ 591 | } 592 | 593 | /** 594 | * @brief Period elapsed callback in non-blocking mode 595 | * @param htim TIM handle 596 | * @retval None 597 | */ 598 | void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) 599 | { 600 | if(htim == &htim3){ 601 | plcTimeoutCallback(); 602 | } 603 | } 604 | 605 | /** 606 | * @brief This function handles TIM2 global interrupt. 607 | */ 608 | void TIM3_IRQHandler(void) 609 | { 610 | /* USER CODE BEGIN TIM2_IRQn 0 */ 611 | 612 | /* USER CODE END TIM2_IRQn 0 */ 613 | HAL_TIM_IRQHandler(&htim3); 614 | /* USER CODE BEGIN TIM2_IRQn 1 */ 615 | 616 | /* USER CODE END TIM2_IRQn 1 */ 617 | } 618 | 619 | void devCommInit(void) 620 | { 621 | MX_USART1_UART_Init(); 622 | } 623 | 624 | void devCommRxStart(void) 625 | { 626 | HAL_UART_AbortReceive_IT(&huart1); 627 | CommRxCnt = 0; 628 | HAL_UART_Receive_IT(&huart1, CommRxBuf, RX_DATA_BUF_SIZE); 629 | } 630 | 631 | void devCommSend(unsigned char* pbuf, unsigned int size) 632 | { 633 | HAL_UART_Transmit(&huart1, pbuf, size, 100); 634 | } 635 | 636 | void devTimerInit(void) 637 | { 638 | MX_TIM3_Init(); 639 | } 640 | 641 | void devTimerStart(void) 642 | { 643 | __HAL_TIM_SET_COUNTER(&htim3, 0); 644 | HAL_TIM_Base_Start_IT(&htim3); 645 | } 646 | 647 | void devTimerStop(void) 648 | { 649 | HAL_TIM_Base_Stop_IT(&htim3); 650 | } 651 | 652 | unsigned int devTimerCountGet(void) 653 | { 654 | return __HAL_TIM_GET_COUNTER(&htim3); 655 | } 656 | 657 | void devIOInit(void) 658 | { 659 | MX_GPIO_Init(); 660 | } 661 | 662 | #define GPIO_PORT(pin) ((GPIO_TypeDef *) (GPIOA_BASE + ((pin) / 16) * 0x0400UL)) 663 | #define GPIO_PIN(pin) ((uint16_t)(0x0001 << ((pin) % 16))) 664 | unsigned char devInputPinRead(unsigned int pin) 665 | { 666 | return (unsigned char)HAL_GPIO_ReadPin(GPIO_PORT(pin), GPIO_PIN(pin)); 667 | } 668 | 669 | void devOutputPinWrite(unsigned int pin, unsigned int val) 670 | { 671 | HAL_GPIO_WritePin(GPIO_PORT(pin), GPIO_PIN(pin), val); 672 | } 673 | 674 | #endif 675 | 676 | void iapModeEnter(void) 677 | { 678 | HAL_NVIC_SystemReset(); //复位则返回IAP程序入口 679 | } 680 | 681 | ``` 682 | 683 | ### 修改main.c文件 684 | 685 | 在main函数中添加如下代码: 686 | ```c 687 | int main(void) 688 | { 689 | extern void plcMain(void); 690 | plcMain(); 691 | 692 | while (1) 693 | { 694 | rt_thread_mdelay(1000); 695 | } 696 | 697 | return RT_EOK; 698 | } 699 | 700 | ``` 701 | 702 | ### 从examples/目录下剪切plcapp文件夹,粘贴到RT-Thread Studio工程目录下 703 | > 注意是剪切! 704 | 705 | plcapp存放了PLC集成开发环境软件根据用户逻辑程序(梯形图、指令表)生成的C语言代码文件,将其复制至RT-Thread Studio工程目录然后在RT-Thread Studio界面刷新项目树。 706 | 707 | ### 设置包含路径 708 | 709 | 在RT-Thread Studio主菜单“项目”->“属性”->“C/C++常规”->“路径和符号”中添加plccore、plctapp的包含路径。 710 | 711 | ### 修改目标文件名 712 | 713 | 在RT-Thread Studio主菜单“项目”->“属性”->“C/C++构建”->“设置”->“构建工件”->“Artifact name:”中写入新的名字。 714 | 715 | ### 编译RT-Thread Studio工程 716 | 717 | 编译成功则移植完成。 718 | 719 | --- 720 | ## 5. 与PLC IDE结合使用 721 | PLC IDE分为社区版与标准版,目前仅提供社区版免费使用,标准版正在开发中。 722 | - 社区版 723 | - 在PLC IDE中,用户可以建立PLC应用工程,使用PLC编程语言,比如指令表、梯形图等实现用户逻辑,然后生成C语言源代码文件,保存在工程目录的plctoc_output子目录中。 724 | - 将plctoc_output目录中的所有.c/.h文件复制至RTT移植工程的plcapp目录下,注意只复制文件,不复制目录结构。 725 | - 刷新RTT移植工程,然后编译生成目标代码,下载至目标板,即可实现用户逻辑控制。 726 | 727 | - 标准版 728 | - 移植完成后,将RT-Thread Studio工程文件夹整体复制至PLC IDE执行目录下的processors目录中,这样就可以作为一种新的PLC处理器使用。 729 | - 在PLC IDE中,用户可以建立PLC应用工程,使用PLC编程语言,比如指令表、梯形图等实现用户逻辑,然后直接编译、连接,再下载至目标板,即可实现逻辑控制。 730 | 731 | ### 关于PLC IDE 732 | 733 | PLC IDE是一款可编程控制器的集成开发环境,实现了符合IEC61131-3标准的软件模型和编程模型,编程简单、配置灵活、系统扩展性好。支持标准的指令表(IL)、结构化文本(ST)、梯形图(LD)等PLC编程语言,能够将PLC用户逻辑代码编译为目标硬件的二进制目标代码,实现编译型PLC。相比于传统的解释型PLC,指令执行效率更高,存储密度更高,且具有更高的可靠性。 734 | 735 | --- 736 | ## 结束 -------------------------------------------------------------------------------- /docs/IEC61131-3标准PLC编程参考手册.md: -------------------------------------------------------------------------------- 1 | IEC61131-3标准可编程逻辑控制器编程参考手册 2 | ======================================== 3 | 4 | # 修订历史 5 | 6 | 版本 | 日期 | 修订人 | 审核人 | 描述 7 | :-: | :-: | :-: | :-: | :- 8 | V0.1 | 2020.2.21 | 冯洲 | 冯洲 | 初次创建,部分功能还未实现,以实际为准。 9 | 10 | # 前言 11 | 本编程参考手册归纳总结了《中华人民共和国国家标准GB/T 15969.3——2005/IEC 61131-3:2002 可编程序控制器 第3部分:编程语言》的各项规定、要求与限制,使用户能准确把握标准的精髓,快速上手,完成PLC应用程序编写与系统组态。 12 | GB/T 15969.3标准等同翻译IEC 61131-3标准,下文统一称为IEC 61131-3标准,或简称为标准。 13 | 14 | #1 软件模型 15 | IEC 61131-3标准的软件模型用分层结构表示,每一层隐含其下层的许多特性,从而构成优于传统可编程控制器软件的理论基础。软件模型描述基本的高级软件元素及其相互关系,是现代PLC的软件基础。这些元素包括: 16 | - 程序组织单元,即程序、功能块和功能 17 | - 组态元素,即配置、资源、任务、全局变量和存取路径 18 | 19 | IEC61131-3标准的软件模型如图所示: 20 |  21 | IEC 61131-3标准软件模型从理论上描述了如何将一个复杂程序分解为若干小的可管理部分,并在各分解部分之间有清晰和规范的接口方法。另外,软件模型还描述一台可编程控制器如何实现多个独立程序的同时装载和运行,如何实现对程序执行的完全控制等。 22 | 以下各节将按从上至下的顺序依次介绍软件模型中不同层级的元素的定义及作用。 23 | ##1.1 配置 24 | 配置(Configuration)位于软件模型的最上层,是可编程控制器系统的整个软件,用于定义特定应用的PLC系统的特性。对于大型复杂的应用,如整个产品线的自动化,可能需要几个PLC相互作用,一个配置可以与其它IEC配置通过通信接口实现通信。在这种情况下,每个PLC的软件可作为一个分离的配置。因此,可将配置认为是一个特定类型的控制系统,它包括硬件装置、处理资源、I/O通道的存储地址和系统能力,即等同于一个PLC的应用程序。 25 | 配置用关键字CONFIGURATION开始,随后是配置名称和配置声明,最后用关键字END_CONFIGURATION结束。配置声明包括定义该配置的有关类型和全局变量的声明、在配置内资源的声明、存取路径变量的声明和实例专用初始化变量声明等。 26 | 在PLC集成开发环境中,配置采用一个专门的页面进行管理,不需要手写代码,这种方式更直观,也更方便。下图为配置管理页面: 27 |  28 | 在PLC系统中,配置将系统内的所有资源结合成组,在一个配置中,可定义在该PLC项目中全局有效使用的全局变量,作为资源之间数据交换的手段。 29 | 30 | ##1.2 资源 31 | 资源(Resource)位于软件模型的第二层,它为运行程序提供支持系统,是能执行IEC程序的处理手段。资源反映了可编程控制器的物理结构,为程序和PLC的物理输入输出通道提供了一个接口。 32 | 每个配置内可有一个或多个资源。资源提供对所有程序执行所需特性的支持。 33 | 一个程序只有在资源中实例化才能运行。资源的主要功能之一是提供程序和PLC物理I/O通道之间的界面。 34 | 每个资源可支持多于一个的程序。因此,资源使PLC能够加载、启动和执行许多总体独立的程序。 35 | 资源有资源名称,它被分配在一个PLC的CPU中。因此,可将资源理解为一个PLC中的微处理器单元。资源内定义的全局变量在该资源内部是有效的。资源可调用具有输入输出参数的运行期程序,给一个资源分配任务和程序,并声明直接表示变量。 36 | 资源用关键字RESOURCE开始,随后是资源名称和ON关键字、资源类型名和资源声明,最后用END_RESOURCE关键字结束。 37 | 资源名是一个符号名,它用于说明可编程控制器系统中的一个处理器。编程系统提供可编程控制器系统内该资源(即每个CPU的命名)的类型和数量,并检验这些资源类型和数量,使系统能够正确地使用这些资源。 38 | 资源声明包括在该资源内的全局变量、任务和程序声明等内容。在资源声明段中,ON关键字指定特定的处理器类型,每种处理器具有限定的“信号处理功能”、“人机接口”和“传感器和执行机构接口”。 39 | 在PLC集成开发环境中,资源采用一个专门的页面进行管理,如下图所示: 40 |  41 | 42 | ##1.3 任务 43 | 任务(Task)位于软件模型分层结构的第3层。任务用于规定程序组织单元(POU)在运行期的特性。任务是一个执行控制元素,它具有调用能力。 44 | 一个资源中可以有多个用户任务。一旦任务被设置,它就可控制一系列程序组织单元周期地执行,或者根据一个特定的事件触发来执行。 45 | 每个资源都有一个最低优先级(比所有声明的用户任务更低)的默认任务,不需要用户声明。如果声明的程序实例没有与任何任务结合,则自动与默认任务结合。 46 | 任务由关键字TASK开始,随后是任务名、任务初始化设置(用圆括号将任务的有关参数分列其中)。 47 | ###1.3.1 任务初始化设置 48 | 任务初始化设置有三个参数: 49 | - SIGNAL:触发任务执行的事件输入端,在该事件触发信号的上升沿,触发任务执行一次; 50 | - INTERVAL:任务周期执行的时间间隔。当其值不为零,且SIGNAL信号保持为0,则表示该任务被周期执行; 51 | - PRIORITY:任务优先级,0表示最高优先级,优先级越低,数值越高。 52 | 53 | 例如: 54 | ``` 55 | TASK slow_1 (INTERVAL := T#20ms, PRIORITY := 2); 56 | ``` 57 | 表示任务名为slow_1的任务是周期执行的任务,周期间隔时间20ms,优先级为2。 58 | 在资源管理页面使用表格化方式对任务进行设置,上述slow_1任务表示如下: 59 |  60 | 61 | ###1.3.2 任务执行准则 62 | - 单任务输入SIGNAL不为零,表示该任务在SIGNAL上升沿时触发执行一次,是事件触发的单任务; 63 | - 当INTERVAL不为零,SIGNAL保持为零,则该任务周期执行,执行周期由INTERVAL数据确定; 64 | - 当多个任务执行时,立即中断正在执行的任务,使优先级高的任务先被执行; 65 | - 如果多个任务的优先级相同,则按时间片轮转执行; 66 | - 没有与任何任务结合的程序实例,默认结合至默认的最低优先级任务,在资源开始运行时立即开始执行,且执行完毕后立即重新启动。 67 | 68 | ##1.4 程序实例 69 | 一个程序只有在资源内部实例化后才能被调用。 70 | 程序实例化以PROGRAM关键字开始,随后是程序名,如果程序实例与特定任务结合,使用WITH关键字声明,最后是程序实例名及程序接口。例如: 71 | ``` 72 | PROGRAM P1 WITH slow_1 : F(x1 := %IX1.1); 73 | ``` 74 | 其中,P1是程序名,与slow_1任务结合,程序实例名为F,程序接口为实例传递实参数据。 75 | 在资源管理页面使用表格化方式对程序实例进行设置,上述程序实例F表示如下: 76 |  77 | 78 | ##1.5 全局变量 79 | 标准允许变量在不同的软件元素中被声明。变量的范围确定其在哪个程序组织单元中是可用的。范围可能是局部的或全局的。每个变量的范围由它被声明的位置和声明所使用的关键字所定义。 80 | 在配置中声明的全局变量可在整个配置范围内使用,在资源中声明的全局变量只能在该资源范围内使用。全局变量的声明格式如下: 81 | ``` 82 | VAR_GLOBAL 83 | 全局变量说明 84 | END_VAR 85 | ``` 86 | 87 | 全局变量能与其它网络进行数据交换。一个系统中不能有相同名称的两个全局变量。在每个使用全局变量的程序组织单元中,需要用VAR_EXTERNAL关键字来声明它。全局变量提供了在两个不同程序和功能块之间非常灵活的交换数据的方法。 88 | ##1.6 存取路径 89 | 存取路径用于将全局变量、直接表示变量和功能块的输入、输出和内部变量联系起来,实现信息的存取。它提供在不同配置之间交换数据和信息的方法。每一配置内的许多指定名称的变量可通过其他远程配置来存取。 90 | 有两种存取方法:读写方法和只读方法。读写(READ_WRITE)方式表示通信服务能够改变变量的值;只读(READ_ONLY)方式表示能够读取变量的值但不能改变变量的值。当不规定存取路径方法时,约定的存取方式是只读方式。 91 | 存取路径变量声明的方法: 92 | ``` 93 | VAR_ACCESS 94 | 存取路径名:外部存取路径:存取路径变量的数据类型和读写属性 95 | END_VAR 96 | ``` 97 | 外部存取路径采用串联方式表示。开始是资源名,然后是程序实例名,功能块实例名,最后是变量名。各名称之间用圆点分隔,中间没有的名称可以省略。 98 | ##1.7 实例专用的初始化 99 | 等待补充…… 100 | ##1.8 示例 101 | 软件模型的代码示例: 102 |  103 | 对应图形示例: 104 |  105 | #2 编程模型 106 | 标准规定的PLC编程语言元素包括: 107 | - 数据类型 108 | - 变量 109 | - 程序组织单元(功能、功能块、程序) 110 | - 顺序功能图(SFC)元素 111 | - 配置元素(全局变量、资源、存取路径、任务) 112 | 113 | 这些语言元素的组合应遵守以下规则: 114 | - 导出数据类型应使用标准数据类型和先前导出的任何数据类型进行说明。 115 | - 导出功能使用标准或导出数据类型、标准功能和先前导出的任何功能进行说明。该说明应使用为IL、ST、LD或FBD语言定义的机制。 116 | - 导出功能块使用标准或导出数据类型和功能、标准功能块和先前导出的任何功能块进行说明。该说明应使用为IL、ST、LD或FBD语言定义的机制,并可包括顺序功能图(SFC)元素。 117 | - 程序使用标准或导出数据类型、功能和功能块进行说明。该说明应使用为IL、ST、LD或FBD语言定义的机制,并可包括顺序功能图(SFC)元素。 118 | - 使用全局变量、资源、任务和存取路径等元素,可将程序组合进配置。 119 | 120 |  121 | 122 | #3 通信模型 123 | IEC 61131-3标准定义了变量在不同层级的软件元素间通信的各种方法。 124 | ##3.1 程序内通信 125 | 在一个程序内的变量可以直接通信,只要将一个程序元素的输出连接到另一个程序元素的输入即可。如下图所示: 126 |  127 | 128 | ##3.2 通过全局变量进行通信 129 | 在同一个配置中的程序间,变量可以通过全局变量进行通信。如下图所示: 130 |  131 | 132 | ##3.3 通过通信控制块通信 133 | 两个配置间、一个程序中不同部分之间或者PLC程序与非PLC系统之间可以使用GB/T 15969.5中定义的标准通信功能块,如下图所示: 134 |  135 | 136 | ##3.4 通过存取路径通信 137 | 使用GB/T 15969.5定义的机制,PLC或非PLC系统可以通过存取路径传输可提供的数据。 138 |  139 | 140 | #4 印刷字符的使用 141 | 根据国家标准GB/T 15969.3-2005,可编程控制器使用的文本和图形类编程语言中的文本元素应根据国家标准GB 1988字符集的“基本代码表”的3-7列的字符组成,并根据GB 2312-1980《信息交换用汉字编码字符集 基本集》来表示汉字。 142 | 支持小写字母时,字母的大小写不作区分,即control与CONTROL、Control具有相同的意义。 143 | 汉字只允许出现在注释与附注中,即不参与编写程序逻辑。 144 | ##4.1 引用字符集 145 |  146 | 147 | ##4.2 标识符 148 | 标识符必须由字母、数字和下划线字符组成,标识符用于表示在IEC语言中的不同元素,包括变量、标号和函数、功能块、程序组织单元等名称。使用标识符的规则如下: 149 | - 标识符的第1个字符必须为字母或下划线; 150 | - 标识符中的大小写字母具有相同的意义; 151 | - 标识符中不允许有两个或两个以上连续的下划线; 152 | - 标识符的结尾不能用下划线; 153 | - 标识符至少应支持6个不同的字符,最大字符数与实现有关; 154 | 155 | ##4.3 分界符 156 | 157 | 分界符|应用场合|备注和示例 158 | :-: | :-: | :- 159 | 空格|允许在PLC程序中插入空格 160 | (* *)| 注释起始、结束符号|不允许嵌套注释 161 | { }| 附注起始、结束符号| 162 | +|十进制数字的前缀符号