当前位置:网站首页>Communication example between upper computer and Mitsubishi fn2x
Communication example between upper computer and Mitsubishi fn2x
2022-07-28 12:41:00 【yi_ tianchou】
According to the needs of the project, the upper computer software and Mitsubishi PLC communicate ,C# and PLC It's all zero base ,
C# The learning process is brief , It's not hard to , Just learn space
The following is a brief description and PLC Key steps of communication :
1、 Serial port settings :
1) Serial line ( Mitsubishi's 422 Line )
2) Serial tools
Baud rate :9600 (PLC Is constant )
Parity test : Even check (PLC fixed )
Data bits :7
Stop bit :1
2、 Communication test
Upper computer : send out 0x05
PLC: Respond 0x06( normal ) return 0x15 The instruction is invalid , Look at your serial port settings
3、 obtain x Current status of points
1) Communication format
read :
| STX | CMD | x/y Address (4 byte ) | Read a few bytes | EXT | check | |||||
| 0x02 | '0' read / '1' Write | ‘0’ | '0' | 'A' | '0' | ‘0’ | ‘2’ | 0x03 | ‘6’ crc1 | ‘6’ crc2 |
| Fixed value 0x02 | 0x30 /0x31 | 0x30 | 0x30 | 0x41 | 0x30 | 0x30 | 0x32 | Fixed value | 0x36 | 0x36 |
notes : ‘A’ direct turn asiic code Put the characters ‘9’-9= 0x30 ‘A’ - 0x0a = 0x31, Notice here , When calculating, we should treat them differently
Check value calculation :CMD+ Address values + Read byte value +ext = The sum of the
temp = The sum of the &0xff
a = ((temp >> 4) & 0x0f) > 9 ? ((temp >> 4) & 0x0f) + 7 : ((temp >> 4) & 0x0f);
b = (temp & 0x0f) > 9 ? ((temp & 0x0f) + 7) : (temp & 0x0f);
crc1= (byte) ( a + 0x30);
crc2= (byte)( b + 0x30);
PLC return :
Erroneous return :0x15
Successfully returns :
| STX | The first value | Second value | EXT | check | |||
| 0x02 | ‘3’ | '5' | '8' | '4' | 0x03 | ‘D’ crc1 | ‘7’ crc2 |
| Fixed value 0x02 | 0x33 | 0x35· | 0x38 | 0x34 | Fixed value | 0x44 | 0x37 |
The first value :
| y7 | y6 | y5 | y4 | y3 | y2 | y1 | y0 |
| 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 3 | 5 | ||||||
Second value
| y17 | y16 | y15 | y14 | y13 | y12 | y11 | y10 |
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 8 | 4 | ||||||
Multibyte isomorphism 2 Byte way
Write :
| STX | CMD | x/y Address (4 byte ) | Read a few bytes | The first value | Second value | EXT | check | |||||||
| 0x02 | ' '1' Write | ‘0’ | '0' | 'A'(Y Address ) | '0' | ‘0’ | ‘2’ | ‘3’ | ‘5’ | ‘8’ | ‘4’ | 0x03 | ‘6’ crc1 | ‘6’ crc2 |
| Fixed value 0x02 | 0x31 | 0x30 | 0x30 | 0x41 | 0x30 | 0x30 | 0x32 | 0x33 | 0x35 | 0x38 | 0x34 | Fixed value | 0x33 | 0x42 |
The first value :
| y7 | y6 | y5 | y4 | y3 | y2 | y1 | y0 |
| 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
| 3 | 5 | ||||||
Second value :
| y17 | y16 | y15 | y14 | y13 | y12 | y11 | y10 |
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| 8 | 4 | ||||||
Write success returns :0x06
Write failure returns :0x15
PLC The corresponding relationship between register points :
x: 0x0080
y:0x00a0
边栏推荐
- Is it difficult for cloud native machine learning to land? Lingqueyun helps enterprises quickly apply mlops
- If you don't roll the golden nine and silver ten, it's too late
- 合并表格行---三层for循环遍历数据
- Some API interfaces purchased by Yiwu hope to bring you some help
- HC-05蓝牙模块调试从模式和主模式经历
- With the continuous waves of infringement, the U.S. patent and trademark office began to study the impact of NFT on copyright
- Distributed timer
- 用C语言开发NES游戏(CC65)11、Metatiles
- Merge table rows - three levels of for loop traversal data
- Uninstall Navicat: genuine MySQL official client, really fragrant!
猜你喜欢

Exploration on cache design optimization of community like business

03 pyechars 直角坐标系图表(示例代码+效果图)

Developing NES games with C language (cc65) 08. Background collision

金山云冲刺港股拟双重主要上市:年营收90亿 为雷军力挺项目

西门子对接Leuze BPS_304i 笔记

Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held

Brief discussion on open source OS distribution

新零售电商O2O模式解析

用C语言开发NES游戏(CC65)07、控制器

Redis implements distributed locks
随机推荐
30 years of open source community | 2022 open atom global open source summit 30 years of special activities of open source community were successfully held
Open source database innovation in the era of digital economy | the 2022 open atom global open source summit database sub forum was successfully held
sqli-labs(less-8)
What SaaS architecture design does a software architect need to know?
How to realize more multimedia functions through the ffmpeg library and NaPi mechanism integrated in openharmony system?
Four authentic postures after suffering and trauma, Zizek
04 pyechars 地理图表(示例代码+效果图)
Developing NES games with C language (cc65) 04. Complete background
Some API interfaces purchased by Yiwu hope to bring you some help
用C语言开发NES游戏(CC65)09、滚动
The usage and Simulation Implementation of vector in STL
【Base】优化性能到底在优化啥?
揭秘界面控件DevExpress WinForms为何弃用受关注的MaskBox属性
Redis implements distributed locks
Develop NES game (cc65) 07 and controller with C language (collision with spirit)
AVL tree (balanced search tree)
SuperMap game engine license module division
Configure jupyter remote server
奥浦迈生物通过注册:半年营收1.47亿 国寿成达与达晨是股东
Unity 安装 Device Simulator