Program Examples:force sensor

From SoftMC-Wiki
Jump to: navigation, search
Language: English

Here is an example of using force sensor with/without filter

'------------------------------------------------------------------------------
' File:        ForceSns.prg
' Purpose:     setup of force sensor filter: Ecat and frequency
' Version:     1.00
' Author:      Eran Korkidi
' History:     2017-AUG-30,	Created
'------------------------------------------------------------------------------
IMPORT_C RBT_GET_OPTOFORCE_DATA(byval as long, byval as long, as generic location) as long
IMPORT_C RBT_SET_FORCE_SENSOR_FILTER(byval as long, byval as long, byval as long) as long
IMPORT_C RBT_SET_FORCE_SENSOR_TYPE(byval as long, byval as long, byval as long) as long
IMPORT_C RBT_SET_FORCE_SENSOR_PDO_INDEX(byval as long, byval as long) as long
IMPORT_C RBT_SET_FORCE_SENSOR_DADD(byval as long, byval as long) as long

common shared locData as generic location
common shared locFilter as generic location

program continue

dim i as long

locData = TP_gGroup.here*0
locFilter = TP_gGroup.here*0

Attach TP_gGroup
	? RBT_SET_FORCE_SENSOR_PDO_INDEX(65, 0x6000)
	? RBT_SET_FORCE_SENSOR_DADD(65, 2)
	? RBT_SET_FORCE_SENSOR_TYPE(65, 1, 0)
	? RBT_SET_FORCE_SENSOR_filter(65, 1, 4)
	for i = 1 to 10000
		Sleep 4
		? RBT_GET_OPTOFORCE_DATA(65,1,locFilter)
		? RBT_GET_OPTOFORCE_DATA(65,0,locData)
	next
Detach TP_gGroup


terminate program ' <MyTask>.prg