Wiki source code of 6.1 Position Control

Last modified by Mora Zhou on 2023/12/21 15:47

Hide last authors
Leo Wei 1.1 1 = Instruction =
2
3 Position control mode is the most important and commonly used control mode of servo system. Position control refers to controlling the position of the motor through position commands, determining the target position of the motor based on the total number of position commands, and the frequency of the position command determines the rotation speed of the motor. The servo drive could achieve fast and accurate control of the position and speed of the machine. Therefore, the position control mode is mainly used in applications requiring positioning control, such as manipulators, chip mounters, engraving machines, CNC machine tools, etc.
4
5 **The block diagram of position control is as follows:**
6
7 [[image:6.1Position Control Mode_html_609e40846452ee6f.jpg||height="236" width="694"]]
8
9 Figure 6-2 Position control diagram
10
11 = Position Reference Input Setting =
12
13 The servo drive has 1 set of pulse input terminals for receiving position pulse input (through the CN2 terminal of the drive)
14
15 [[image:6.1Position Control Mode_html_b4583250d8c6f14a.jpg||height="320" width="366"]]
16
17 The reference from the host controller could be differential output or open collector output. The maximum input frequency is shown in** the following table:**
18
19 |=**Pulse Type**|=**Differential**|=**Open collector**
20 |Max. frequency|500k|200k
21 |Voltage|5V|24V
22
23 1. **Low-speed Pulse Input   **Differential drive mode
24
25 [[image:6.1Position Control Mode_html_490dedbefe04fcc2.jpg||height="306" width="458"]]
26
27 1. **OC mode**
28
29 [[image:6.1Position Control Mode_html_569c7689f69f646.jpg||height="343" width="509"]]
30
31 1. Position pulse selection
32
33 **The servo drive supports three pulse input formats:**
34
35 Direction + pulse (positive logic),Phase A + phase B quadrature pulse (4-frequency multiplication), CW + CCW
36
37 |=**Code**|=**Parameter Name**|=**Property**|=(((
38 **Effective**
39
40 **Time**
41 )))|=**Range**|=**Function**|=**Unit**|=**Default**
42 |P0-12|Position pulse type selection|At stop|(((
43 Power-on
44
45 again
46 )))|0~~2|(((
47 0:Direction + pulse (positive logic)
48
49 1:CW/CCW
50
51 2:Phase A + phase B quadrature pulse (4-frequency multiplication)
52 )))|-|0
53
54 **The corresponding pulse waveform is as follows:**
55
56 [P0-12]=0 (Direction + pulse(positive logic))
57
58 **PULSE:**Pulse **SIGN:**Signal
59
60 |Positive pulse waveform|Negative pulse waveform
61 |[[image:6.1Position Control Mode_html_7a9487f068524a06.jpg||height="72" width="270"]]|[[image:6.1Position Control Mode_html_a14dfb549ce24194.jpg||height="69" width="270"]]
62
63 **(b)[P0-12]=1(CW/CCW)**
64
65 **PULSE:**Pulse **SIGN:**Signal
66
67 |Diagram
68 |[[image:6.1Position Control Mode_html_a902eee139336d62.png||height="66" width="404"]]
69
70 **(c)[P0-12]=2(**Phase A + phase B quadrature pulse (4-frequency multiplication)**)**
71
72 **PULSE(A phase):**pulse **SIGN(B phase):**signal
73
74 |Positive pulse waveform|Negative pulse waveform
75 |(((
76 A advances B by 90°
77
78 [[image:6.1Position Control Mode_html_b76ec4546293bb58.png||height="66" width="268"]]
79 )))|(((
80 B advances A by 90°
81
82 [[image:6.1Position Control Mode_html_811c198d2fd30ab6.png||height="66" width="270"]]
83 )))
84
85 **Position pulse frequency and anti-interference level**
86
87 Filtering time is necessary for the reference input pin to prevent external interference input to the driver and affect the control of the motor. The signal input and output waveforms with filtering enabled are shown in** the following figure:**
88
89 [[image:6.1Position Control Mode_html_ae99a14a8a0edd6a.jpg||height="238" width="581"]]
90
91 Figure 6-3 Filtering signal waveform
92
93 The input pulse frequency refers to the frequency of the input signal, and the frequency of the input pulse command could be modified through the function code [P0-13]. If the actual input frequency is greater than [P0-13], it may cause pulse loss or alarm. The function code [P0-14] could adjust the position pulse anti-interference level, the greater the value, the greater the depth of the filter.
94
95 **Relevant function code:**
96
97 |=**Code**|=**Parameter Name**|=**Property**|=(((
98 **Effective**
99
100 **Time**
101 )))|=**Range**|=**Function**|=**Unit**|=**Default**
102 |P0-13|Position pulse frequency|At stop|(((
103 Power-on
104
105 again
106 )))|1~~500|Set the maximum pulse frequency|kHz|300
107 |P0-14|Position pulse anti-interference level|At stop|(((
108 Power-on
109
110 again
111 )))|1~~3|(((
112 Set the pulse anti-interference level.
113
114 1:Low anti-interference level. (0.1)
115
116 2: Medium (0.25)
117
118 3: High (0.4)
119 )))|-|2
120
121 = Electronic Gear Ratio =
122
123 **[Glossary]**
124
125 **Reference unit:** It means the minimum value the host controller input to the servo drive.
126
127 **Encoder unit:** It means that the value from the input reference processed with the electronic gear ratio.
128
129 **[Electronic gear ratio definition]**
130
131 In position control mode, the input position reference (reference unit) defines the load displacement. the motor position reference (encoder unit) defines the motor displacement. The electronic gear ratio is used to indicate the relationship between input position reference and motor position reference. By dividing (electronic gear ratio < 1) or multiplying (electronic gear ratio > 1) the electronic gear ratio, the actual motor rotating or moving displacement within the input
132
133 position reference of one reference unit could be set.
134
135 **[Setting range of electronic gear ratio]**
136
137 The setting range of the electronic gear ratio should** **meet **the following conditions**:
138
139 [[image:6.1Position Control Mode_html_2c181c45c26d57f7.jpg||height="43" width="341"]]
140
141 Otherwise, it would display [Er. 35] "Electronic gear ratio setting over limit" fault.
142
143 **Electronic gear ratio setting Flowchart:**
144
145 [[image:6.1Position Control Mode_html_ad9e5ff442164b5d.jpg||height="859" width="301"]]
146
147 Figure 6-4 Electronic gear ratio setting flowchart
148
149 Firstly, confirm the mechanical parameters, including confirming the reduction ratio, ball screw lead, gear diameter in gear transmission, pulley diameter in pulley transmission, etc. Confirm the resolution of the servo motor encoder used.
150
151 Confirm the parameters such as machine specifications and positioning accuracy, and determine the load displacement corresponding to the position command output by the host computer. Combine information including the mechanical parameters and the load displacement corresponding to one position command to calculate the position command value required for one rotation of the load shaft.
152
153 Electronic gear ratio = encoder resolution / position command (command unit) required for one revolution of the load shaft × reduction ratio, Set the function code parameters according to the calculated electronic gear ratio value.
154
155 In addition to use the electronic gear ratio function, you could also use [P0-16] (the number of command pulses for one rotation of the motor). Both gear ratio 1 and electronic gear ratio 2 are invalid when [P0-16] is not zero.
156
157 **Relevant function codes:**
158
159 |=(% style="width: 63px;" %)**Code**|=(% style="width: 190px;" %)**Parameter Name**|=**Property**|=(((
160 **Effective**
161
162 **Time**
163 )))|=**Range**|=**Function**|=**Unit**|=**Default**
164 |(% style="width:63px" %)P0-16|(% style="width:190px" %)pulse number per revolution|At stop|(((
165 Power-on
166
167 again
168 )))|0~~10000|(((
169 Set the pulse number of per rotation
170
171 Only when P0-16=0 then P0-17,P0-18,P0-19,P0-20 would take effect
172 )))|pulse|10000
173 |(% style="width:63px" %)P0-17|(% style="width:190px" %)Electronic gear 1 numerator|During running|Immediate|1~~32767|(((
174 Set the numerator of the first group electronic gear ratio.
175
176 It is valid when P0-16=0
177 )))|-|1
178 |(% style="width:63px" %)P0-18|(% style="width:190px" %)Electronic gear 1 denominator|During running|Immediate|1~~32767|(((
179 Set the denominator of the first group electronic gear ratio.
180
181 It is valid when P0-16=0
182 )))|-|1
183 |(% style="width:63px" %)P0-19|(% style="width:190px" %)Electronic gear 2 numerator|During running|Immediate|1~~32767|(((
184 Set the numerator of the first group electronic gear ratio.
185
186 It is valid when P0-16=0
187 )))|-|1
188 |(% style="width:63px" %)P0-20|(% style="width:190px" %)Electronic gear 2 denominator|During running|Immediate|1~~32767|(((
189 Set the denominator of the first group electronic gear ratio.
190
191 It is valid when P0-16=0
192 )))|-|1
193
194 = Position Reference Filter =
195
196 This function filters the position references (encoder unit) divided or multiplied by the electronic gear ratio. It involves the first-order filter and average filter.
197
198 **It is applicable to the following conditions:**
199
200 1. Acceleration/Deceleration is absent on the position references from the host controller.
201 1. The pulse frequency is too low.
202 1. The electronic gear ratio is larger than 10.
203
204 Properly setting the position loop filter time constant could run the motor more smoothly, so that the motor speed would not overshoot before it stabilizes. This setting has no effect on the number of command pulses.
205
206 The filter time is not as long as possible. The longer the filter time, the longer the delay time and the longer the response time.
207
208 [[image:6.1Position Control Mode_html_c13c256a6e790c7f.jpg||height="262" width="602"]]
209
210 Figure 6-5 position reference filter
211
212 **Relevant parameters:**
213
214 |=**Code**|=**Parameter Name**|=**Property**|=(((
215 **Effective**
216
217 **Time**
218 )))|=**Range**|=**Function**|=**Unit**|=**Default**
219 |P4-1|Pulse command filtering mode|At stop|Immediate|0~~1|(((
220 0:first-order low-pass filtering
221
222 1: average filter
223 )))|-|0
224 |P4-2|Position command first-order low-pass filter|At stop|Immediate|0~~128|For pulse command input filtering|ms|0
225 |P4-3|Position command average filtering time constant|At stop|Immediate|0~~1000|For pulse command input filtering|ms|20
226
227 = Position Deviation Clear =
228
229 Position deviation = Position reference – Position feedback (encoder unit)
230
231 The position deviation clear function refers to the function that the drive clears the deviation register in the position mode. The function of clearing position deviation could be realized through DI terminal.
232
233 = Frequency-Division Output =
234
235 The encoder pulse is output as a quadrature differential signal after divided by the internal circuit of the servo driver. The phase and frequency of the frequency-divided signal could be set by parameters. The source of frequency division output could be set by function code, and the setting of different sources makes the function of frequency division output more widely used.
236
237 [[image:6.1Position Control Mode_html_aff13745232892c.jpg||height="259" width="336"]]
238
239 Figure 6-6 diagram of frequency division output wiring
240
241 **The frequency-division output is a differential signal output:**
242
243 **Phase A pulse: **PAO +, PAO-, differential output, the maximum output pulse frequency is 2Mpps
244
245 **Phase B pulse: **PBO +, PBO-, differential output, the maximum output pulse frequency is 2Mpps
246
247 **Phase Z pulse:** PZO +, PZO-, differential output, the maximum output pulse frequency is 2Mpps
248
249 The frequency division pulse output direction could be set through the function code [P0-21]. The waveform diagram of the encoder frequency division pulse output is** as follows:**
250
251 |**P0-21**|**Forward rotation, pulse output waveform**|**Reverse rotation, pulse output waveform**
252 |0|[[image:6.1Position Control Mode_html_d66fab59025c842d.jpg||height="68" width="264"]]|[[image:6.1Position Control Mode_html_7f87ff6faaa689d0.jpg||height="64" width="246"]]
253 |1|[[image:6.1Position Control Mode_html_4303570ed8f08519.jpg||height="64" width="251"]]|[[image:6.1Position Control Mode_html_535a2e7e164c2b2f.jpg||height="64" width="246"]]
254
255 In addition, the Z pulse output polarity could be set through function code P0-23, as shown in **the** **following figure:**
256
257 |**P0-23(Z pulse output polarity)**|**pulse waveform (forward / reverse)**
258 |0|[[image:6.1Position Control Mode_html_99fac56ab3d3e115.jpg||height="49" width="250"]]
259 |1|[[image:6.1Position Control Mode_html_893cb0bf9e405027.jpg||height="50" width="252"]]
260
261 Function code P0-22(the number of output pulses per revolution of the motor) is used to set the number of output pulses of the A and B phases of the motor, and changing the function code could set the frequency division of the output.
262
263 **Relevant parameters:**
264
265 |=(% style="width: 69px;" %)**Code**|=(% style="width: 170px;" %)**Parameter Name**|=**Property**|=(((
266 **Effective**
267
268 **Time**
269 )))|=**Range**|=**Function**|=**Unit**|=**Default**
270 |(% style="width:69px" %)P0-21|(% style="width:170px" %)frequency-dividing output direction|At stop|(((
271 Power-on
272
273 again
274 )))|0~~1|(((
275 Quadrature pulse output.
276
277 0: When the motor rotation direction is CW, A advances B
278
279 1: When the motor rotation direction is CCW, B advances A
280 )))|-|0
281 |(% style="width:69px" %)P0-22|(% style="width:170px" %)Encoder ppr|At stop|Power-on|10~~10000|Quadrature output. Set the number of output pulses of phase A and phase B for each rotation of the motor|Pulse|2500
282 |(% style="width:69px" %)P0-23|(% style="width:170px" %)(((
283 Z pulse output
284
285 OZ polarity
286 )))|At stop|again|0~~1|(((
287 0-Z Active when pulse is high
288
289 1-Z Active when pulse is low
290 )))|-|0
291
292 = Position-relevant DO output function =
293
294 The feedback value of the position command is compared with different thresholds, and the DO signal could be output for the host controller to use.
295
296 (1)Positioning completed/near output
297
298 The internal command completion function means that when the multi position reference within the servo is zero, it could be considered that the command transmission is completed. At this time, the servo drive could output the internal command completion signal, and the host computer could confirm that the multi-segment position command within the servo drive has been sent.
299
300 The positioning completion function means that the position deviation meets the conditions set by the [P5-12], and it could be considered that the positioning is completed in the position control mode. At this time, the servo driver could output the positioning completion signal, and the host controller could confirm that the positioning of the servo driver is completed after receiving this signal.
301
302 **The functional schematic diagram is as follows:**
303
304 [[image:6.1Position Control Mode_html_d9b34f7fe3d81eaa.jpg||height="308" width="470"]]
305
306 Figure 6-7 positioning completed diagram
307
308 When using the positioning completion / proximity function, you could also set positioning completion, positioning proximity conditions, window, and hold time. The diagram of window filtering time is shown in** the figure below:**
309
310 [[image:6.1Position Control Mode_html_db565056f6f34cb6.jpg||height="314" width="549"]]
311
312 Figure 6-8 diagram of positioning completion signal output with window filtering time
313
314 **Relevant parameters:**
315
316 (% style="width:1075px" %)
317 |=(% style="width: 67px;" %)**Code**|=(% style="width: 119px;" %)**Parameter Name**|=**Property**(((
318 **Effective**
319
320 **Time**
321 )))|=**Range**|= **Function**|=**Function**|=(% style="width: 66px;" %)**Unit**|=(% style="width: 66px;" %)**Default**
322 |(% style="width:67px" %)P5-11|(% style="width:119px" %)Positioning completed, positioning near setting|During running|Immediate|1~~3|(((
323 Output signal judging conditions for positioning completed and positioning near
324
325 0:The output is valid when the absolute value of the position deviation is less than the positioning completion threshold / location near threshold.
326
327 1:The absolute value of the position deviation is less than the positioning completion threshold / positioning near threshold, and the input position command is 0 then the output is valid
328
329 2:The absolute value of the position deviation is smaller than the positioning completion threshold / positioning approach threshold, and the input position command filter value is 0 then the output is valid
330
331 3:The absolute value of the position deviation is less than the positioning completion threshold / positioning approach threshold, the input position command filter value is 0, and the positioning detection time window is continued then the output is valid
332 )))|(% style="width:66px" %)-|(% style="width:54px" %)0
333 |(% style="width:67px" %)P5-12|(% style="width:119px" %)Positioning completed threshold|During running|Immediate|1~~65535|Positioning completion threshold|(% style="width:66px" %)Pulse|(% style="width:54px" %)800
334 |(% style="width:67px" %)P5-13|(% style="width:119px" %)Positioning approach threshold|During running|Immediate|1~~65535|Positioning near threshold|(% style="width:66px" %)Pulse|(% style="width:54px" %)5000
335 |(% style="width:67px" %)P5-14|(% style="width:119px" %)Positioning detection time window|During running|Immediate|0~~20000|Set the positioning completion detection time window|(% style="width:66px" %)ms|(% style="width:54px" %)10
336 |(% style="width:67px" %)P5-15|(% style="width:119px" %)Positioning signal hold time|During running|Immediate|0~~20000|Set the hold time of positioning completion output|(% style="width:66px" %)ms|(% style="width:54px" %)100
337
338 To use the positioning completion function, the DO terminal of the servo drive should be assigned as the positioning completion function and determine the valid logic. Take the DO1 terminal as an example, **the relevant function code:**
339
340 |=**Code**|=**Parameter Name**|=**Property**|=(((
341 **Effective**
342
343 **Time**
344 )))|=**Range**|=**Function**|=**Unit**|=**Default**
345 |P6-26|DO_1 function selection|During running|(((
346 Power-on
347
348 again
349 )))|128~~142|(((
350 129-RDY Servo Ready
351
352 130-ALM Alarm
353
354 131-WARN Warning
355
356 132-TGON Motor rotation output
357
358 133-ZSP Zero speed signal
359
360 134-P-COIN Positioning completed
361
362 135-P-NEAR Positioning near
363
364 136-V-COIN Speed consistent
365
366 137-V-NEAR Speed near
367
368 138-T-COIN Torque reached
369
370 139-T-LIMIT Torque limit
371
372 140-V-LIMIT Speed limit
373
374 141-BRK-OFF Solenoid brake
375
376 (not implemented yet)
377
378 142-SRV-ST Enable Servo status output
379 )))|-|131
380 |P6-27|DO_1 logic selection|During running|(((
381 Power-on
382
383 again
384 )))|0~~1|(((
385 Output logic function selection. ★
386
387 ~1. Set to 0:
388
389 When the signal is valid, the output transistor is on.
390
391 When the signal is invalid, the output transistor is off.
392
393 2. Set to 1:
394
395 When the signal is valid, the output transistor is off.
396
397 When the signal is invalid, the output transistor is on.
398 )))|-|0
399
400 ----
401
402 = [[**Servo position control case**>>doc:Servo.3\. Demos.01 VD1/VD2 Servo Position control.WebHome]] =
403
404 (% class="wikigeneratedid" id="HIntroduction" %)
405 **Introduction**
406
407 This case uses three commonly used PLC positioning instructions to implement the servo position control mode actions.
408
409 = I/O wiring =
410
411 [[image:1611563158799-293.png]]
412
413 == **Servo parameter setting** ==
414
415 **Step 1**:Power on the servo, set the M key on the panel of the servo drive, set the value of function code P0-1 to 1, and 1 is the position control mode;
416
417 |=**Code**|=**Parameter Name**|=**Property**|=(((
418 **Effective**
419
420 **Time**
421 )))|=**Range**|=**Function**|=**Unit**|=**Default**
422 |P0-1|Control mode (default setting)|At stop|Power-on again|1~~10|(((
423 1: Position control mode
424
425 2: Speed control mode
426
427 3: Torque control mode
428 )))|-|1
429
430 **Step 2**:Set the value of function code P0-4, 0 is forward rotation, 1 is reverse rotation
431
432 |=**Code**|=**Parameter Name**|=**Property**|=(((
433 **Effective**
434
435 **Time**
436 )))|=**Range**|=**Function**|=**Unit**|=**Default**
437 |P0-4|(((
438 Rotating
439
440 direction
441
442 selection
443 )))|At stop|(((
444 Power-on
445
446 again
447 )))|0~~1|(((
448 Forward direction:viewed from the motor shaft.
449
450 0: CW direction as the forward direction
451
452 1: CCW direction as the
453
454 forward direction
455 )))|-|0
456
457 **Step 3**:Set the value of function code P6-04 to 1. 0 is the hardware DI_1 channel, which requires wiring; 1 is the virtual DI_1 channel,no wiring is required.
458
459 |=**Code**|=**Function**|=**Effective time**|=**Default**|=**Range**|=**Description**
460 |P13-1|Virtual VDI_1 input value|▲|0|0-1|(((
461 VDI1 input level:
462
463 0: low level. 1: high level.
464 )))
465
466 **Step 4**:Set the value of the function code P13-1 to choose whether VDI1 is valid at high or low levels.
467
468 **Notes**:the value of function code P6-02 should be set to 1. Only in this way can the motor rotate.
469
470 |=**Code**|=**Function**|=**Effective time**|=**Default**|=**Range**|=**Description**|=**Unit**
471 |P6-02|DI_1 function selection|△|1|0-16|(((
472 1: SON, Servo ON
473
474 2: A-CLR, Fault and warning clear
475
476 3: POT, Forward limit switch
477
478 4: NOT, Reverse limit switch
479
480 5: ZCLAMP, Zero speed clamp
481
482 6: CL, Clear the position deviation
483
484 7: C-SIGN, Instruction negation
485
486 8: E-STOP, Emergency stop
487
488 9: GEAR-SEL, Electronic gear switching 1
489
490 10: GAIN-SEL, Gain switch
491
492 11: INH, Position reference inhibited
493
494 12: VSSEL, Damer control switch(not implemented yet)
495
496 13: INSPD1, Internal speed command selection 1(not implemented yet)
497
498 14: INSPD2, Internal speed command selection 2(not implemented yet)
499
500 15: INSPD3, Internal speed command selection 3(not implemented yet)
501
502 16: J-SEL, Inertia ratio switch(not implemented yet)
503 )))|
504
505 = **PLC Project** =
506
507 [[image:1611563183076-132.png]]
508
509 = **Explanation** =
510
511 The program uses M0,M1,M2 as the switch button of three modes of actions.
512
513 When M0 is turned on, the Y0 servo motor rotates 5000 pulses in the direction of Y3.
514
515 When M1 is turned on, the Y0 servo motor rotates 20,000 pulses at the speed of 4,000 pulses, and Y3 represents the direction of the motor.
516
517 When M2 is turned on, the Y0 servo motor moves to the absolute position of 2000 at the speed of 4000 pulses, and Y3 represents the direction of the motor.