Moog Animatics SmartMotor™ Developer's Guide,Rev. L
Page 837 of 909
MFD(af[3],1)
af[5]=3750.0/ttt*af[4]
IF af[5]>=32768.0
'error, too high for MFMUL
RETURN
ENDIF
MFMUL=af[5]
MFDIV=1000
MFSDC(-1,0) ' No repeat.
IF rrr>32767
MCMUL=32767
MCDIV=1073676289.0/rrr
ELSE
MCMUL=rrr
MCDIV=32767
ENDIF
G
RETURN
C1 ' Write the cam
IF q==123 RETURN ENDIF
' This writes the sine into EE memory.
' Normalized table that will be scaled in frequency and amplitude later.
' Table is +/-32767 in amplitude.
PRINT("Writing Tables. Please wait.",#13)
CTE(1) ' erase all flash tables.
CTA(361,80) ' Table will have 361 points, each is 80 ticks.
' (fixed length data)
iii=0
WHILE iii<361
ppp=32767*SIN(iii)
CTW(ppp) ' Write a point into table.
' Length of segment set by CTA command.
'PRINT("Point: ",iii,", position: ",ppp,#13)
iii=iii+1 ' Update counter.
LOOP
PRINT("Done. Motor: ",ADDR,#13)
q=123
RETURN
CAUTION: When writing a cam table to EEPROM, structure the program so
that the cam table is not frequently rewritten or written from a loop. Repeated
erasing and rewriting can burn bits and corrupt data. For details and sample
code, refer to Electronic Camming Notes and Best Practices on page 159.
Camming - Demo XYCircle