Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 691 of 909
EXAMPLE:
a=SAMP 'Assign sample rate to variable a.
PRINT("The current sample rate is: ",a) 'Print info to terminal.
END
Program output is:
The current sample rate is: 8000
EXAMPLE: (Scale Factor Multipliers)
' SAMP: motor sample time in samples per second
' RES: encoder resolution in counts per rev
' 65536: internal fractional constant for motor unit calculations
' 60: conversion between seconds and minutes
' *1.0: way to typecast integer values out to full floating-point values
' af[2] thru af[7]: 32-bit, floating-point array variables
'These abbreviations are used in the following code:
' NatAD (Native Accel{decel})
' NatVel (Native Velocity)
' RPM (revolutions per minute)
' RPS (revolutions per second)
'Calculating multipliers 'Input Output
af[2]=(((SAMP*1.0)/RES)*60)/65536 'NatVel -> RPM Multiplier
af[3]=(((RES*1.0)/SAMP)/60)*65536 'RPM -> NatVel Multiplier
af[4]=((SAMP*1.0)/RES)/65536 'NatVel -> RPS Multiplier
af[5]=((RES*1.0)/SAMP)*65536 'RPS -> NatVel Multiplier
af[6]=af[5]/SAMP 'RPS^2 -> NatAD Multiplier
af[7]=af[4]*SAMP 'NatAD -> RPS^2 Multiplier
'Examples
'Suppose you wish to set a Velocity of 3000 RPM:
'(This method simply uses the above multiplier)
VT=3000*af[3] '3000 RPM desired speed multiplied by af[3]
'(RPM to Native Velocity multiplier)
'Suppose you wish to read real time velocity in units of RPS:
s=VA*af[5] 'Converts native VA (actual velocity) into RPS
'and assigns it to the variable "s"
END
RELATED COMMANDS:
R
FW Firmware Version (see page 454)
R
RES Resolution (see page 670)
Part 2: Commands: SAMP