Model Description Language Ver 1.0
Compiler details Sample model description source file. In Acrobat format
Analog Processing - basic Scheme :
Output from A/D 0<----------------------------------->1023
Offset -512<-----------------0----------------->511
Calibration (+Kcal) -512<-----------------Kcal-------------->511
Analog input data = an
Program processing -xl<-----------Kcal------------>xu
End point scaling -xl*Kl<-------------Kcal------->xh*Ku
.... reversing if required .... -xu*Ku<-------Kcal------------->xl*Kl
Centre offset (+Cof) -xl*Kl<------------Kcal+Cof------>xu*Ku
Clipping -512[[[-xl*Kl<---------Kcal+Cof---->xu*Ku]]]512
Offset <---------NPW-IPP----->
Channel output = ch
Legend : Ku upper endpoint 8 bit signed proportion
Kl lower endpoint 8 bit signed proportion
Cof centre offset 8 bit signed multiples of 4 us
Kcal Calibration offset 8 bit signed in us
NPW Neutral pulse width typically 1500us
IPP Inter-pulse pause typically 350us
Notes : 1 8 bit signed proportions ie. a factor of 0.5 would be 64
2 Final output is clipped to neutral pulse width +/- maximum pulse
deviation (nominally 1500us +511/-512us).
Instruction Set for Model Type Processing :
Instruction Function Function Op Code
Mnemonic Name Operation (hex)
RET Return return from processing 0x00
POP Pop stack X = Y, Y = Z, Z = T, T = T 0x01
PUSH Push stack T = Z, Z = Y, Y = X, X = X 0x02
EXCH Exchange X = Y, Y = X 0x03
CLR Clear X = 0 0x04
SETS Set stack to 511 X = Y = Z = T = 1FFh 0x05
CLRS Clear stack X = Y = Z = T = 0 0x06
RLD Roll down X = Y, Y = Z, Z = T, T = X 0x07
RLU Roll up T = Z, Z = Y, Y = X, X = T 0x08
SGE Skip on greater or equal if X >= Y, ++pc 0x09
SLT Skip on less than if X < Y, ++pc 0x0a
SEQ Skip on equal if X == Y, ++pc 0x0b
SKZ Skip on zero if X == 0, ++pc 0x0c
SKNZ Skip on nonzero if X <> 0, ++pc 0x0d
DSZ Decrement skip on zero if --X == 0, ++pc 0x0e
DSNZ Decrement skip on nonzero if --X <> 0, ++pc 0x0f
MUL Multiply Y *= X, POP 0x10
DIV Divide Y /= X, POP 0x11
ADD Add Y += X, POP 0x12
SUB Subtract Y -= X, POP 0x13
NEGX Negate X X = -X 0x14
NEGY Negate Y Y = -Y 0x15
NEGZ Negate Z Z = -Z 0x16
INC Increment X++ 0x17
DEC Decrement X-- 0x18
INCL Increment 16 X += 16 0x19
DECL Decrement 16 X -= 16 0x1a
OXU Offset X up by 511 X += 511 0x1b
OXD Offset X down by 512 X -= 512 0x1c
DBX Multiply by 2 X *= 2 0x1d
DVX Divide by 2 X /= 2 0x1e
LMX Load X with max value PUSH, X = 511 0x1f
SCZ Skip on counter zero if C == 0, ++pc 0x20
SCNZ Skip on counter nonzero if C <> 0, ++pc 0x21
RLDC Reload counter C = L 0x22
LDC Load counter L = X 0x23
CLC Clear counter C = 0 0x24
SAE Skip on analog error if err, ++pc 0x25
SPC Skip on parameter change if par[0..15] chg, ++pc 0x26
GTO dest Goto pc = dest 0x27
dest
LDX k11 Load constant PUSH, X = k11 0x28 | k11<10:8>
k11
STO reg Store reg = X 0x30 | reg
RCL reg Recall PUSH, X = reg 0x38 | reg
EXCM reg Exchange memory X = reg, reg = X 0x40 | reg
OUT ch Output ch = X (clip & scale) 0x48 | ch
EXON ech Extended channel on ech = ON 0x50 | ech
EXOF ech Extended channel off ech = OFF 0x58 | ech
SCL par Scale X *= par / 128 0x60 | par
SETX par Set X = par * 4 0x70 | par
MIX par Mix see notes below 0x80 | par
SADJ par Speed adjust see notes below 0x90 | par
SSS sw Skip on switch set if sw, ++pc 0xa0 | sw
SSC sw Skip on switch clear if !sw, ++pc 0xb0 | sw
TRIM an Trim X += an 0xc0 | an
IN an Input analog PUSH, X = an 0xd0 | an
JMP dist Jump pc += dist 0xe0 | dist
Legend : reg 16 bit non-volatile general purpose register, 3 bit address
sw switch 4 bit address
dist 5 bit signed program counter offset (+15/-16)
pc 8 bit program counter
dest 8 bit destination
k11 11 bit signed constant (+1023/-1024)
par 8 bit signed parameter (+127/-128), 4 bit address
ch 16 bit output channel, 3 bit address
ech extended output channel, 3 bit address
an 16 bit analog input, 4 bit address
Resources : Stack X, Y, Z, T 16 bit volatile working registers
an Analog inputs 0..9 16 bit input registers
ch Channel outputs 0..7 16 bit output registers, 0 on first cycle
ech Extended channel outputs 0..7, 8 bit register, 0 on first cycle
reg Memory registers 0..7 16 bit memory registers, 0 on first cycle
par Parameters 0..15 8 bit parameter registers
sw Switched inputs 0..15 single 16 bit register
err Analog error bit - set if a/d self test failed
Counter C, 8 bit non-volatile system loop counter, decremented by return
instruction and auto reloaded from L when zero. Nominal count
rate is 50 counts per second (ie. frame rate).
Notes : SADJ The speed instruction assumes that Y is the target output (ie.
current input) and X is the previous output. The value of par
will be added/subtracted to/from X to meet the target or if X is
closer to Y than par it will be set to Y. Typical frame rates are
50Hz, so if par is 127(100%), the output will change at
127us/frame which is 161ms for full scale range which exceeds the
performance of current servos. Servo slowest speed is 1us/frame
which is 20.5s for full scale range. The sign of par is ignored
and the servo will always track in the correct direction.
SPC The parameter change bit is set by the system whenever a
parameter is changed or the first cycle through the model code
and it is reset by the return instruction.
SAE The analog error bit is set by the system whenever the a/d
converter returns a value more than 12 from half scale from its
internal self test. This bit is reset by the return instruction.
MIX Mixing uses the following relation:
X = Y + (X * par) / 128
Y = Y - (X * par) / 128
SCL Scaling uses the following relation:
X = X * par / 128
Maths All 16 bit registers and mathematical functions operate on 16 bit
signed values.
ech Extended output channels are switched channels 8 to 16. They are
only available for use with Eagle Air Extended Channel Receiver.
The instruction set described above is a complex instruction set
to allow for the production of model type programs with the
minimum number of instructions. The limiting factor for program
execution speed is eeprom bandwidth so smaller programs run faster.
Preprocessor Directives :
#define id int replace identifier id with integer int
#descr "string" set model type description to string (max. 16 char)
#assign id "string" assign string to id for user interface (max. 5 char)
Possible values of id for #assign are as follows;
PARn id is parameter n
CHAn id is output channel n
ECHn id is extended output channel n
Memory map for RCMicro Encoder :
Model code block +-----+----------------------------------------+
0 | 1 | Model number (added by compiler) |
+-----+----------------------------------------+
1 | 1 | Size of executable code |
+-----+----------------------------------------+
2 | 16 | Model description (null padded) |
+-----+----------------------------------------+
18 | 5 | Channel assignment text (null padded) | x 8
+-----+----------------------------------------+
58 | 5 | Parameter assignment text (null padded)| x 16
+-----+----------------------------------------+
138 | 256 | Executable code (up to 256 bytes) |
+-----+----------------------------------------+
E2Prom memory +-----+----------------------------------------+
| | | x 4 for 2k eeprom
0 | 394 | Model code block (up to 394 bytes) | x 7 for 4k eeprom
| | | x 17 for 8k eeprom
| | | x 34 for 16k eeprom
+-----+----------------------------------------+
06A1h 1697 | | | x 4 for 2k eeprom
0CADh 3245 | 50 | Model memory block | x 14 for 4k eeprom
1AB9h 6841 | | | x 24 for 8k eeprom
38C5h 14533 | | | x 34 for 16k eeprom
+-----+----------------------------------------+
0769h 1897 | | | for 2k eeprom
0F69h 3945 | 150 | System strings & variable block | for 4k eeprom
1F69h 8041 | | | for 8k eeprom
3F69h 16233 | | | for 16k eeprom
+-----+----------------------------------------+
Copyright © 1995-1998. Eagle Air Australia Pty.Ltd. All Rights Reserved.