# Change XYZ to the UID of your Performance DC Bricklet

setup:
	publish '{"mode": "drive_coast"}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_drive_mode

	publish '{"frequency": 10000}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_pwm_frequency # Use PWM frequency of 10 kHz

	publish '{"acceleration": 4096, "deceleration": 4096}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_motion # Slow ac-/deceleration (12.5 %/s)

	publish '{"velocity": 32767}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_velocity # Full speed forward (100 %)

	publish '{"enabled": true}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_enabled # Enable motor power

cleanup:
	# If you are done, run this to clean up
	# Stop motor before disabling motor power
	publish '{"acceleration": 4096, "deceleration": 16384}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_motion # Fast decceleration (50 %/s) for stopping

	publish '{"velocity": 0}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_velocity # Request motor stop

	wait for 2s # Wait for motor to actually stop: velocity (100 %) / decceleration (50 %/s) = 2 s

	publish '{"enabled": false}' to tinkerforge/request/performance_dc_bricklet/XYZ/set_enabled # Disable motor power
