;MDrv0  SPice10213 dynamic braking example

;This program simply illustrates dynamic braking of a small DC motor using the SPice10213
;on an MS12. It has a stop/start button. The motor is driven in simple on/off mode 
;(no speed control) off the motor A output.

iStopStart	iEQU		16		;The Stop/Start button

oDirection	oEQU		12		;The direction relay
oMotor		oEQU		16		;The on/off output

;------ 
;Start of program
		setu		0,1		;set spice connector pin 4 as DO
		setu		4,1		;set spice connector pin 8 as DO
		SpiceConfigU


Idle:			;Back here when motor is stopped
		WaitOnK		iStopStart	;Wait for start command
		On		oMotor		;Run the motor
Running:
		WaitOnK		iStopStart	;Wait for stop command
Stop:
		Off		oMotor		;Turn off the motor

;Comment out the following line to see the effect of not using dynamic braking
		ON		oDirection	;Apply the brake

		Pause		50		;Allow motor time to stop
		Off		oDirection	;Turn off the brake
		GoTo		Idle		
		