Newsgroups: comp.robotics
Path: brunix!sgiblab!swrinde!elroy.jpl.nasa.gov!decwrl!amd!amdahl!netcomsv!netcom.com!jfox
From: jfox@netcom.com (Jeff Fox)
Subject: Remote Control Program for Hero Jr. Robot 
Message-ID: <jfoxCE70vB.MuM@netcom.com>
Sender: jfox@netcom.com (Jeff Fox)
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
Date: Fri, 1 Oct 1993 00:47:34 GMT
Lines: 208

I recently wrote a remote control program for the Hero Jr. robot.  I would
like to post the program so that any other Hero Jr. users may make use
of it as they choose.

The program is designed to control of the robot from the RS232 port. With
it a user can experiment in real time with the robot using an RS232 cable
and any personal computer or terminal.  With this program HERO JR. can also
be controled by a laptop or embedded computer connected to HERO's RS232
port.

The program is very short so this post includes a description of the
program, source code, and a load file that will load the program to
the robot using telecommunication software.

The program is short, but this post is about 8K bytes.  If this is too
long for a post please let me know and I will not post any further listings
of this size.

                      
                        REMOTE CONTROL FOR HERO JR.
                             JEFF FOX 9/28/93

The RMT program for Hero Jr. provides remote control of Hero Jr. from a host
computer connected to Hero Jr. on the RS232 port.  You should use the same
cable used to talk to the MONITOR ROM or BASIC CARTRIDGE from your host
computer.

Loading:

To load RMT start the RS232 MONITOR program by pressing ENTER and 0 at the
same time on Hero Jr.'s buttons.  Then enter FBF8 and press ENTER to start
the ROBOT WIZARD - MONITOR ROM software.  Hero Jr. will send the REGISTER
status on the 6808 and the prompt.  Now type L and press ENTER on the
host computer to start the HERO Jr. LOAD program.  Now SEND the ascii file
RMT.LD to HERO from your host terminal program.  This will load RMT into
HERO Jr. memory.  The main program is in 1000 - 1088 and has a few routines
located at 1100.

Starting RMT:

To start RMT press CONTROL and P at the same time (^P) on the host computer.
The HERO Jr. MONITOR program will respond with the current program counter
setting and prompt for a new value.  Type 1000 and press ENTER on the host
computer.  This will set HERO Jr.'s program counter to 1000 the start of
the remote control program.  Then type G and press ENTER on the host computer.
This will start the REMOTE program.

Using RMT:

RMT can be used directly from the communication software on the HOST computer,
or it can be used by any program that can access the RS232 port on the HOST
computer.  RMT responds to the following commands: F B S M H Q O L R and D.

F start forward motor
B start backward motor
S stop drive and steering motors
M return T or F from the Motion sensor
H home the steering wheel
Q quit RMT and return to HERO Jr. "READY"
O display Odometer value as 16 bit hex value
L start left steering
R start right steering
D display Distance measured by Sonar sensor as 16 bit hex value

Jeff Fox
9/28/93

;            RMT   ReMoTe control program  COMMANDS: F B S M H Q O L R D

ORG $1000
1000 BD 1118 RMT   jsr  RCV            ; read rs232
1003 81 46         cmpa "F"            ; F
1005 26 06         bne  100D
1007 BD ECBE       jsr  .FORWARD       ; forward
100A 7E 1000       jmp  RMT
100D 81 42         cmpa "B"            ; B
100F 26 06         bne  1017
1011 BD ECD6       jsr  .BACKWARD      ; backward
1014 7E 1000       jmp  RMT
1017 81 53         cmpa "S"            ; S
1019 26 06         bne  1021
101B BD ED4D       jsr  .STOP          ; stop
101E 7E 1000       jmp  RMT
1021 81 4D         cmpa "M"            ; M
1023 26 11         bne  1036
1025 BD EC75       jsr  .MOTION        ; motion detector
1028 26 102E       bne  102E
102A 86 46         ldaa "F"            ; return F or
102C 20 02         bra  1030
102E 86 54         ldaa "T"            ; return T
1030 B7 D881       staa D881  SND      ; send it to host
1033 7E 1000       jmp  RMT
1036 81 4D         cmpa "H"            ; H
1038 26 06         bne  1040
103A BD EC83       jsr  .HOME          ; home steering
103D 7E 1000       jmp  RMT
1040 81 51         cmpa "Q"            ; Q
1042 26 03         bne  1047
1044 7E 9FB6       jmp  .RESTART       ; quit to "READY"
1047 81 4F         cmpa "O"            ; O
1049 26 0F         bne  105A
104B B6 05A1       ldaa ODOMETER_HIGH
104E BD 1136       jsr  HEX.
1051 B6 05A2       ldaa ODOMETER_LOW   ; send
1054 BD 1136       jsr  HEX.           ; 16 bit odometer value in HEX
1057 7E 1000       jmp  RMT
105A 81 4C         cmpa "L"            ; L
105C 26 06         bne  1064
105E BD ECF5       jsr  .LEFT          ; left
1061 7E 1000       jmp  RMT
1064 81 52         cmpa "R"            ; R
1066 26 06         bne  106E
1068 BD ED0E       jsr  .RIGHT         ; right
106B 7E 1000       jmp  RMT
106E 81 44         cmpa "D"            ; D
1070 26 13         bne  1085
1072 BD EF6F       jsr  .SNSON         ; sensor on
1075 BD EFA1       jsr  .RDSNR         ; read sonar
1078 36            psha
1079 37            pshb                ; high byte in B
107A 32            pula
107B BD 1136       jsr  HEX.           ; display 8 bit in HEX
107E 32            pula                ; low byte in A
107F BD 1136       jsr  HEX.           ; display 8 bit in HEX
1082 7E 1000       jmp  RMT
1085 7E 1000       jmp  RMT            ; place next command here
1088 01            nop


