'!TITLE "DENSO Robot Program"

#Include "CONTEC_Motion.pcs"

Sub Main
	Wait IO[128] = On
	
	'CONTEC Motion Initialization
	MotionInitialize

	'CONTEC Motion axis speed setting
	smcSetMvStSpd "SIGMA_5", 1, 100000                                                      'Starting speed [PPS]
	smcSetMvTgSpd "SIGMA_5", 1, 500000                                                      'Target speed [PPS]
	smcSetMvAccTm "SIGMA_5", 1, 100                                                         'Acceleration time [ms]
	smcSetMvDecTm "SIGMA_5", 1, 100                                                         'Deceleration time [ms]
	
	'Servo ON
	smcOut1_On "SIGMA_5", 1
	
	'Relative movement  CW
	smcMvPtoP "SIGMA_5", 1, 1, 262140
	
		'Wait until stop
		Wait smcGetStsMov("SIGMA_5", 1) = 0
	
	'Relative movement  CCW
	smcMvPtoP "SIGMA_5", 1, 1, - 262140
	
		'Wait until stop
		Wait smcGetStsMov("SIGMA_5", 1) = 0

	
End Sub

'-------------------------------------------------------------------------------------------------
'	Initialization
'-------------------------------------------------------------------------------------------------
Sub MotionInitialize
	'CONTEC Motion AddAddController
	CONTEC_Motion "SIGMA_5", "CaoProv.CONTEC.SMC", "", "DeviceName=SMC000,@Ifnotmember=True"
	
	'CONTEC Motion 1 axis pulse output initialization
	smcSetIniPis "SIGMA_5", 1, 4, 1, 0
	
	'CONTEC Motion 1 axis counter movement settings
	smcSetIniCnt "SIGMA_5", 1, 0, 0, 0
	
	'CONTEC Motion 1 axis control I/O settings
	smcSetIniDio "SIGMA_5", 1, 1, 0, 0, 0, 0
	
	'CONTEC Motion 1 axis encoder settings
	smcSetIniEnc "SIGMA_5", 1, 1, 0, 0, 0, 0
	
	'CONTEC Motion 1 axis origin settings
	smcSetIniOrg "SIGMA_5", 1, 1, 1, 0, 0, 1
	
	'CONTEC Motion 1 axis speed resolution settings
	smcSetReSpd "SIGMA_5", 1, 10
	
	'CONTEC Motion 1 axis other initial settings
	smcSetIniExt "SIGMA_5", 1, 0, 0, 0
End Sub
