
;This is velocity tuning program. A3 input should be activated 
;before running this program.
;
;Please Edit SpeedReference constant if you need other speed tuning reference
;Reference is set in RPS. 
;This program disables accel/decel for velocity mode.
;With default refrence value of 5 Rps please set oscilloscope tool to following:
;<<<<<<Channel 1>>>>>> 
;Signal 	Motor Velocity
;Scale		100 Rpm/div
;Offset		0
;Time base	50 ms/div
;Trigger	Ch1 rising edge
;Level		100 Rpm
;<<<<<<Channel 2>>>>>>
;
;Signal 	Iq current
;
;Scale		Choose scales appropriate for your motor	

;*************************************************************************
;    Motion Parameters
DEFINE SpeedReference  5    ;speed reference in Rps               
DEFINE Period 500


;*************************************************************************
UNITS =1		;set user units to revolutions
;--------------------------------------------------------------------------------------------

	VAR_REFERENCE = 1			 ;select trajectory generator as positioning source
	VAR_DRIVEMODE = 1	 		;velocity mode
	VAR_ENABLE_SWITCH_TYPE=0  	;enable switch function set to "Enable only"
	VAR_ENABLE_ACCELDECEL =0		 ;disable accel/decel for velocity mode
;--------------------------------------------------------------------------------------------

WAITENABLE:
	WAIT   UNTIL IN_A3 	;wait until A3 - hardware "enable" closed

	ENABLE			;enable drive
		
	V0=0
	OUT1 = 0;              			 ;clear "fault" output
Again:	
	VAR_IREF  = SpeedReference	;
	WAIT TIME Period/2 		;
	VAR_IREF = -SpeedReference 	;
	WAIT TIME Period/2		;
	GOTO Again				;execute motions in the loop 	
;
	END					;shouldn't get here anyway

;---------------------------------------------------------------------------
;In case if fult happens... it gets here!
;---------------------------------------------------------------------------
PROCESSFAULT:
;Do your fault processing here
	
	V0=1;			;do this so you can see that it was a fault
	OUT1 =1;		;indicate fault on output too
	GOTO WAITENABLE		;continue program
				
;***************************************************************************
;
ON FAULT

	RESUME PROCESSFAULT
ENDFAULT

 
