The MRO Filter Slide

Last Updated: June 16, 2000


History

This documents the low-level commands that run the MRO filter slide. Inside the filter slide is a micro-processor called an EC-35. This micro-processor uses an 80C32 CPU, which is a variant of the Intel 8051 CPUs. The program which runs the filter slide is written in C and is called ec35v2.c The v2 in the name refers to the fact that we are currently running version 2 of this code. Ec35v2.c is compiled with the Micro-C cross compiler which will convert the C code into 8051 machine code which can be directly downloaded to the EC-35. Details on how to compile this code are given at the end of this document in Appendix A. Version 2 of the code is set up to deal with the slide encoder hardware which was added to the filter slide in May of 2000. Previous versions of the code will still run on the filter slide, but will not be capable of tilting the filter slide nor making use of the new encoder. Use of this older code should be avoided! The port bits which are used by the hardware are documented below in Appendix B.

Commands

The Ec35 is set up to accept the following command formats. In the table below note that a vertical bar (|) denotes the OR function. Therefore, the notation "x|y" means that either 'x' or 'y' can be included in the command syntax, but not both. The order of the parameters is critical in all of the commands. Spaces in the syntax summaries are for clarity and are not present in the commands themselves (see the examples).

Unless otherwise noted in the table, all of the commands below return the string "done\n\r" when they successfully execute. The table notes other possible returns.

Command

Command Description

Syntax Summary

a

Do a timed scan

s | t = choose slide or tilt (motor)

u | d = choose up or down (direction)

t ime = time of scan in decimal seconds

a s|t u|d time

example:

asu0.15

Causes a 0.15 second motion of the slide motor in the 'up' direction.

c

Read the encoder counter. Note there is one counter which reads both the tilt and slide encoders.

c

returns:

"cts\n\r" where cts = encoder counts, e.g. 1325

C

Sets the encoder counter

n = encoder counts to set the counter to

C n

example:

C4400

Sets the encoder counter to a value of 4400.

returns:

"bad command: %s\n\r" where %s is the command received.

e

Go to a tab edge

s | t = choose slide or tilt (motor)

u | d = choose up or down (direction)

e s|t u|d

example:

esu

The filter slide moves "up" to the nearest tab edge.

h

Print out the menu of commands

h

returns:

Approximately18 lines of help information (\n\r terminated lines)

i

Initialize the controller

i

m

Move to a new filter position

n = slide position to move to (1-6)

m n

example:

m4

Causes the filter slide to move to position 4.

returns:

"bad command: %s\n\r"

M

Move to a new tilt position

t = tilt position in decimal degrees

M t

example:

M1.45

Causes the tilt mechanism to move to 1.45 degrees.

returns:

"bad command: %s\n\r"

"Abort move. -5.0 <= tilt <= 15.5\n\r"

n

Move to a slide encoder position of x counts.

n x

example:

n183

Move to encoder counts of 183 on the filter slide

returns:

"bad command: %s\n\r"

N

Move to tilt encoder position of x counts.

N x

example:

N4400

Move to encoder counts of 4400 on the tilt

returns:

"bad command: %s\n\r"

o

Reset the slide origin. Causes the filter slide to move to the lower limit switch position and reset the slide counter.

o

O

Reset the tilt origin

O

p

Read out current control port setting.

p

returns:

The hex value of the current port setting (eg. 3F)

P

Set the control port to a value.

x = hex value to set the port to

P x

example:

P7D

Sets the control port to 0x7d

s

Report the current slide position.

s

returns:

"sp,se,sr\n\r" where

sp= slide position

se = raw slide encoder counts

sr = tab sensor reading eg. 4,812,48

S

Set the slide encoder.

n = encoder counts to set. Note: fractional parts to n are ignored.

S n

example:

S153

Causes the slide encoder to be set to 153.

returns:

"bad command: %s\n\r"

t

Report the current tilt position.

t

returns:

"t,e,s\n\r" where

t = tilt position in degrees

e = tilt encoder counts

s = tilt tab sensor reading e.g. 1.35,13500,248

T

Set the tilt position

tilt = tilt to set in decimal degrees

T tilt

example:

T1.35

Causes the current tilt position to be set to 1.35 degrees.

x

Read the Clinometer x tilt.

x

returns:

