Wiki source code of Управление шпинделем по Modbus на примере Sunfar E550 и платы расширения PLCM-B1-G2
Last modified by writer on 2023/02/20 13:47
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
14.1 | 1 | You will need a frequency converter (hereinafter referred to as the FC) with support for Modbus RTU control, such as Sunfar E500, to control the spindle via Modbus via the PLCM-B1-G2 expansion board. |
![]() |
2.1 | 2 | |
![]() |
14.1 | 3 | Modbus spindle control setting procedure: |
![]() |
2.1 | 4 | |
![]() |
14.1 | 5 | 1. Set FC to the control mode using the Modbus RTU protocol (RS-485) and remember the COM port settings in FC (count of bits per second, data bits, parity and stop bits). |
![]() |
2.1 | 6 | |
![]() |
14.1 | 7 | Example for Sunfar E500. |
![]() |
2.1 | 8 | |
![]() |
14.1 | 9 | |=(% style="text-align: center; width: 150px;" %)Function code|=(% style="text-align: center; width: 100px;" %)Value|=(% style="text-align:center" %)Description |
10 | |(% style="width:150px" %)F0.00|(% style="width:100px" %)2|Frequency reference source - external data transfer | ||
11 | |(% style="width:150px" %)F0.02|(% style="width:100px" %)0002|Trigger channel selection - serial data port | ||
12 | |(% style="width:150px" %)F4.00|(% style="width:100px" %)0114|Data transfer settings - speed selection: 9600 bps, parity check, Modbus data transfer protocol | ||
![]() |
2.1 | 13 | |
![]() |
3.1 | 14 | (% style="margin-left: 30.0px;" %) |
![]() |
14.1 | 15 | 2. Connect FC to the PLCM-B1-G2 expansion board via RS-485 interface. |
![]() |
2.1 | 16 | |
![]() |
3.1 | 17 | (% style="margin-left: 30.0px;" %) |
![]() |
14.1 | 18 | 3. Purchase the "[[MODBUS protocol support>>http://pumotix.ru/#soft]]" option or activate a trial period for this option in the menu "Configuration" → "License Manager" → "Common". |
![]() |
2.1 | 19 | |
![]() |
3.1 | 20 | (% style="margin-left: 30.0px;" %) |
![]() |
14.1 | 21 | 4. Enable and configure Modbus in the menu "Configuration" → "Modbus Setup". |
![]() |
2.1 | 22 | |
![]() |
14.1 | 23 | Create new Modbus-master. Number of COM port is PLCM. The rest of the settings should be exactly the same as in the FC (in the screenshot, an example of a standard configuration of the COM port of Sunfar E500). |
![]() |
2.1 | 24 | |
![]() |
14.1 | 25 | [[image:modbus_master_en.png||alt="master_plcm.png" data-xwiki-image-style-alignment="center" height="300" width="367"]] |
![]() |
2.1 | 26 | |
![]() |
14.1 | 27 | You need to add registers to control the FC and read statuses from FC. For example you need to configure registers named **SpindleMode**, **SpindleRPM** and **SpindleStatus**. |
![]() |
2.1 | 28 | |
![]() |
14.1 | 29 | We recommend using exactly these names, since in the future, registers will be accessed from background operations by their names. |
![]() |
2.1 | 30 | |
![]() |
14.1 | 31 | (% style="text-align:center" %) |
32 | [[image:Modbus_Settings_example_E500.png||alt="registers_plcm.png" data-xwiki-image-style-alignment="center" height="444" width="1000"]] | ||
![]() |
2.1 | 33 | |
34 | {{success}} | ||
![]() |
14.1 | 35 | Register numbers must be specified as decimal values. |
![]() |
2.1 | 36 | {{/success}} |
37 | |||
38 | {{warning}} | ||
![]() |
14.1 | 39 | These values can be indicated in HEX (hexadecimal) in the instructions for the frequency converter. For example, 0x1001, 0x1002 |
![]() |
2.1 | 40 | {{/warning}} |
41 | |||
![]() |
3.1 | 42 | (% style="margin-left: 30.0px;" %) |
![]() |
14.1 | 43 | 5. Create new background operation (macro) through [[the macro manager>>doc:Руководство пользователя.Описание M-кодов.Управление макросами и фоновыми операциями.WebHome]]. |
![]() |
2.1 | 44 | |
![]() |
14.1 | 45 | The main task of the background macro is to monitor the current state and spindle speed and send the values to the frequency converter via Modbus. |
![]() |
2.1 | 46 | |
![]() |
14.1 | 47 | An example of [[background operation>>doc:Руководство пользователя.Описание фоновых операций.Создание фоновой операции.WebHome]] **modbus_spindle.bm** for ModBus spindle control posted in attachment. This file must be added to background operations list. |
![]() |
2.1 | 48 | |
![]() |
14.1 | 49 | **[[Download background operation>>attach:modbus_spindle (1).bm]]** |
![]() |
2.1 | 50 | |
51 | {{warning}} | ||
![]() |
14.1 | 52 | Access to Modbus registers from macros is done by the name of the Modbus register case sensitive! For example, **SpindleRPM** and **SpindleRpm** are different registers. |
![]() |
2.1 | 53 | {{/warning}} |
54 | |||
![]() |
3.1 | 55 | (% style="margin-left: 30.0px;" %) |
![]() |
14.1 | 56 | 6. Enable the background operation. Make sure that the operation has started and is working properly. This will be indicated by the green indicator to the right of the operation name. |
![]() |
2.1 | 57 | |
![]() |
14.1 | 58 | (% style="text-align:center" %) |
59 | [[image:Macros_Manager_wndw.png||alt="2021-11-29 14_18_03-Управление макросами.png" data-xwiki-image-style-alignment="center" height="400" width="544"]] | ||
![]() |
2.1 | 60 | |
![]() |
14.1 | 61 | The spindle should now turn on and off if everything is configured correctly. The spindle speed accordingly must also change at the FC when it changing in PUMOTIX. |