Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

Motion Control Position Synchronous Output (2) | PSO 2D & 3D Modes

Let's continue,  PSO 2D and 3D modes and HW_TIMER.

There are several PSO modes for motion controller, we can select suitable trigger mode modes to meet requirements for actual applications.

Here, it introduces PSO 2D and 3D modes one by one (mode 25, mode 26, mode 35, mode 36) in details. In last part, mode 1-7 are describled.

PSO position synchronous output function is used to control high-speed switch on / off of laser or dispensing valve , then use linear interpolation and plane circular interpolation function to complete processing trajectory. In addition, the continuous interpolation function is used to make multiple interpolation speed continuous to promote production efficiency.

Let's begin.



2D

Mode=25,26: 2D comparison

2D comparison : save one XY coordinates for every two continuous table positions, that is, multi-point can be achieved, and output state of each comparison is inverted.

Note: mode 25 is similar with mode 35 , mode 26 is similar with mode 36 , they all need to be used together with HW_TIMER.

A. HW_PSWITCH2(25, opnum, opstate, maxerr, num, tablepos)

mode: 25, 2D comparison mode

opnum: relevant outputs

opstate: output status of the first comparison position

maxerr: pulse deviation between left and right of each axis, it starts to compare when it enters the deviation range, please note the parameter can't be 0.

num: the number of comparison position coordinates saved into TABLE.

tablepos: table No. where the first comparison point coordinate is.

Please refer to below, blue segment means OP is on.

All kinds of interpolation motions can use this mode to compare, but the comparison coordinates must be correct, otherwise behind points will be influenced.

12.png

Example:

TABLE(0, 0 0 50 50 100 100 50 150 0 200 -50 150 -100 100 -50 50) : 8 comparison coordinates, occupy 16 TABLE.

HW_PSWITCH2 (25, 0, 1, 10, 8, 0) : mode 25, OUT0, the first comparison outputs ON, pulse deviation is 10, 8 coordinates, table address is 0-15 (2 continuous coordinates is one 2D coordinate).  

32.png

33.png

XYZ mode

   

B. HW_PSWITCH2(26, opnum, opstate, maxerr, num, tablepos, [ophwtimeus, ophwtimes, hwcyctimeus])

mode: 26, 2D comparison mode

opnum: relevant outputs

opstate: output status of the first comparison position

maxerr: pulse deviation between left and right of each axis, it starts to compare when it enters the deviation range, please note the parameter can't be 0.

num: the number of comparison position coordinates saved into TABLE.

tablepos: table No. where the first comparison point coordinate is.

[select one from below parameters and HW_TIMER, HW_TIMER can be edited independently to adjust parameters dynamically]

ophwtimeus: pulse time

ophwtimes: the number of pulses

hwcyctimeus: pulse period

This mode actually is similar with mode 7 . Comparison points are written into TABLE, two continuous TABLE data compose as one 2D coordinate, and also trigger OP when reached one comparison position, the OP reverse times of each comparison and reverse period are controlled by HW_TIMER. Then trigger OP again when reached next TABLE position.  

13.png

Example

TABLE(0,  0 0 50 50 100 100 50 150 0 200 -50 150 -100 100 -50 50) : 8 comparison coordinates, occupy 16 TABLE.

HW_PSWITCH2 (26, 0, 1, 10, 8, 0) : mode 26, OUT0, the first comparison outputs ON, pulse deviation is 10, 8 coordinates, table address is 0-15 (2 continuous coordinates is one 2D coordinate).

HW_TIMER(2, 100000, 50000, 2, OFF, 0) : the hardware timing period is 100000us, the pulse width is 50000us, output pulses twice of each comparison.

34.png

35.png

XYZ mode




3D

Mode=35, 36: 3D comparison

3D comparison : save one XYZ coordinates for every three continuous table positions, that is, multi-point can be achieved, and output state of each comparison is inverted.

Note: mode 25 is similar with mode 35, mode 26 is similar with mode 36, they all need to be used together with HW_TIMER.

A. HW_PSWITCH2(35, opnum, opstate, maxerr, num, tablepos)

mode: 35, 3D comparison mode

opnum: relevant outputs