tilt = Clinometer x tilt in decimal degrees (tilt in the slide motion direction), eg. 5.50

y

Read the Clinometer y tilt.

y

returns:

tilt = Clinometer y tilt in decimal degrees, eg. 8.47

z

Read the Clinometer temperature.

z

returns:

t = Clinometer temperature in degrees Celsius, eg. 15.9

 

Appendix A: Compiling the filter slide code

The filter slide code is written in Micro-C, which is a PC based cross-compiler written by Dunfield Development Systems. This cheap compiler (only $100!) can be purchased from their web site at:

http://www.dunfield.com/dks.htm

It can be compiled from the DOS command line with the line

cc51 ec35v2 -pi m=l

Or, it can be compiled, downloaded and edited by using the program DDSIDE which comes with the DDS developer's kit. To set up DDSIDE to compile properly, you must set the compile options for a large memory model and Intel output. The compiling steps should be set to include the Preprocess option. If you are using the Mon-52 monitor and wish to download programs to the EC-35 using DDSIDE, then the "Upload delay" in the options menu must be set appropriately for the computer that you are using. For my current laptop, a value of 40,000 works fine.

Before compiling ec35v2.c, you must make sure that the micro-C compiler is set up for running code in EPROM, rather than under one of the monitors. The downloaded code is placed into a file called ec35v2.hex which must be programmed into ROM with a chip programmer. In the sections below I show how to set up the Micro-C files to download the code intended for use under the monitor and for a standalone EPROM.

Compiling Micro-C to run with a standalone EPROM

To set up Micro-C to compile for a standalone EPROM you need to do the following:

 

  1. In \mc (the root directory for the micro-C compiler) change the file '8051int.h' to use the normal interrupt vectors (ie. _IE0_ should point to $03, etc.) To do this set the parameter INTBASE to equal 0.

     

  2. In \mc\lib51 change the file '8051rlpl.asm' (the large memory model) to have the lines

    ?RAM EQU $0000

    ?RAMEND EQU $7FFF (if you're using the 32K RAM on the EC-35)

    ORG $0000

 

The embedded micro processor in the filter slide (the EC-35) is programmed to run its serial port at 1200 baud, 8 data bits, 1 stop bit, no parity.

 

Compiling a Micro-C program to run under the mon-52 monitor

To set up Micro-C to compile under mon-52 you need to do the following:

 

  1. In \mc change '8051int.h' to use the MON-52 interrupt vectors (ie. _IE0_ should point to $2203, etc.)

2)

  1. In \mc\lib51 change file '8051rlpl.asm' to have the lines

    ?RAM EQU $0000

    ?RAMEND EQU $7FFF (if using a 32K RAM chip)

    ORG $2300

You then must download the program and communicate with the EC-35 by running a DDSIDE session. You can also use any terminal emulator programs like ZTERM. Note that DDSIDE can also be used to edit and compile the program that you wish to run on the EC-35. See the document on the Integrated Development System (ie. DDSIDE) for instructions on how to run in this environment.

 

Appendix B: The filter slide port bits

The following are the actions of the port bits on the EC-35 embedded microprocessor which run the filter slide. The A/D converter has its input/output port at 0xf500. Reads and writes to this port are what control its actions. The A/D converter uses the T2EX interrupt on the EC-35 controller (ie. P1.1). The THCT2000 chip (ie. the counter) has two ports at 0xf600 (the most significant byte when reading the output counter) and 0xf601 (the least significant byte). Reads and writes to these ports will read the output registers on this chip, but to place the most recent value of the counter in the output register you must toggle the port pins P1.5 and P1.6 in an appropriate sequence before reading this output registers. The selection between the tilt encoder and the slide encoder is done in hardware. Turning on a motor will select the appropriate encoder. This multiplexing saved board space at the price of having to keep track of each encoder reading seperately in software.

The control bits for the filter slide are all found in port 1 of the CPU. They have the following functions:

Bit

Function

0

Turn on/off the tilt motor (on = 1/ off = 0)

1

(Used for T2EX interrupt)

2

Turn on/off the slide motor (1/0)

3

Select up/down motor direction (0/1)

4

Tab sensors on/off (1/0)

5

Reset tilt position counter (0)

6

Load latch for tilt position counter (downward transitions)

7

Clock output for tilt position counter (used by timer 1)