User's Manual

PMAC User Manual
114 Closing the Servo Loop
; period factor and its counter should be
; initialized in L:SAMP_A. Notice the sampling
; period counter always should be less than the
; sampling period factor. The content of the
; sampling period factor cell represents an integer
; multiple of the hardware selected PMAC servo
; sampling period. In this way the sampling frequency
; may be reduced from the the PMAC default value.
;
OLD_UF_A EQU $0770 ;Old UVAL after filter.
COEF_A EQU $07F0 ;Filter coef. a1 (x mem.), a2 (y mem).
SAMP_A EQU $07F1 ;Sampling period factor (y mem.) &
;counter (x mem.).
DEMAND_A EQU $07F2 ;Address for the temp. storage of
;demand value.
ACTUAL_A EQU $07F3 ;Address for the temp. storage of
;actual value.
DAC_A EQU $07F4 ;Address for dac value.
ORG P:$B800
CLR B B10,L:DEMAND_A ;Save the demand in memory.
MOVE #1,B1 ;B1=1.
MOVE X:SAMP_A,A ;A1=counter.
ADD B,A Y:SAMP_A,Y0 ;Counter=counter+1, Y0=samp. factor.
SUB Y0,A A1,X:SAMP_A ;Compare counter with factor & save
;count.
JMI ESERVO ;Skip if counter < samp. factor.
MOVE A1,X:SAMP_A ;Clear and save the counter.
MOVE Y:DEMAND_A,B ;Load demand position (assuming 24- bit)
MOVE X1,A ;Load Actual position (assuming 24- bit)
SUB A,B ;Form the 24-bit error(k)
;Now execute the low pass filter and exit
;with value of DAC in the upper 18 bits
;of A1 (integer).
;
RND B X:COEF_A,X1 ;Round B adding 1 to bit 23 (of B0).
MOVE X:OLD_UF_A,X0 B,Y1 ;X0=uf(k-1), Y1=error(k), X1=a1.
MPY X1,Y1,B Y:COEF_A,Y0 ;B=a1*error(k), Y0=a2.
MACR X0,Y0,B ;B=a1*error(k)+a2*uf(k-1).
MOVE B,X:OLD_UF_A ;Save uf(k)
ESERVO
MOVE X:OLD_UF_A,A ;LOAD SAVED DAC VALUE
MOVE A0,A1
REP #6
ASL A
JMP <$23 ;RETURN TO SERVO
END
C Program to Convert .LOD File to PMAC Format
/* .LOD TO .PMC CONVERSION PROGRAM 09/04/90 V1.0 */
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
FILE *infile,*outfile;
Char buf[81],bufr[32768];
Int l,m,n,x,y;
void main (argc,argv)