opstate: output status of the first comparison position

maxerr: pulse deviation between left and right of each axis, it starts to compare when it enters the deviation range, please note the parameter can't be 0.

num: the number of comparison position coordinates saved into TABLE.

tablepos: table No. where the first comparison point coordinate is.

14.png

Example:

TABLE(0 20 20 20 40 40 40 70 70 70 100 100 100 140 140 140 180 180 180) : 6 comparison coordinates, occupy 18 TABLE.

HW_PSWITCH2(35, 0, 1, 10, 6, 0) : mode 35, OUT0, the first comparison outputs ON, pulse deviation is 10, 6 coordinates, table address is 0-18 (3 continuous coordinates is one 3D coordinate).

HW_TIMER(2, 100000, 50000, 1, OFF, 0) : the hardware timing period is 100000us, the pulse width is 50000us, output pulses once of each comparison.

36.png


B. HW_PSWITCH2(36, opnum, opstate, maxerr, num, tablepos, [ophwtimeus, ophwtimes, hwcyctimeus])

mode: 36, 3D comparison mode

opnum: relevant outputs

opstate: output status of the first comparison position

maxerr: pulse deviation between left and right of each axis, it starts to compare when it enters the deviation range, please note the parameter can't be 0.

num: the number of comparison position coordinates saved into TABLE.

tablepos: table No. where the first comparison point coordinate is.

[select one from below parameters and HW_TIMER, HW_TIMER can be edited independently to adjust parameters dynamically]

ophwtimeus: pulse time

ophwtimes: the number of pulses

hwcyctimeus: pulse period

This mode actually is also similar with mode 7. Comparison points are written into TABLE, three continuous TABLE data compose as one 3D coordinate, and also trigger OP when reached one comparison position, the OP reverse times of each comparison and reverse period are controlled by HW_TIMER. Then trigger OP again when reached next TABLE position.

15.png

Example:

TABLE(0 20 20 20 40 40 40 70 70 70 100 100 100 140 140 140 180 180 180) : 6 comparison coordinates, occupy 18 TABLE.

HW_PSWITCH2 (36, 0, 1, 10, 6, 0) : mode 36, OUT0, the first comparison outputs ON, pulse deviation is 10, 6 coordinates, table address is 0-18 (3 continuous coordinates is one 3D coordinate).

HW_TIMER(2, 100000, 50000, 1, OFF, 0) : the hardware timing period is 100000us, the pulse width is 50000us, output pulses once of each comparison.

37.png


For 2D and 3D modes, there is one parameter "maxerr" , let's see it clearly.

Under 2D mode, XY coordinates must be correct, because it can't trigger if axis moves to wrong TABLE. It is with same principle for 3D mode. Therefore, a special parameter maxerr is required, and it means the deviation of pulses, not of distance.

It is valid when the deviation value between actual position coordinate and TABLE comparison is in the range of maxerr. The comparison is triggered when current position enters comparison point trigger range. 

16.png





HW_TIMER: hardware timing

Hardware timer is used to restore electric level after one certain of hardware comparison output. There is only one HW_TIMER, so former calling will be stopped when HW_TIMER is called each time.

When it is not used or when comparison completes, use HW_TIMER(0, 10000, 6000, 1, OFF, 0) ".

HW_TIMER(mode, cyclonetime, optime, reptimes, opstate, opnum )

mode: 0-stop, 2-run

cyclonetime: cycle time, us is the unit

optime: valid time, us is the unit

reptimes: repeat times, start the mode, when reptimes=0, HW_TIMER will be softly closed, and uncompleted pulses will keep outputting.

opstate: output default status, start to do timing when output port is not current state

opnum: output No., the port must support hardware comparison output.

Please see following graphic, it outputs in cycle with fixed time, and each period's valid output time and repeat output times are set.

17.png

18.png

For the mode that is matched with "HW_TIMRE" together, the pulse output width is determined by "HW_TIMER".

It can be seen from the above form, there are absolute coordinates and vector coordinates, so the difference is ?

Absolute refers to the current position that related to origin coordinate.

Vector means the total distance from when axis backs to origin to current position, it only can be accumulative, so please manually clear it before using.

