Eebot - Department of Electrical and Computer Engineering

65 downloads 3319 Views 838KB Size Report
1This eebot technical description was adapted to be used with the HCS12 ..... HCS12/9S12: An Introduction to Software and Hardware Interfacing. Han-Way ...
eebot Technical Description1 Peter Hiscocks Department of Electrical and Computer Engineering Ryerson University [email protected]

Contents 1

Overview

2

2

Technical Overview

2

3

Robot Systems 3.1 Robot Mainframe Power Supply . 3.2 Bumper Switches and Knob . . . 3.3 Motor Drive . . . . . . . . . . . . 3.4 Motor Speed and Direction . . . . 3.5 Wheel Rotation Detectors . . . . . 3.6 MPU Alive . . . . . . . . . . . . 3.7 Guider Sensors . . . . . . . . . . 3.7.1 Guider Transient Response 3.7.2 Line Tracker . . . . . . . 3.7.3 Pattern Detector . . . . .

4

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

4 . 4 . 5 . 6 . 6 . 6 . 7 . 7 . 8 . 9 . 10

Signal Summary

5 eebot Hardware Test Routines 5.1 Motor Controls . . . . . . . . . . 5.2 Wheel Counters . . . . . . . . . . 5.3 The ALIVE Indicator . . . . . . . 5.4 The Battery and Bumper Switches 5.5 The Guider . . . . . . . . . . . . 5.6 The Frob Knob . . . . . . . . . . 6

. . . . . . . . . .

10

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

References

. . . . . .

12 12 12 13 13 14 14 14

List of Figures 1 2 3 4 5 6 7 8 9 1 This

eebot v1 . . . . . . . . . . . . . . . . . eebot v2 . . . . . . . . . . . . . . . . . Voltage Monitor, Programming Model . Bumper Switches, Programming Model Motor Control, Programming Model . . Wheel Rotation Detectors . . . . . . . . Guider Sensor Locations, Top View . . Guider Sensors . . . . . . . . . . . . . Signal Summary . . . . . . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

eebot technical description was adapted to be used with the HCS12 microcontroller by V. Geurkov.

1

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. 2 . 3 . 5 . 5 . 7 . 8 . 9 . 10 . 11

List of Tables 1

LCD Signal Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

1 Overview eebot is a small mobile robot intended for learning exercises in robotics, artificial intelligence and microprocessor programming. A photograph of the eebot prototype is shown in figure 1 on page 2.

Figure 1: eebot v1 Many courses that involve mobile robot exercises require students to construct their own robot. This is undoubtedly an educational process but because of time constraints it means that much of the focus is on the mechanical and electrical design and construction of the bot. In order to focus on programming issues, we have decided to provide students with a ’ready to run’ mobile robot. The robot includes a complete microprocessor development system, interfaced to the robot motors and sensors. The robot can be operated from an AC adaptor or from an internal 9.6 volt rechargeable battery. Programming the bot begins with basic exercises such as reading the sensor array and controlling the speed and direction of two DC drive motors. After this is completed, the student will program the bot to follow a black line, detecting and making decisions at line branches. Software modules developed in the first phase of the course can be re-used to form the basis of the guidance program in the second phase of the course.

2 Technical Overview The eebot consists of a 3-board sandwich. From top to bottom, the layers are 2

• A microprocessor development system. • The robot mainframe. • The sensor board. There are two versions of an eebot. The one presented in figure 1 uses a 68HC11 microprocessor development system (the MPP Board, unmodified). The MPP Board is a stand-alone development system for the 68HC11 microcontroller. It is available as a kit with assembly manual. The board is described in detail in separate publications. The second version of an eebot (currently in use) is built on an HCS12 microcontroller and is shown in figure 2 on page 3. As any microcontroller, the HCS12 includes an A/D converter, input capture interrupts, and output timers, all of which are used as part of the eebot system. The development system for the microcontroller also includes a Serial Monitor program and a 20x2 liquid crystal display.

