Contact Approach with PSPD Align

PowerScript
main 0 files
Contact Approach with …..js
Contact Approach with …..js 1353 bytes
print('Approach Started')

spm.addChannel('a-b')

//Backup original setting values
sp_0 = spm.zservo.setpoint.normValue
zGain_0 = spm.zservo.gain

//Changing values for approach
zGain_Appr = {
	'z+': 5.0,
	'useZNeg': false
}

spm.zservo.setpoint.normValue = 1.0
spm.zservo.gain = zGain_Appr

//Approach Start
isTipSampleContact = false
iteration = 0

while(isTipSampleContact == false){
	spm.zservo.enable = true
	spm.sleep(1000)
	zscan_0 = spm.zscanner.pos
	ab_0 = spm.readChannelAveraged('a-b', 10, 10)

	spm.approach.start('quick')
	spm.sleep(1000)

	zscan_1 = spm.zscanner.pos
	ab_1 = spm.readChannelAveraged('a-b', 10, 10)

	ab_diff = ab_1 - ab_0
	zscan_diff = zscan_1 - zscan_0

	if((ab_diff > 0.8) && (zscan_diff > 0)){
		isTipSampleContact = true
		z = spm.zstage.pos
		spm.zstage.move(10)
		spm.sleep(500)
		spm.approach.start('incremental')

		print('Approach Done')
		print('ab_0, ab_1, zscan_1, Z')
		print(ab_0 + ',' + ab_1 + ',' + zscan_1 + ',' + z)
	} else {
		if(iteration > 10) { break }

		if(Math.abs(ab_diff) > 0.3) {
			z = spm.zstage.pos
			spm.fx.analyzer.alignPspd()
			print('PSPD Realigned')
			spm.sleep(3000)
			print('ab_0, ab_1, zscan_1, Z')
			print(ab_0 + ',' + ab_1 + ',' + zscan_1 + ',' + z)
		} else {
			print('PSPD Align Skipped')
		}

		iteration++
	}
}
Comments (0)

No comments yet. Be the first to comment!

Snippet Information
Author: daeyeon.won
Language: PowerScript
Created: Oct 23, 2025
Updated: 0 minutes ago
Views: 25
Stars: 2