Wiki source code of Управление шпинделем по ModBus на примере Sunfar V350
Last modified by writer on 2023/02/20 13:25
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | You need next devises to control the spindle via Modbus: | ||
| 2 | |||
| 3 | 1. RS-485 adapter for connecting a frequency converter to a PC. | ||
| 4 | 1. Frequency converter (FC) with support for control via Modbus RTU. | ||
| 5 | 1. (% style="color:#1d1c1d" %)Expansion board for frequency converter: IOV-A102; IOV-D104; IOV-D105 ([[more information...>>url:https://purelogic.ru/docs/elektronika/Plata_rasshireniya_dlya_SUNFAR_V350_V560_instruction_ru.pdf||shape="rect" style="text-decoration: none;text-align: left;"]]). | ||
| 6 | |||
| 7 | ==== Modbus spindle control setting procedure ==== | ||
| 8 | |||
| 9 | (% style="margin-left: 30.0px;" %) | ||
| 10 | ~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). | ||
| 11 | |||
| 12 | |=(% style="text-align: center; width: 150px;" %)Function code|=(% style="text-align: center; width: 100px;" %)Value|=(% style="text-align: center;" %)Description | ||
| 13 | |(% colspan="3" style="text-align:center" %)**Enable spindle parameter control via ModBus** | ||
| 14 | |(% style="width:150px" %)F0.0.02|(% style="width:100px" %)1580|Password for access to change parameters. Entered through the operation panel. | ||
| 15 | |(% style="width:150px" %)F0.0.00 |(% style="width:100px" %)0|Custom control profile. | ||
| 16 | |(% style="width:150px" %)F0.3.33|(% style="width:100px" %)2|Control profile selection - via ModBus. | ||
| 17 | |(% style="width:150px" %)F0.2.25|(% style="width:100px" %)17|Frequency reference using ModBus Field Set 2 register. | ||
| 18 | |(% style="width:150px" %)F3.0.00|(% style="width:100px" %)18|Setting digital input №1 of the FC: setting the function Fu.0.17 (external equipment fault) - when the contact is closed to the inputs, the FC will smoothly stop. | ||
| 19 | |(% colspan="3" style="text-align:center" %)**ModBus connection settings** | ||
| 20 | |(% style="color:#7a869a; width:150px" %)FA.0.00|(% style="color:#7a869a; width:100px" %)1|(% style="color:#7a869a" %)Read only. It will display the currently selected control mode (ModBus). | ||
| 21 | |(% style="width:150px" %)FA0.01|(% style="width:100px" %)03|((( | ||
| 22 | Select the baud rate and packet format. | ||
| 23 | Least significant decimal place (baud rate kbit/s): 1 — 1200, 2 — 2400, 3 — 4800, 3 — 9600, 4 – 19200, 5 – 38400, 6 – 76800. | ||
| 24 | The next digit (number of stop bits and parity): 0 — 1N, 1 – 1E, 2 – 1O, 3 – 2N (N – none, e – Even, O – odd). | ||
| 25 | For example, 03 = no parity, one stop bit, 9600. | ||
| 26 | ))) | ||
| 27 | |(% style="width:150px" %)FA.0.02|(% style="width:100px" %)1|Device address on the bus. | ||
| 28 | |(% style="width:150px" %)FA.0.03|(% style="width:100px" %)10|Answer delay (ms). | ||
| 29 | |(% style="width:150px" %)FA.0.04|(% style="width:100px" %)1000|Network failure detection time (ms). The frequency converter will stop the spindle and stop working after this time. | ||
| 30 | |(% style="width:150px" %)FA.0.05|(% style="width:100px" %)0|Reaction to connection loss: 0 — spindle stop, 1 — continue executing the previous command. | ||
| 31 | |(% colspan="3" style="text-align:center" %)**Save settings** | ||
| 32 | |(% style="width:150px" %)F0.0.08|(% style="width:100px" %)2| | ||
| 33 | |||
| 34 | (% style="margin-left: 30.0px;" %) | ||
| 35 | 2. Connect FC to the PC via the RS-485 adapter. You may need to install the driver for the RS-485 adapter for Windows. | ||
| 36 | |||
| 37 | (% style="margin-left: 30.0px;" %) | ||
| 38 | 3. Verify that the adapter in RS-485 was detected by the operating system. Use the Windows Device Manager for this. | ||
| 39 | |||
| 40 | [[image:wndws_Device_Manager.png||alt="image2019-11-5_17-13-40.png" data-xwiki-image-style-alignment="center" height="500" width="709"]] | ||
| 41 | |||
| 42 | (% class="auto-cursor-target" style="margin-left: 30.0px;" %) | ||
| 43 | 4. Purchase the "[[MODBUS protocol support>>url:http://pumotix.ru/#soft||rel="nofollow" shape="rect" style="text-decoration: none;" class="external-link"]]" option or activate a trial period for this option in the menu "Configuration" → "License Manager" → "Common". | ||
| 44 | |||
| 45 | (% style="margin-left: 30.0px;" %) | ||
| 46 | 5. Enable and configure Modbus in the menu "Configuration" → "Modbus Setup". | ||
| 47 | |||
| 48 | Create new Modbus-master. Number of COM port is RS-485 adapter number. 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). | ||
| 49 | |||
| 50 | [[image:COM_master_example.png||alt="master.png" data-xwiki-image-style-alignment="center" height="300" width="367"]] | ||
| 51 | |||
| 52 | You need to add registers to control the FC and read statuses from FC. For example you need to configure registers named **CtrlWord** и **FreqSet **for Sunfar V350, also additional registers for diagnostics. | ||
| 53 | |||
| 54 | We recommend using exactly these names, since in the future, registers will be accessed from background operations by their names. | ||
| 55 | |||
| 56 | [[image:Modbus_Settings_example_V350.png||data-xwiki-image-style-alignment="center" height="359" width="1000"]] | ||
| 57 | |||
| 58 | {{success}} | ||
| 59 | Register numbers must be specified as decimal values. | ||
| 60 | {{/success}} | ||
| 61 | |||
| 62 | {{warning}} | ||
| 63 | These values can be indicated in HEX (hexadecimal) in the instructions for the frequency converter. For example, 0x1001, 0x1002 | ||
| 64 | {{/warning}} | ||
| 65 | |||
| 66 | (% style="margin-left: 30.0px;" %) | ||
| 67 | 6. Create new background operation (macro) through [[the macro manager>>doc:Руководство пользователя.Описание M-кодов.Управление макросами и фоновыми операциями.WebHome||shape="rect" style="text-decoration: none;"]]. | ||
| 68 | |||
| 69 | 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. | ||
| 70 | |||
| 71 | An example of [[background operation>>doc:Руководство пользователя.Описание фоновых операций.Создание фоновой операции.WebHome||shape="rect" style="text-decoration: none;"]] **modbus_spindle_v350.bm** for ModBus spindle control posted in attachment. This file must be added to background operations list. | ||
| 72 | |||
| 73 | **[[Download background operation>>attach:modbus_spindle_v350.zip]]** | ||
| 74 | |||
| 75 | {{warning}} | ||
| 76 | 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. | ||
| 77 | {{/warning}} | ||
| 78 | |||
| 79 | (% style="margin-left: 30.0px;" %) | ||
| 80 | 7. 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. | ||
| 81 | |||
| 82 | [[image:Macros_Manager_wndw_V350.png||alt="2022-05-12 09_22_49-Управление макросами.png" data-xwiki-image-style-alignment="center" height="500" width="681"]] | ||
| 83 | |||
| 84 | 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. |