1. Data Conversion Instruction Classification System
1. Base Conversion Instructions
Instruction Function Typical Application Scenarios
BIN BCD to Binary Instrument Data Reading
BCD Binary to BCD Seven-Segment Display
DBCD 32-bit BCD Calculation High-Precision Counting
2. Character Conversion Instructions
ASC String to ASCII Code Touchscreen Text Display
HEX ASCII to Hexadecimal Communication Protocol Processing
3. Module Read/Write Instructions
FROM Module Data Reading Analog Input
TO Module Data Writing Inverter Parameter Setting
4. Special Conversion Instructions
DECO Decoding Instruction Multi-Stage Speed Control
ENCO Encoding Instruction Status Compression
2. Core Instruction Practical Cases
Case 1: Sensor Data Acquisition System
Task Requirements:
1.Read the BCD code output from the pressure sensor (4 digits)
2.Convert to binary and store in D100, then convert to actual pressure value (kPa)
// Read BCD code
FROM K0 K0 D0 K4 // Read 4-digit BCD code from analog module CH0
// BCD to Binary
BIN D0 D100 // Store in D100
// Calculate actual pressure value
MOV D100 D200 // Binary value
MUL D200 K10 D300 // Convert to kPa (assuming each unit = 10kPa)
Key Steps:
1. FROM instruction reads BCD code
2. BIN instruction converts to binary
3. Multiplication operation to obtain actual engineering quantity
Case 2: Seven-Segment Display System
Task Requirements:
1.Display the value of register D200 (0-9999) on a 4-digit seven-segment display
2.Support real-time updates
// Binary to BCD
BCD D200 K1Y0 // Drive Y0-Y3 (units)
BCD D200 K1Y4 // Drive Y4-Y7 (tens)
BCD D200 K1Y10 // Drive Y10-Y13 (hundreds)
BCD D200 K1Y14 // Drive Y14-Y17 (thousands)
Optimization Points:
1.Use BCD instruction to directly output to Y elements
2.Implement multi-digit display through bit segmentation
Case 3: Modbus Communication System
Task Requirements:
1.Convert temperature value (D100=25℃) to Modbus protocol format
2.Send to the host computer via RS485
// Convert to ASCII code
MOV K25 D100 // Temperature value
ASC “T:” D200 K3 // Concatenate string “T:25”
// Send data
RS D200 D300 K5 K5 // Send 5-byte data
Protocol Analysis:
ASCII code format: “T:25” → 54 3A 32 35 0D (hexadecimal)
RS instruction is responsible for serial communication
Case 4: Inverter Parameter Setting System
Task Requirements:
1.Set the inverter operating frequency (50Hz) through PLC
2.Use FROM/TO instructions to read and write parameters
// Set frequency parameter
MOV K50 D100 // 50Hz
TO K1 K1 D100 K1 // Write inverter parameter 1 (frequency setting)
// Read operating status
FROM K1 K2 D200 K1 // Read inverter parameter 2 (current frequency)
3. Advanced Application Techniques
1. Multi-Byte Data Conversion
// Convert 32-bit data from D100-D101 to BCD
DBCD D100 D200 // Result stored in D200-D201
2. Dynamic Address Read/Write
// Select the module channel to read based on the value of D0
FROM K0 K[D0] D100 K1 // D0=0→CH0, D0=1→CH1
3. Complex Protocol Processing
// Generate Modbus RTU CRC Checksum
MOV D100 D200 // Data Area
CRC D200 K10 D300 // Calculate CRC Checksum
4. Common Problems and Solutions
Problem 1: Incorrect BCD Conversion Result
Cause: Input value exceeds BCD range (0-9999)
Solution: Use double-word BCD instruction (DBCD) or add range detection
Problem 2: ASCII Display Garbled
Cause: Incorrectly concatenated terminators (e.g., 0D 0A)
Solution: Add newline characters (ASCII codes 13 and 10) at the end of the string
Problem 3: FROM/TO Instruction Timeout
Cause: Module did not respond correctly
Solution: Check communication parameters (D8120) and module power supply
5. Pitfall Guide
⚠️ Prohibitions:
1. Do not use 16-bit BCD instruction on 32-bit registers
2. The number of characters for ASCII conversion cannot exceed 256
3. FROM/TO instructions cannot cross program end markers (END)
💡 Optimization Tips:
1.Use MOV K0 D0 to initialize conversion results
2.Add checks (e.g., XOR check) for key conversions
3.Display original data and converted results on the touchscreen
Previous Recommendations
“Comprehensive Analysis of Mitsubishi PLC Comparison Instructions! From Temperature Thresholds to Precise Control of Recipe Ranges”
Comprehensive Analysis of Mitsubishi PLC Logic Operation Instructions! From Simple Bit Operations to Complex State Combinations
Comprehensive Analysis of Mitsubishi PLC Arithmetic Operation Instructions! From Basic Addition and Subtraction to Complex Algorithm Practice
Comprehensive Analysis of Mitsubishi PLC Data Transmission Instructions! From Basics to Practical 5 Core Instructions
Comprehensive Analysis of Mitsubishi PLC Program Flow Control Instructions! 5 Core Instructions + Factory Practical Cases
Next Preview:
“Practical High-Speed Processing Instructions for Mitsubishi PLC”——From Encoder Positioning to Servo Control, a step-by-step guide to capturing instantaneous changes! Follow↓↓
Get more materials and unlock high-speed control black technology~