====== Arduino IDE · Connecting an HMI with Mitsubishi MC 1C ====== [[:en-us_guide:hmi_connection|HMI Connection overview]] · [[:en-us_guide:hmi_connection:arduino|Arduino IDE setup]] The MC Slave in this SDK handles **MELSEC A-compatible 1C frame, Format 1 serial ASCII** requests. Set the HMI driver to that frame format and to **Sum Check enabled**. Ordinary MC 3E/4E frame drivers and MC TCP drivers cannot connect to this example. ''M'' and ''D'' are specified by the device letter and number in the 1C request. The example on this page uses **MPINO-8A4R-S · RS-232 ''Serial1'' · station 1 · 9600 bps · 8N1** and is for Arduino IDE. Check [[:en-us_guide:hmi_connection:wiring|channels and wiring]] and [[:en-us_guide:hmi_connection:arduino|SDK installation and board selection]]. The MPINO STUDIO2 Communication settings do not include this protocol. ===== 1. Addresses for the HMI screen ===== ^ Screen element ^ SDK memory ^ Device and address in the 1C request ^ Request command ^ | Communication check number | ''D0'' | ''D0000'' | Word read ''WR'', repeats 0~99 | | Number input | ''D1'' | ''D0001'' | Word write ''WW'', 0~9999 | | Returned value | ''D2'' | ''D0002'' | Word read ''WR'', same as D1 | | Test switch and lamp | ''M0'' | ''M0000'' | Bit write ''BW'', read ''BR'' | ''D0000'' and ''M0000'' in the table are **the device code and 4-digit decimal address in the 1C request the core receives**. HMI editors display this differently by driver, so confirm that the actual request points to this address. **The Modbus address conversion table does not apply to MC.** Number format, switch, and lamp settings are covered in [[:en-us_guide:hmi_connection:screen|Building the HMI Screen]]. ===== 2. Enter the complete code in a new sketch ===== This simple example exchanges internal memory values at the 1C addresses above. It does not use any real input or relay output pins. #include unsigned long lastTick = 0; void setup() { IMcMem(0, 0, 16, 16); // X/Y not used; includes M0 and D0~D2 IMcAdr(0, 0, 0, 0); // External addresses also start at 0 IMcInit(Serial1, 1, 9600); lastTick = millis(); } void loop() { if (M == nullptr || D == nullptr) return; IMcProtocol(); unsigned long now = millis(); if (now - lastTick >= 1000UL) { lastTick = now; D[0] = (D[0] >= 99) ? 0 : D[0] + 1; } if (D[1] > 9999) D[1] = 9999; D[2] = D[1]; } ''IMcMem()'' allocates the memory at startup, and ''IMcProtocol()'' handles HMI requests on every loop. ===== 3. Verify, upload, and build the HMI screen ===== After uploading the sketch, place the HMI elements using the screen example below and the address table above. {{ :en-us_guide:hmi_connection:practice-screen.svg?420 |D0 communication check number, D1 input, D2 returned value, M0 test switch and lamp }} - Save the sketch and run **Verify** in Arduino IDE. - Check **Tools → Board** and the upload COM port, then select **Upload**. See [[:en-us_guide:getting_started|Getting Started with Arduino IDE]]. - In [[:en-us_guide:hmi_connection:screen|Building the HMI Screen]], assign ''D0000~D0002'' and ''M0000'' above to external device elements, then transfer the HMI project. - Turn on the product and the HMI, then test read → write → bit in [[:en-us_guide:hmi_connection:check|Checking Operation and Troubleshooting]]. {{ :en-us_guide:hmi_connection:write-read-flow.svg?420 |The HMI writes D1 and M0, then reads back the product's D2 and M0 to check the result }} First confirm that the HMI driver sends **1C, Format 1, Sum Check** requests. Expected results and where to look for each symptom are listed in [[:en-us_guide:hmi_connection:check|Checking Operation and Troubleshooting]].