====== MPINO STUDIO2 · Connecting an HMI with LS Electric Cnet ====== [[:en-us_guide:hmi_connection:studio2:modbus|← Modbus RTU exercise]] · [[:en-us_guide:hmi_connection:studio2|STUDIO2 start]] In STUDIO2's LS Electric Cnet Slave, ''%DW0'' in a Cnet request corresponds to internal ''D0'', and ''%MX00000'' corresponds to internal ''M0''. In LS Electric, M2I, and EasyView HMI editors, select the Cnet driver and enter M and D memory names such as ''D000'' and ''M000''. Modbus Coil ''1000'' and Holding Register ''2000'' are not Cnet addresses. Start this conversion example **after you have created the project, set the memory, built the ladder, entered the ''main'' code, and finished the first build and upload in the [[:en-us_guide:hmi_connection:studio2:modbus|STUDIO2 Modbus RTU example]]**. You do not need to build the Modbus HMI screen or test real communication first. The Arduino IDE Cnet example does not have this prerequisite. ===== 1. Change the communication protocol ===== - Open ''HMI_First_Test.mp2'', which has completed its first build and upload, and save it as ''HMI_Cnet_Test.mp2'' under **File → Save As**. - Open **Run → Communication** and change the protocol of ''Serial1'' to **LS Electric Cnet Slave**. - Check Slave ID ''1'', Baud Rate ''9600'', Data Bits ''8'', Stop Bits ''1'', and Parity ''None'', then press ''Ctrl+S'' to save. **The figure below is an initial screen that shows where each item is.** Its protocol **''None''** and baud rate **''115200''** are not the values for this exercise. Set and save **''LS Electric Cnet Slave'' and ''9600''** as described above. {{ :en-us_products:mpino_studio2:communication-settings-marked.svg?1000 |Initial screen showing where each item is. The protocol None and 115200 in the figure are only an example; this exercise changes them to LS Electric Cnet Slave and 9600. }} On the HMI side, check the Cnet driver and connection port in [[:en-us_guide:hmi_connection:wiring#choose_a_protocol|Choose a protocol]]. ===== 2. Check the internal ladder and code ===== **Settings → Memory Area Settings** remains P ''64'' and M, D, C, T, and R ''16'' each, and **Use** for all physical pins remains cleared in **Ladder Pin Map Settings**. **Ladder → ladderLoop** is the single rung NO contact ''M0'' → output coil ''M1''. {{ :en-us_guide:hmi_connection:internal-ladder.svg?420 |Ladder that copies internal M0 to M1 without any real output }} Keep the ''main'' code the same as [[:en-us_guide:hmi_connection:studio2:modbus#one_ladder_rung_and_the_main_code|the complete code in the Modbus exercise]]. STUDIO2 generates the communication functions, so do not add ''ICnetMem()'', ''ICnetInit()'', or ''ICnet()'' yourself. Internal ''D0'' increments every second, and a value the HMI writes to ''D001'' is copied from internal ''D1'' to ''D2''. When the HMI changes ''M000'', you can see the ladder result ''M1'' at the HMI's ''M001''. ''D'' is a **signed 16-bit integer**. ===== 3. Cnet HMI addresses ===== ^ HMI element ^ STUDIO2 internal memory ^ HMI entry example ^ Operation ^ | Number that changes every second | ''D0'' | ''D000'' | Read | | Number input | ''D1'' | ''D001'' | Read and write | | Number that returns the input value | ''D2'' | ''D002'' | Read | | Switch and check lamp | ''M0'' | ''M000'' | Write and read | | Lamp for the ladder result | ''M1'' | ''M001'' | Read | The HMI entry examples apply to LS Electric, M2I, and EasyView HMIs. For other HMIs, check the address format of the selected Cnet driver. Modbus Coil ''1000'' and Holding Register ''2000'' are not Cnet addresses. Set the three numbers to **16-bit integer, 1 word, 0 decimal places, scale 1**, and limit the input range to ''0~9999''. Set the switch to write ''M000'' as a toggle, and read it back with a separate lamp. This program does not control any physical output. ===== 4. Rebuild and check ===== - Run **Run → Build** (''Ctrl+R'') and check that there are no errors. - Select the PC COM port of your product's download cable in the status bar, then run **Run → Upload** (''Ctrl+U''). Confirm that the upload log in the bottom panel **ends normally**. For the port and log locations, see [[:en-us_products:mpino_studio2:first_project#select_a_port_and_upload|Select a Port and Upload]]. - In [[:en-us_guide:hmi_connection:screen|Building the HMI Screen]], select the Cnet driver, assign ''D000''~''D002'' and ''M000'' and ''M001'' from the table above, then save and transfer with station ''1'' and ''9600/8N1''. Use ''Serial1'' on the product only for HMI communication. - After connecting the hardware, check in this order in [[:en-us_guide:hmi_connection:check|Checking Operation and Troubleshooting]]: read ''D000'' → write ''D001'' and read ''D002'' → bits ''M000/M001''. This example was checked up to code generation and compilation with the SDK installed by STUDIO2. **The behavior of a specific HMI driver and cable must be verified separately.** [[:en-us_guide:hmi_connection:screen|Building the HMI Screen →]] · [[:en-us_guide:hmi_connection:check|Checking Operation and Troubleshooting →]]