; REMOTE CONTROL PROGRAM FOR HERO JR
; JEFF FOX 9/28/93
;
; ORG $1100
1100 D6 FF   DELAY ldab <FF            ; delay about 1/2 sec
1102 BD 1109 DL1   jsr  2MS
1105 5A            decb
1106 26 FA         bne  DL1
1108 39            rts
1109 36      2MS   psha                ; delay about 2 ms
110A 07            tpa
110B 36            psha
110C 96 FF         ldaa <FF
110E 4A            deca
110F 26 FD         bne  $-1
1111 32            pula
1112 06            tap
1113 32            pula
1114 39            rts
1115 B7 D881 S/R   staa D881 SND       ; SND/RCV     bytes from rs232
1118 B6 D880 RCV   ldaa D880           ; RCV ReCeiVe byte  from rs232
111B 84 01         anda #01            ; status at D880
111D 81 01         cmpa #01
111F 26 F7         bne  RCV
1121 B6 D881       ldaa D881           ; data
1124 39            rts
1125 84 0F   NIB.  anda #0F            ; convert nibble from HEX to ASC
1127 81 0A         cmpa #0A            ; and send
1129 25 02         bcs  112D
112B 8B 07         adda 7
112D 8B 30         adda "0"
112F B7 D881       staa D881           ; SND
1132 BD 1109       jsr  2MS
1135 39            rts
1136 36      HEX.  psha                ; convert byte from HEX to ASC
1137 46            rora                ; and send
1138 46            rora
1139 46            rora
113A 46            rora
113B BD 1125       jsr  NIB.           ; MSN
113E 32            pula
113F BD 1125       jsr  NIB.           ; LSN
1142 39            rts
1143 01            nop

; DUMP
1000  BD 11 18 81  46 26 06 BD  EC BE 7E 10  00 81 42 26
1010  06 BD EC D6  7E 10 00 81  53 26 06 BD  ED 4D 7E 10
1020  00 81 4D 26  11 BD EC 75  26 04 86 46  20 02 86 54
1030  B7 D8 81 7E  10 00 81 48  26 06 BD EC  83 7E 10 00
1040  81 51 26 03  7E 9F B6 81  4F 26 0F B6  05 A1 BD 11
1050  36 B6 05 A2  BD 11 36 7E  10 00 81 4C  26 06 BD EC
1060  F5 7E 10 00  81 52 26 06  BD ED 0E 7E  10 00 81 44
1070  26 13 BD EF  6F BD EF A1  36 37 32 BD  11 36 32 BD
1080  11 36 7E 10  00 7E 10 00  01 01 01 01  01 01 01 01
1100  D6 FF BD 11  09 5A 26 FA  39 36 07 36  96 FF 4A 26
1110  FD 32 06 32  39 B7 D8 81  B6 D8 80 84  01 81 01 26
1120  F7 B6 D8 81  39 84 0F 81  0A 25 02 8B  07 8B 30 B7
1130  D8 81 BD 11  09 39 36 46  46 46 46 BD  11 25 32 BD
1140  11 25 39 01  01 01 01 01  01 01 01 01  01 01 01 01

; MIKBUG LOAD FORMAT

S1131000BD111881462606BDECBE7E100081422625
S113101006BDECD67E100081532606BDED4D7E1034
S113102000814D2611BDEC752604864620028654A7
S1131030B7D8817E100081482606BDEC837E10005F
S1131040815126037E9FB6814F260FB605A1BD119F
S113105036B605A2BD11367E1000814C2606BDECC5
S1131060F57E100081522606BDED0E7E10008144EF
S11310702613BDEF6FBDEFA1363732BD113632BD39
S113108011367E10007E10000101010101010101F1
S1131100D6FFBD11095A26FA3936073696FF4A2604
S1131110FD32063239B7D881B6D8808401810126E0
S1131120F7B6D88139840F810A25028B078B30B733
S1131130D881BD1109393646464646BD112532BD12
S1131140112539010101010101010101010101011F
S9

