其他项目
Other projects:
(点击进入 click to enter)
其他项目
Other projects:
(点击进入 click to enter)
项目类别 / Project Category: PLC 高级语言编程 · C 语言 · HMI 交互设计
PLC High-Level Language Programming · C Programming · HMI Interface Design
核心技术 / Core Technologies: PLC · C Programming · Data Structures · Pulse Counting · Angle Calculation · HMI Animation · Parameter Management
本项目为基于 PLC C 语言编程的多路角度监测系统,通过读取四路高速脉冲计数值,计算并实时显示对应工件的旋转角度。
系统针对 Y0、Y1、Y2、Y3 四路脉冲输出进行配置,利用对应的高速计数寄存器 HSD0、HSD4、HSD8、HSD12 获取脉冲累计值。根据电机每转脉冲数、减速比、初始角度及旋转方向,计算工件当前角度,并将结果限制在 0°–359.9° 范围内。
项目重点在于使用 C 语言与结构体组织控制参数及计算逻辑,并通过 HMI 实现角度显示、运动控制、位置清零、角度记录及工件位置动画模拟。
This project involved developing a multi-channel angle monitoring system using C programming in a PLC environment. The system calculated and displayed the rotational angles of four workpieces based on high-speed pulse counts.
Four pulse output channels, Y0, Y1, Y2, and Y3, were configured. Their corresponding high-speed counter registers, HSD0, HSD4, HSD8, and HSD12, provided the accumulated pulse values. The current angle was calculated using the motor pulses per revolution, gear ratio, initial angle, and rotation direction, with the displayed result normalized to the range of 0°–359.9°.
The project focused on organizing parameters and calculation logic with C structures, while providing HMI functions for angle display, motion control, position clearing, angle logging, and animated workpiece-position visualization.
四路角度计算 / Four-Channel Angle Calculation: 根据四路高速脉冲计数值,分别计算各工件的当前角度。
Calculate the current angle of each workpiece from its corresponding high-speed pulse count.
参数配置 / Parameter Configuration: 支持设置每转脉冲数、减速比、初始角度及正反转方向。
Configure pulses per revolution, gear ratio, initial angle, and rotation direction.
实时角度显示 / Real-Time Angle Display: 将角度结果规范化至 0°–359.9° 范围。
Normalize calculated angles to the range of 0°–359.9°.
启动与停止 / Start and Stop: 启动后发送脉冲并更新角度;停止后保持当前角度,再次启动时继续累计。
Generate pulses and update angles during operation, hold the current angle after stopping, and resume from the held angle when restarted.
位置清零 / Pulse Position Clearing: 停止后可清零累计脉冲位置,同时保持当前显示角度不变。
Clear the accumulated pulse position while stopped without changing the displayed angle.
复位控制 / Reset Control: 按照设定的复位流程,先返回 0°,再运动至初始角度。
Follow the configured reset sequence by returning to 0° before moving to the initial angle.
角度记录 / Angle Logging: 停止状态下可记录当前角度并添加序号,最多保存 10 组记录,存满后循环覆盖旧记录。
Record the current angle with an index while stopped, storing up to 10 entries before overwriting the oldest records.
系统根据脉冲累计量与机械传动参数之间的关系,计算工件相对于参考位置的旋转角度。
主要参数包括:
每转脉冲数: 电机旋转一圈所需的脉冲数,使用 32 位整型数据。
减速比: 工件旋转一圈时电机旋转的圈数,使用 16 位整型数据。
初始角度: 工件位于参考位置时对应的初始角度,范围为 0°–359.9°。
旋转方向: 正转时,脉冲累计使工件角度增加;反转时,脉冲累计使工件角度减小。
工件旋转一周所对应的脉冲数由每转脉冲数与减速比共同决定。计算时还需考虑角度周期归一化、正反转处理及整型运算中的溢出风险。
The system calculated the workpiece angle from the accumulated pulse count and the mechanical transmission parameters.
The main parameters included:
Pulses per Revolution: The number of pulses required for one motor revolution, stored as a 32-bit integer.
Gear Ratio: The number of motor revolutions corresponding to one workpiece revolution, stored as a 16-bit integer.
Initial Angle: The reference angle of the workpiece, within the range of 0°–359.9°.
Rotation Direction: The angle increases with accumulated pulses in the forward direction and decreases in the reverse direction.
The pulse count corresponding to one complete workpiece revolution is determined by the pulses per motor revolution and the gear ratio. The calculation also needs to account for angular normalization, rotation direction, and potential overflow during integer arithmetic.
PLC C 语言编程 / PLC C Programming: 在 PLC 环境中组织数据处理与控制逻辑。
Organizing data processing and control logic in a PLC environment.
结构体与数据管理 / Structures and Data Management: 使用结构体管理多路通道的相关参数。
Using structures to manage parameters across multiple channels.
脉冲计数与角度计算 / Pulse Counting and Angle Calculation: 根据脉冲累计量和机械参数计算周期性角度。
Calculating periodic angles from accumulated pulse counts and mechanical parameters.
寄存器规划与溢出处理 / Register Allocation and Overflow Handling: 关注数据类型、寄存器对齐与整型运算边界。
Addressing data types, register alignment, and integer arithmetic limits.
HMI 动画与交互 / HMI Animation and Interaction: 将计算结果转化为可视化位置显示,并提供操作入口。
Translating calculated results into visual position displays and operator controls.
培训实践作品,展示个人学习成果。 / Training work presented to demonstrate personal learning outcomes.
本网站中的部分视频及相关作品形成于本人在无锡信捷电气股份有限公司工作期间的培训与学习过程,旨在记录个人学习成果、展示相关技能及职业发展经历,仅用于个人职业作品集展示与非商业性交流。
本人不以相关作品进行商业销售、商业推广或其他营利性活动。本网站亦不意图侵犯任何第三方的知识产权、商业秘密或其他合法权益。
如相关权利人认为本网站展示的内容存在权利争议或不适宜公开展示,请通过网站联系方式与本人联系。本人将及时核实,并视具体情况采取修改、移除或其他适当措施。
Some videos and related works on this website were created during my training and learning activities while working at Wuxi Xinje Electric Co., Ltd. They are intended to document my learning outcomes, demonstrate relevant skills, and reflect my professional development. These materials are presented solely for my personal professional portfolio and non-commercial purposes.
I do not use these materials for commercial sales, commercial promotion, or other profit-making activities. Nothing on this website is intended to infringe upon the intellectual property rights, trade secrets, or other lawful rights and interests of any third party.
If any rights holder believes that any content displayed on this website raises rights-related concerns or should not be publicly available, please contact me through the contact information provided on this website. I will review the matter promptly and, as appropriate, revise or remove the relevant content or take other suitable measures.