For example, after axis 0 returns to origin, it moves 200 forward, then moves 100 inversely, now the absolute coordinate is 100, but the vector coordinate is 300. If two-axis interpolation is executed, the vector coordinate should be composed trajectory vector of current interpolation, so the mode compared by vector supports multi-axis.

Please note when the axis is with an encoder, MPOS (measurement / feedback position) is compared automatically, when without the encoder, DPOS (demand / target position) is used.

Here, we have learned all modes, let me show you one example that includes all modes.

This example is operated in ZDevelop, and uses oscilloscope to observe PSO output.

Please see the codes:

RAPIDSTOP(2)

WAIT  IDLE(0)

WAIT  IDLE(1)

WAIT  IDLE(2)

 

'set basic axis parameters

BASE(0,1,2)      'select axis X Y

ATYPE=1,1,1      '1-pulse axis type, compare DPOS, 4-the axis type that is with encoder feedback, compare encoder measurement position MPOS

UNITS=100,100,100

SPEED=100,100,100

ACCEL=1000,1000,1000

DECEL=1000,1000,1000

MERGE=ON,ON,ON

SRAMP=50,50,50    'S curve speed smooths

OP(0,OFF)      'initialize to turn off the OUT that is used by PSO

VECTOR_MOVED = 0  'clear interpolation vector distance to 0

global g_cmd    'select comparison mode

g_cmd = 0

 

while 1        'test all comparison modes

  if g_cmd =  1 THEN

     g_cmd = 0

     Clean_Pos()    'clear position

     Test_Mode1()    'call comparison  

  elseif g_cmd =  3 THEN

     g_cmd = 0

     Clean_Pos()

     Test_Mode3()

  elseif g_cmd =  4 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode4()  

  elseif g_cmd =  5 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode5()

  elseif g_cmd =  6 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode6()

  elseif g_cmd =  7 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode7()  

  elseif g_cmd =  25 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode25()

  elseif g_cmd =  26 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode26()

  elseif g_cmd =  35 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode35()

  elseif g_cmd =  36 THEN  

     g_cmd = 0

     Clean_Pos()

     Test_Mode36()

  endif

wend

 

GLOBAL SUB Clean_Pos()

  RAPIDSTOP(2)  'axis stops

  WAIT  IDLE(0)

  WAIT  IDLE(1)

  WAIT  IDLE(2)  

  DPOS=0,0,0    'set the current position to 0

  MPOS=0,0,0

  OP(0,OFF)    'close the output

END SUB

 

GLOBAL SUB Test_Mode1()

  TABLE(0,100,150,250,300,400,450)  

  BASE(0)

  'hw_pswitch2 has own buffer, and remain buffer size of current axis can be checked through ?hw_pswitch2(n)

  HW_PSWITCH2(2)  'stop and delete the comparison positions that are not finished.

  HW_PSWITCH2(1, 0, 1, 0, 5,1)   'open comparison output, mode 1, OUT0, the first comparison point outputs ON, table address is 0-2, and compare in positive direction

  TRIGGER          'trigger the oscilloscope

  MOVE(500)

END SUB

 

GLOBAL SUB Test_Mode3()

 TABLE(0,100,150,250,300,400,450)  

  HW_TIMER(0, 10000, 6000, 1, OFF, 0)

  BASE(0)

  VECTOR_MOVED(0) = 0    'set the current vector position

  HW_PSWITCH2(2)        'stop and delete the comparison positions that are not finished.

  'no need to consider one single motor direction for vector changeing, vector always increses.

  HW_PSWITCH2(3, 0, 1, 0, 5) 'open comparison output, mode 3, OUT0, the first comparison point outputs ON, table address is 0-5 (vector coordinates)

  TRIGGER          'trigger the oscilloscope to capture waveform

  MOVEABS(300,200)

  MOVEABS(400,0)

END SUB

 

GLOBAL SUB Test_Mode4()  

  HW_TIMER(0, 10000, 6000, 1, OFF, 0)

  BASE(0)

  VECTOR_MOVED(0) = 0    'set the current vector position

  HW_PSWITCH2(2)        'stop and delete the comparison positions that are not finished.