Figure 2: eebot v2 The mainframe contains the robot power supplies, bow and stern bumper switches, DC gearmotor drive motors, power switches, LED indicators, a general purpose potentiometer (the frob knob). It supplies DC power to the controller board and brings signals to and from the board via a ribbon cable. The sensor board provides optical signals that allow the robot to track a black line and detect branches in the line. It includes 6 high-intensity LEDs to illuminate the line and 6 corresponding Cadmium Sulphide photoresistors to detect the background and line illumination. (CdS photocells are low resistance when illuminated and high resistance when dark.) Four of the photoresistors are configured in a T formation to detect line branches and junctions. Two photoresistors are arranged differentially to track the edges of 3/4 inch wide black electrical tape. The resistances of the cells are converted to voltages and then multiplexed into one channel of the HCS12 A-D converter. The sensor board also supports the bot front roller. 3

3 Robot Systems In the next section, we describe each of the robot subsystems in detail.

3.1

Robot Mainframe Power Supply

For development work on the lab bench, the robot can be powered from a 9 volt DC adaptor. When the program has been developed and is working, the bot can be powered by a 9.6 volt rechargeable NiCad battery, which fits into the robot interior, and then turned loose on the world. It is advisable to disconnect the battery when using the AC adaptor supply. Raw 9 volt power is supplied to the MPP board, which then regulates it down to 5 volts to operate the microprocessor. The 9 volt input power is also regulated down to 5 volts on the robot mainframe, for power to circuitry on the mainframe and sensor boards. A separate regulator drops the 9 volt input power down to 4 volts or so to operate the drive motors. This is equipped with a large heat sink because the voltage drop (from 9 to 5 volts) and drive currents (maximum about 400mA per motor) combine to generate significant heat in the regulator2 . The bot logic is enabled with a LOGIC toggle switch, which is indicated with a POWER LED. A separate MOTOR switch enables motor power. Logic voltage is connected to one of the A/D channel inputs so that the microprocessor can detect when the battery is reaching the end of its charge. The measurement voltage is about 9 volts, and the maximum voltage readable by the A/D is five volts, so the logic supply is divided down by a factor of 2 for measurement. The software must consequently multiply the A/D reading by 2 to get the correct logic supply voltage. The logic and the two DC motors share the same 9 volt input power, which can lead to problems of electrical noise. The DC motors tend to pull down the supply voltage when they start, because of their large starting current. As well, the DC motor commutator generates switching noise. To avoid noise contaminating the logic supply • The motor supply has its own regulator. • Motor current is filtered with an inductor and filter capacitors. • The logic and motor supplies are isolated with rectifier diodes. • The logic power has its own, large reservoir capacitor which can hold up the logic voltage for a few milliseconds. The simplified circuit for the power supply monitor input is shown in figure 3. Notice: • The battery voltage reading must be calculated from the A/D reading. The battery voltage is actually twice the A/D voltage reading, plus one diode drop (0.6 volts). The software routine that displays battery voltage must take this into account. • When both the battery and AC adaptor are plugged in simultaneously, the effect of the diodes is to select the larger of the two voltages. • The LOGIC POWER switch must be closed to get a reading. • The motor is also powered from the same sources, but this is not shown in the programming model. When a motor is running (and especially when it is starting), the logic voltage reading will decrease. 2 A switching regulator would be much more efficient of battery power, but might have difficulty coping with the variable current motor load. To simplify the development process, we went with the less efficient linear regulator.

4





' 1

/RJLF3RZHU

7R9ORJLFVXSSO\UHJXODWRU ' % 9%DWWHU\,Q

5 N

$&$GDSWRU3RZHU,Q 9'&

+&6 %'(7

$1 $'&RQYHUWHU,QSXW

5 N

3RZHU6XSSO\6HFWLRQ

Figure 3: Voltage Monitor, Programming Model

3.2

Bumper Switches and Knob



When the robot bumps into some object, it should stop immediately. Two bumper switches, one at the bow and one at the stern, generate signals for this purpose. When a bumper switch is actuated, the corresponding LED on the back deck will illuminate. The simplified circuit for bumper switches and General Purpose Knob is very simple, as shown in figure 4. ☎

9 ☎

0LFURFRQWUROOHU

%2:%803(5 %2:%803

$1 %

9

67(51%803(5 67(51%803 $1 %

9

.12%

$1

Figure 4: Bumper Switches, Programming Model Notice: • When the switch is open (no bump), there will be no current through the resistor and LED. The LED has a fixed voltage drop of about 1.5 volts, so the input voltage to the A/D converter channel will be about 3.5 volts. 5

• When the switch is closed (bump), the input voltage will be zero volts. • The general purpose knob (aka frob knob) produces an input between zero and 5 volts, which will read between $00 and $FF at the A/D input channel AN4.

3.3

Motor Drive

The robot is driven by two DC gearmotors. Each motor is geared down by a factor of 203:1, so the bot has lots of torque for scaling hills, but it moves fairly slowly. It is not intended to be a race car. To steer the robot, the gearmotors can be driven at different speeds or even in different directions. The robot can then execute very tight turns. The front wheel rolls normally when the robot is moving straight ahead, and skids sideways when the robot is executing a turn. (An alternative drive system would have been to use stepping motors to drive the robot. A stepping motor rotates a certain fixed amount with each pulse of current to the motor coils. This makes it simple to keep track of wheel rotation. However, stepping motors tend to skip steps if their load is exceeded, in which case the distance count becomes erroneous. DC motors, as used in eebot, have more torque than stepping motors, especially when geared down as in this design. However, you then need wheel rotation detectors to detect distance, and you need to be careful about the direction of wheel rotation.)

3.4

Motor Speed and Direction

Each DC motor is operated from a DC voltage of about 4 volts that can be duty cycle modulated. For example, if the duty cycle is such that the supply voltage is on for 50% of the time and off for the remaining time, the average voltage across the motor is then 2 volts, and the motor turns more slowly. The duty cycle for each motor is controlled from an HCS12 Output Timer line, which is ideally suited for varying the duty cycle of a pulse signal. The direction of each motor is controlled by a general purpose computer output signal, so that a logic 0 drives the motor forwards and a logic 1 drives it in reverse. The motor requires at least 1 volt to operate, the duty cycle range between 25% minimum and 100%. The optimum switching frequency for the motor supply appears to be around 50Hz. Two LED indicators are attached to each motor, one for each connection to the motor, labeled as MOTOR+ and MOTOR-. These are useful for determining that the motor is receiving power, along with a visible indication of the duty cycle. The simplified circuit for the motor control circuit is shown in figure 5. Notice: • The direction is controlled by a DPDT switch which controls the direction of current flow through the DC motor. The state of this switch is controlled by bits PA0 and PA1 of the PORTA register, which is mapped into the microprocessor memory location $0000. • The speed of each motor is controlled by a switch in series with the power supply. Varying the duty cycle of the switch sets the average voltage across the motor, and hence its speed. The motor speeds are controlled by the Output Compare lines IOC4 and IOC5, which are part of the timer section of the HCS12 microprocessor.

3.5

Wheel Rotation Detectors

For each motor, one of the gearbox gears has holes in it that are detected by a photointerrupter3 . There are 4 holes in the gear and a 13:1 ratio between the gear rotation and the rotation of the output shaft. Counting the holes 3 The photointerrupter consists of a light-emitting diode and a phototransistor with a space between them. If something blocks the light path between the two the phototransistor turns OFF. If the optical path is transparent, the phototransistor turns ON. By detecting the state of the phototransistor (ON or OFF), it is possible to sense the passage of a mechanical object through the gap.

6

HCS12

PT5/IOC5

L293D STARSPEED

1

uP-31 1=On, 0=Off

PA1

STARDIR

Starboard

4V Motor Supply

Port

4V Motor Supply

2

U6-19 0=Fwd, 1=Rev

PT4/IOC4

PORTSPEED

9

uP-30 1=On, 0=Off

PA0

PORTDIR

10

U6-2 0=Fwd, 1=Rev

Figure 5: Motor Control, Programming Model gives a measurement of distance traveled by each drive wheel, with a resolution of about 5mm distance moved per count. The count information is connected to computer input capture inputs so that the computer can monitor wheel count. It can then be used by the computer to ensure that the robot is moving in a straight line or executing a sharp turn through a desired angle. The photointerrupters are each connected to a ROTATION LED on the rear deck of the mainframe. When the motors are running at slow speed, these LEDs can be seen flashing. The simplified circuit for the rotation detector circuits is shown in figure 6.

3.6

MPU Alive

When debugging a microprocessor system, it is very useful to have some indication that the computer program is executing correctly. If the computer program crashes for some reason, the indicator shuts off. This can be accomplished by having the computer pulse an output line every time it executes the main loop (also known as the event loop). This is a feature that the programmer must add to the system software. The alive circuit on the mainframe detects this type of pulse and causes the MPU ALIVE LED to illuminate when the pulse is present. If the pulse ceases for some reason, regardless of whether the output of the computer is in the high or low state, the LED will extinguish. Think of it as the heartbeat of the computer program. The ALIVE signal is derived from the microprocessor output signal PT6/IOC6. This pin must be configured by the software as a general purpose output pin, which then is flipped in polarity each time the software executes the main loop of the program.

3.7

Guider Sensors

The Guider Sensors are used for pattern detection and line following of black electrical tape on a light background. (Red electrical tape on a dark background also works well, but of course the on-tape and off-tape signals are opposite since the contrast is reversed.) 7

9

+&6

5'67$5

37,2&

5 5 527$7,21

2SWRLQWHUUXSWHU

6WDUERDUG

5'3257

37,2&

527$7,21

2SWRLQWHUUXSWHU 3RUW

Figure 6: Wheel Rotation Detectors The sensors are 6 Cadmium Sulphide (CdS) photoresistors that are high resistance in darkness and low resistance when illuminated. The sensors are labeled a through f, as shown in figure 7. The small circles are high-intensity red LEDs, which illuminate the floor surface under each sensor. The large circles are the sensors themselves. Lines join each LED to its corresponding sensor. The relationship between a typical sensor and LED is shown in the bottom half of the diagram. The LEDs are mounted on the top side of the guider circuit board and illuminate the floor surface via a hole in the guider circuit board. This arrangement allows the CdS cells to be very close to the floor surface, which improves the sensitivity and reduces the effect of ambient light. As well, the LEDs are protected from being knocked out of alignment. The simplified schematic for the Guider Sensors is shown in figure 8. The LEDs and CdS cells are selected by the same signals, the three general purpose digital outputs PA2, PA3 and PA4. The 74HC138 decoder that drives the LEDs is enabled and disabled by the general purpose digital output PA5. One of the voltages developed across the sensors is selected by a 74HC4051 analogue multiplexer and directed to the HCS12 A/D input channel AN1. The same three general purpose digital outputs PA2, PA3 and PA4 selecting the LED also select the corresponding photosensor. Notice that 3 of the 8 possible sensor inputs are unused and connected to ground, so they should read zero. In general, the LEDs will be enabled so D5 should be set to a high (logic 1, +5V) level. The PA2, PA3 and PA4 signals will have some value between 000 and 100 (msb-nsb-lsb) to illuminate one of the LEDs and simultaneously select one of the guider signals. The guider software could scan the 5 sensor signals or repeatedly read one sensor, whatever is required. To detect the background illumination, the LEDs can be disabled by lowering the D5 signal. The sensor readings would then indicate read the lighting without any LED illumination. This could be used as a baseline or noise value and subtracted from the value obtained when the LED is activated. (The original guider design illuminated all LEDs at once, but that caused problems in light leaking from one LED into several sensors. Furthermore, there was no way to determine background illumination level.) 3.7.1

Guider Transient Response

The CdS photoresistors respond quickly to an increase in illumination (decreasing resistance) but rather slowly to decreasing illumination (increasing resistance). Consequently, for accurate measurements the photoresistor

8

D F A

C

B

E

EEBOT PLATFORM

LED (one of 6) GUIDER PLATFORM

CdS Photoresistor cell Ground

Figure 7: Guider Sensor Locations, Top View should be allowed time to darken between each measurement. The darkening time constant is in the order of 50 milliseconds4 . Consequently, the most rapid allowable scan rate to scan one sensor is 20 times per second. If all five sensors are being scanned, the fastest allowable scan rate increases because a given sensor can be darkening while others are being read. Then the minimum scan time per sensor is 10 milliseconds, or about 100 times per second. The differential line tracker pair of cells E-F actually recovers faster than a single cell, and the effective time constant is about 25 milliseconds. (This is because one of the pair is brightening while the other darkens.) So the line tracker signal could be scanned as fast as 40 times per second, which may be important for rapid response in steering. 3.7.2 Line Tracker Sensors E and F used for line tracking. They are spaced 0.75 inches apart, so that they are centered over the two edges of electrical tape line when the robot is centered over the line. The two sensors are a voltage divider, so that the voltage at the center tap is determined by the ratio of the two sensor resistances. The guidance software of the robot should position the robot so that the voltage at the centre tap from voltage divider sensors E and F is exactly midway between 5 volts and zero, ie, 2.5 volts. Then the two sensor resistances are equal, the light level on the two cells is equal, and the two cells are equally over the black line and light background. Notice that the absolute value of the resistance of sensors E and F is unimportant: it is their ratio that determines the output voltage. Consequently, they should largely ignore changes in ambient light level and this does indeed prove to be the case. However, if both sensors are over a completely black background or a completely white background, they will also generate 2.5 volts. Consequently, some other method is required for ensuring that the robot is over a valid 4 This was determined by aiming an LED directly at a photoresistor and pulsing it from a function generator while measuring the voltage across the photoresistor with an oscilloscope.

9

  ( 3RUW

,QSXW&KDQQHO 

+& '(&2'(5

) 6WDUERDUG

6HQVRU9ROWDJH 0HDVXUHPHQWWR+&6$'FRQYHUWHU FKDQQHO$1  



2XWSXW

$

+& 



$1$/2* 08;

%

 

)URP+&6   3RUW $ 

3$

$

3$

%

3$

&

3$

&

6HOHFW   '

(QDEOH &6



$ %

6HOHFW

&

Figure 8: Guider Sensors line, and that is the function of the pattern detector. 3.7.3 Pattern Detector Sensors A, B, C and D form a pattern detector for various line configurations. For example, if sensors A and C detect a dark line while sensors B and D detect a light background, then the robot is probably over a valid line and the information from the line tracker can be used for guidance. If the pattern detector sensors all detect a light background, then the robot is off line, and should begin to search for a line. The line tracker cannot be used. If the pattern detector senses a black line at right angles to the current line (for example, sensors A reads light, sensor B reads dark, sensor C reads dark, sensor D reads light, so the line angles off to port), then the robot should advance until the drive motors are over the bend in the line and then pivot counter-clockwise until the spur line is under sensors A and C. Similar interpretation strategies should enable the pattern detector to sense a T junction or a line that simply comes to an end. The sensors of the pattern detector each detect absolute light level. A constant current is passed through each sensor and the voltage generated across the sensor is then proportional to its resistance. The sensor currents are each adjusted so that the sensor generates about 1.8 volts over a light surface and 3 volts over a dark surface5 .

4

Signal Summary

The eebot signals and their connection to the microprocessor system are shown in figure 9 on page 11. 5 As part of the operating procedure, the operator should check the A/D reading from each of the pattern detector sensors over light and dark surfaces, and calibrate the software thresholds accordingly.

10

%'(7

%DWWHU\9ROWDJH

3$'$1

*8,'('$7

*XLGHU'DWD

3$'$1

%2:%803

%RZ%XPSHU

3$'$1

67(51%803

6WHUQ%XPSHU

3$'$1

.12%

)URE.QRE

$' ,QSXWV



3$'$1 QF

3$'$1

QF

3$'$1

QF

3$'$1

527'(767$5

6WDUERDUGURWDWLRQ

527'(73257

3RUWURWDWLRQ

37,2& 37,2&

QF

,QSXW&DSWXUHV

37,2& 2XWSXW&RPSDUHV

37,2&

;,54

6LQJOH6WHS

37,2&

325763'

3RUW0RWRU6SHHG

 2II

37,2&

67$563'

6WDUERDUG0RWRU6SHHG

 2II

37,2&

$/,9(

$OLYH,QGLFDWRU

37,2&

QF

6& 0LFURSURFHVVRU 3257$ RXWSXWV



3$

3257',5

3RUW0RWRU'LUHFWLRQ

 )ZG

3$

67$5',5

6WDUERDUG0RWRU'LUHFWLRQ

 )ZG

3$

PA

*XLGHU6HOHFW/6%

3$

PA3

*XLGHU6HOHFW16%

3$

PA

*XLGHU6HOHFW06%

3$

PA

*XLGHU/('(QDEOH

3$

QF

3$

QF

Figure 9: Signal Summary

Table 1 on page 11 shows relationship between the standard LCD signals and the corresponding pins of Port B and Port J of the microcontroller. Table 1: LCD Signal Summary LCD Signals 9S12C Port Pins Data 0 - D0 Port B/0 - PB0 Data 1 - D1 Port B/1 - PB1 Data 2 - D2 Port B/2 - PB2 Data 3 - D3 Port B/3 - PB3 Data 4 - D4 Port B/4 - PB4 Data 5 - D5 Port B/5 - PB5 Data 6 - D6 Port B/6 - PB6 Data 7 - D7 Port B/7 - PB7 RegSel - RS Port J/6 - PJ6 Enable - E Port J/7 - PJ7

11

eebot Hardware Test Routines

5

In this section, we show test routines that may be exercised from the CodeWarrior IDE. These are routines that may be used very quickly, without programming, to check whether some hardware feature of the eebot is working correctly. All these test routines assume that the robot is powered up correctly and that the microcontroller board is connected to a host running the CodeWarrior IDE software. In order to establish contact with the CodeWarrior software via the serial terminal connection on the microcontroller board you will need to upload any (even ”empty”) program into the board. This program should not be periodically updating the content of the addresses that are going to be modified from the command line.

5.1

Motor Controls

The motors may be turned on and off by changing bits 4 and 5 in the PORTT register of the HCS12 at $0240 (don’t forget to preliminary configure pins 4 and 5 of the PORTT as outputs by executing wb $0242 $78 command which will write byte $78 into the DDRT register): Monitor Command wb $0240 $00 wb $0240 $10 wb $0240 $20 wb $0240 $30

Action Turn off both motors Turn on the Port motor (only) Turn on the Starboard motor (only) Turn on both motors

The monitor command wb $0240 $00 is interpreted as follows: Type in wb $0240 $00 followed by The motor direction may be changed by changing bits 0 and 1 in the PARTA register at $0000. A 0 bit selects forward motion, a 1 bit selects reverse. (Again, to configure pins 0 and 1 as outputs you will need to write $3F into the DDRA register: wb $0002 $3F.) Monitor Command wb $0000 $00 wb $0000 $01 wb $0000 $02 wb $0000 $03

5.2

Action FWD both motors Starboard FWD, Port REV Starboard REV, Port FWD REV both motors

Wheel Counters

The technique for reading the wheel counters is to • Start one of the motors turning as described above in section 5.1 • Repeatedly read the PORTT register at $0240: – scroll down to the location $0240 on the Memory window – holding the mouse pointer over the Memory window repeatedly right-click and press the (refresh) key on the keyboard • Check to see if the bit corresponding to that wheel counter input is changing. For example if you run the STARBORD motor, when you repeatedly display PORTT you should see the least significant nibble of PORTT changing in such a way that corresponds to changes in the least significant bit. For example, it might fluctuate between FC and FD, or between FE and FF. Similarly, if you run the PORT motor, you should see the least significant nibble of PORTT changing in such a way that corresponds to changes in the second least significant bit. For example, the reading might fluctuate between FD and FF. 12

5.3

The ALIVE Indicator

The ALIVE indicator may be tested with a short looping program that continuously flips bit PT6. Using the monitor wb command, type in the following code from the monitor prompt line followed by key: wb $3800 $B6 $02 $40 $88 $40 $7A $02 $40 $20 $F6 This code corresponds to the assembly language program:

start

org ldaa eora staa bra

$3800 PTT #$40 PTT start

To test if the data was entered properly, you can execute the instruction wb dasm $3800. You should see the same (disasembled) mnemonics. Start this program with the command g $3800. The ALIVE indicator should illuminate continuously. Break out of the program by pressing the reset button on the MPP board computer.

5.4

The Battery and Bumper Switches

The battery voltage and two bumper switches are on A/D channels AN0, AN2 and AN3 respectively. The five channels of the A/D, AN0 through AN4, may be displayed continuously with the following sequence of commands6 : • Start the A/D converter running continuously by executing the monitor command wb $0082 $80 $28 $F7 $B0. • Repeatedly check the conversion results at the locations $0091, $0095 and $0097 as described above in section 5.2. • These locations contain the input data we are interested in, from A/D channels AN0, AN2 and AN3: Address 0091 0093 0095 0097 0099

Channel AN0 AN1 AN2 AN3 AN4

Function Battery voltage Guider (see section 5.5 below) Bow bumper Stern bumper Frob Knob (see section 5.6 below)

Battery Voltage The battery voltage value may be determined by converting the hex value on channel AN0 to volts, multiplying by 2, and adding 0.6 volts. Each count amounts approximately to 20mV, so a reading of $DB would correspond to an input voltage of 4.28 volts, which is a battery voltage of 9.16 volts. Bow Bumper Switch The Bow Bumper signal is on channel AN2. When the switch is not actuated, the voltage should be some non-zero value corresponding to approximately 3.5 volts. When the switch is actuated, the input voltage should be zero. Use the procedure of section 5.4 above to repeatedly display the readings of channels AN0 through AN4. While displaying the contents, press and release the Bow Bumper switch. You should see AN2 change. 6 Tip

o’ the hat to Ken Clowes, who suggested this technique.

13

Stern Bumper Switch This is exactly the same procedure as the Bow switch, except that the reading is on channel AN3, stored at location $0097.

5.5

The Guider

The method of testing a guider is as follows: • Start the A/D converter running in continuous mode, as described in section 5.4 • Select the guider sensor by setting bits 2, 3 and 4 of the PORTA register at $0000 according to the following table. Notice that bit 5 (D5) must be a logic 1 to enable the LEDs. Sensor A (front) B (port) C (center) D (starboard) E-F (line)

Contents of PORTA Binary 00100000 00100100 00101000 00101100 00110000

Contents of PORTA Hex 20 24 28 2C 30

• Repeatedly check the conversion results. • Watch the contents of $0093 while covering and uncovering the sensor to be checked. • Reading a sensor with bit 5 (D5) set to zero will give a background illumination reading, ie, a reading with the corresponding LED disabled.

5.6

The Frob Knob

The Frob Knob may be used to check whether the A/D converter is working properly. The Frob Knob is connected to A/D channel AN4, so the procedure is similar to section 5.4: • Start the A/D converter running continuously. • Repeatedly check the conversion results. • Location $0099 contains the input data we are interested in, this time from the A/D channel AN4. • Move the Frob Knob while watching the contents of location $0099. The value should increase as the knob is rotated clockwise.

6 References CPU12 Reference Manual Motorola Document CPU12RM/AD REV 3, 4/2002 The authoritative source of information about the 68HC12 & HCS12 microcontrollers. 68HC11 Microcontroller, Construction and Technical Manual Peter Hiscocks, 2001 Technical information on the MPP Board, 68HC11 Microprocessor Development System Information on programming and interfacing the M68HC11 MPP Board. HCS12/9S12: An Introduction to Software and Hardware Interfacing Han-Way Huang Delmar Cengage Learning, 2010 A basic text on the HCS12 microcontroller. 14