Newsgroups: comp.robotics,alt.toys.lego
Path: brunix!news.Brown.EDU!noc.near.net!howland.reston.ans.net!ux1.cso.uiuc.edu!cs.uiuc.edu!kadie
From: kadie@cs.uiuc.edu (Carl M Kadie)
Subject: Miniboard begining user: Let's share tips
Message-ID: <C87q6r.CGM@cs.uiuc.edu>
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
Date: Sun, 6 Jun 1993 18:32:51 GMT
Lines: 435

Like many you, I just got a preassembled miniboard from Greg (thanks,
Greg!). I've figured out a bunch of stuff but I still have some
"beginner's" questions. Let's share tips.  More experienced hands are
welcome to help. Alternatively, they can skip articles with subject
lines starting with "Miniboard begin".  Either way, we beginners can
get up to speed and won't have to feel selfconscience about asking
dumb questions.

(I'll mark my questions with "Q:")
- Carl

===============================================================
        Notes and Questions from a miniboard beginning user
                Carl M. Kadie, June 1993
* Steps

Here are the steps I took:
   Read Tech Ref (see below). Don't worry about "Mini-C" stuff.
   Connect a 9V battery to board. The red wire connects to terminal
           on the outside edge of the board. The power light (which
           might be green, or might be red) should light.
   Build and connect a serial line. Connect to a PC. The other light
           should light.
   Start a terminal program on the PC. Send commands to the miniboard.
           Make the motor lights go on and off. Read the time
   Connect wires to the digital and analog sensor sockets, read the
           values.
   Write a program in BASIC to do much the same (see enclosed program).
   Built a Lego project with computer control.
   Share what was learned.
   

* On-line archive site

Much miniboard information is available on-line via anonymous ftp from
cherupakha.media.mit.edu (18.85.0.47) in directory pub/miniboard.

* Documentation

The most important documentation is _Mini Board 2.0 Technical
Reference_ by Fred Martin. It is in the pub/miniboard/docs directory
of the archive.

Another interesting document is in postscript file "sensors.PS". It
tells how to make sensors for the miniboard.

* Running the miniboard - overview

You can put a program on the miniboard's computer or you can put
HEXMON on the miniboard's computer, connect the miniboard to a PC, and
then send commands from your PC to the miniboard. Both alternatives
are documented in the Technical Reference.

We beginners should probably start with the second alternative. 
It is simpler.

HEXMON is already loaded on the boards from Greg.

* Programs

The on-line archive has HEXMON and some other programs, if you want to
download them yourself. Except for HEXMON, none seemed very
interesting for beginners.

You can, in theory, modify HEXMON to add more functions, but that
would require assembly-level programming.

Also, you can in theory write C programs to run on the miniboard's CPU
but that requires a $100 C compiler or BSD Unix running on your PC (so
that you can use GCC to cross compile)

Q: Are there any free C cross compilers that run on MS DOS (or on a
Mac)?

Q: When downloading a program to the miniboard, when should I push
the slider switch back? When I see "____"?

* Useful Parts

I have found these parts from Radio Shack very helpful:

6v, 9v transformer -- to power the miniboard.
Alligator-clip wires -- to wire stuff together
"RS 232 to Mod Adpt", #276-1405, $3
    -- to build the connector described on page 13 of the Tech Ref. I
       did it without soldiering, but I did have to strip a couple
       wires.
CDS Photo Cell, 276-196, $1 for package of 3
    -- an analog light sensor
SMINI SPDT lever switch, 275-016, $1.69
    -- this is just a little switch, but it makes a perfect
       digital touch sensor. It is also perfect for Lego
       projects because it has two little holes in it that
       can easily be tied/wired to Legos.
4 color, solid wire, 278-858, $3.50
    -- This wire is stiff. I use 12" long pieces to plug into the miniboard
       and then I alligator clips to connect to the wire.
A digital multimeter
    -- Makes it easy to test sensors and motor output.
9v Battery clips, 270-325, $1.29 for 5
    -- for connect a 9v battery to the miniboard, also easy to clip to.
male-male telephone cord -- to connect the miniboard to RS232 Adaptor
telephone extension cord -- to extend range
25-pin RS232 female-female gender changer
     -- to connect the male RS232 Adaptor to the male serial connection
         on my computers.
male-female RS-232 cable
     -- to connect the Adaptor to my model 100's female serial input.

Q: Can I get "connectors" from Radio Shack (or via mail order) that fit
the miniboard motor and sensor sockets?

Q: Can I get a plug that fits the miniboard's power socket?

Q: What other sensors are easy/fun/cheap and easy to get?
    A bend sensor? a sensor to see if something is close
    (say by reflecting IR)? What are their part numbers?

Q: What motors are good?

Q: Can I replace my alligator clips with something more module like Lego's
     plug in wiring?

* PC control

You can connect a miniboard to a Radio Shack Model 100 computer and
control it via the terminal program or via BASIC (see sample program).
The only problem is that m100 I/O is very, very slow so programs
have poor reaction time.

For much faster control, connect to an MS-DOS machine. Any version of
Microsoft Basic can interact with the serial port quite easily.

Q: Can any other PC languages interact easily with a serial port?
Any free ones?

* Project

My Lego project was an simple elevator (a platform hanging from a
pully. The string was connected to an axis connect via gears (for more
power and less speed) to a Lego motor. When the elevator was down it
hit the lever switch, sending a signal to the miniboard.

* Computer Program

Here is a Microsoft Basic program for controlling some parts of the
miniboard. It was written on a Model 100 and then ported to Quick
Basic (only a few lines changed). (Both versions are included). Quick
Basic is from Microsoft, it is included in MS DOS 5.0 (but not 6.0).
For BASIC it is very nice, for example, it has parameter passing and
line numbers are optional.  Model 100 BASIC didn't so this program is
not nearly as nice as it could be.

Tip: If your PC program gets funny characters back from the miniboard,
it might be sending a newline character. This is a very easy bug to
have in a BASIC program (i.e. forgetting the semicolon at the end of a
print statement)

When this program runs, it goes into a loop waiting for a
key. Here is what the keys do:

1-9: set speed of current motor
q,w,e,r: make motor 1-4 the current motor
a,s: stop, start
z,x,c: toggle motor direction, motor reverse, motor forward
k: wait until a digital sensor senses something
t: wait a very short time


* The Program - MSDOS

2 ' Carl Kadie (kadie@cs.uiuc.edu) 1993
5  co$ = "com1:9600,n,8,1"
10 DEFINT A-Z
70 MAXFILES = 2
80 OPEN co$ FOR RANDOM AS 1
90 'OPEN co$ FOR INPUT AS 2
100 GOSUB 1500
105 DATA "0000","0001","0101","0841","1111","1249","2949","2A93","5555","D555","D5D5","EDB6","EEEE","F7BE","FEFE","FFFE","FFFF"
110 DIM PO$(16): FOR I = 0 TO 16: READ PO$(I): NEXT I
120 KEY ON
130 ON KEY(1) GOSUB 2000
135 DATA "005E","0060","0062","0064"
138 DIM PW$(4): FOR I = 1 TO 4: READ PW$(I): NEXT I
140 DATA 14,14,14,14
150 DIM HL(4): FOR I = 1 TO 4: READ HL(I)
160 PRINT "Max power level #"; I; " set to "; HL(I): M9 = I: P9 = HL(I): GOSUB 1100: NEXT I

170 PRINT "(SEE LINE 140)"
180 DIM DI(4), GO(4)
190 FOR I = 1 TO 4: DI(I) = 0: GO(I) = 0: NEXT I
200 DATA "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"
210 DIM HX$(15): FOR I = 0 TO 15: READ HX$(I): NEXT I
220 DATA "0054","0055","0056","0057","0058","0059","005A","005B"
230 DIM AV$(7): FOR I = 0 TO 7: READ AV$(I): NEXT I
240 S9 = 1: M9 = 1
250 GOSUB 3000
999 STOP
1000 ' motor 1 at power level 8
1010 PRINT #1, "z5555005E";
1020 GOSUB 1200
1030 PRINT #1, "z0010005D";
1040 GOSUB 1200
1090 RETURN
1100 ' set absolute power level for a motor
1110 ' p9 = aboluste power level 0-15
1119 ' m9 = motor number
1120 PRINT #1, "z"; PO$(P9); PW$(M9);
1150 GOSUB 1200: RETURN
1200 'read and print return value
1210 a9$ = INPUT$(1, 1): PRINT a9$; : IF a9$ = ">" THEN PRINT  ELSE 1210
1290 RETURN
1300 'calibrate motor
1310 PRINT "Calibrate Motor"
1312 INPUT "Which motor (1-4)"; M9
1315 PRINT "Press the up or down arrow or space."
1320 P9 = 0
1330 PRINT "Power Level: "; P9
1340 GOSUB 1100
1350 a9$ = INKEY$: IF a9$ = "" THEN 1350
1360 'PRINT ASC(A9$)
1370 IF a9$ = CHR$(30) THEN P9 = P9 + 1: GOTO 1330 ELSE IF a9$ = CHR$(31) THEN P9 = P9 - 1: GOTO 1330
1380 RETURN
1400 ' relative motor speed
1410 ' m9=the motor
1420 ' l9!=level (between 0 and 1)
1425 IF L9! > 1 THEN PRINT "l9! should be <=1, not "; L9!: STOP
1426 'PRINT INT(L9!*HL(M9)+.5)
1427 'PRINT PO$(L9!*HL(M9)+.5)
1430 PRINT #1, "z"; PO$(L9! * HL(M9) + .5); PW$(M9)
1440 GOSUB 2300
1490 RETURN
1500 'reset til ">"
1515 PRINT #1, "sssssssss";
1517 A$ = INPUT$(10, 1)
1520 A$ = INPUT$(1, 1)
1525 PRINT A$;
1527 IF A$ <> ">" THEN 1520 ELSE PRINT
1590 RETURN
1600 ' turn on/off a motor
1610 'm9 = the motor to turn on
1620 GO(M9) = G9
1630 GOSUB 1700
1690 RETURN
1700 'tell controller of go/di
1710 T9 = 0: FOR I9 = 4 TO 1 STEP -1: T9 = T9 + T9 + DI(I9): NEXT I9
1715 V9 = 0: FOR I9 = 4 TO 1 STEP -1: V9 = V9 + V9 + GO(I9): NEXT I9
1720 PRINT #1, "w00"; HX$(V9); HX$(T9); "005D";
1730 GOSUB 1200
1790 RETURN
1800 'change direction
1810 'm9 the motor
1820 'd9 0=forward, 1=backward, -1 toggle
1830 IF D9 >= 0 THEN DI(M9) = D9 ELSE DI(M9) = 1 - DI(M9)
1840 GOSUB 1700
1890 RETURN
1900 'digital input
1930 a9$ = "1003": GOSUB 2200
1940 PRINT B9$
1950 RETURN
2000 ' reset
2010 PRINT #1, "sssssssss";
2020 A$ = INPUT$(11, 1): PRINT A$
2040 RETURN
2100 ' read one char at a time
2130 PRINT "press keys, then press space"
2140 B9$ = INKEY$: IF B9$ = "" THEN 2140 ELSE IF B9$ = " " THEN RETURN
2150 a9$ = INPUT$(1, 1): PRINT a9$;
2160 GOTO 2140
2200 'read byte
2210 'a9$=address string
2220 PRINT #1, "r0000"; a9$;
2230 T9$ = INPUT$(10, 1)
2231 'PRINT T9$
2235 B9$ = INPUT$(2, 1): PRINT INPUT$(1, 1)
2240 RETURN
2300 'read 11
2310 PRINT INPUT$(11, 1): RETURN
2400 'reset on digitla input
2430 GOSUB 1900: IF B9$ = "FF" THEN 2430
2490 RETURN
2500 'read sensor
2510 's9= sensor number
2530 a9$ = AV$(S9)
2535 GOSUB 2200: PRINT B9$
2540 GOTO 2535
2590 RETURN
2600 'pause
2620 FOR I9 = 1 TO U9: NEXT I9
2630 RETURN
3000 'keyboard control of motor
3010 M9 = 1
3020 PRINT "motor #"; M9
3030 a9$ = INKEY$: IF a9$ = "" THEN 3030
3035 PRINT "Inkeyed: "; a9$
3040 T9 = INSTR("zxc", a9$): IF T9 > 0 THEN D9 = T9 - 2: PRINT "Direction="; D9: GOSUB 1800: GOTO 3030
3050 T9 = INSTR("as", a9$): IF T9 > 0 THEN G9 = T9 - 1: PRINT "On/off="; G9: GOSUB 1600: GOTO 3030
3060 T9 = VAL(a9$): IF T9 > 0 THEN L9! = T9 / 9: PRINT "Power Level="; L9!: GOSUB 1400: GOTO 3030
3070 T9 = INSTR("qwer", a9$): IF T9 > 0 THEN M9 = T9: PRINT "Motor="; M9: GOTO 3030
3080 IF a9$ = "k" THEN GOSUB 2400: GOTO 3030
3090 IF a9$ = "t" THEN U9 = 2000: GOSUB 2600: GOTO 3030

* The Program - Model 100
5 ' Carl Kadie (kadie@cs.uiuc.edu) 1993
10 DEFINT A-Z
70 MAXFILES=2
80 OPEN "com:88n1d" FOR OUTPUT AS 1
90 OPEN "com:88n1d" FOR INPUT AS 2
100 GOSUB 1500
105 DATA "0000","0001","0101","0841","1111","1249","2949","2A93","5555","D555","D5D5","EDB6","EEEE","F7BE","FEFE","FFFE","FFFF"
110 DIM PO$(16):FOR I=0TO16:READ PO$(I):NEXT I
120 KEY ON
130 ON KEY GOSUB 2000
135 DATA "005E","0060","0062","0064"
138 DIM PW$(4):FOR I=1TO4:READ PW$(I):NEXT I
140 DATA 14,14,14,14
150 DIM HL(4):FOR I=1TO4:READ HL(I)
160 PRINT "Max power level #";I;" set to ";HL(I):M9=I:P9=HL(I):GOSUB 1100:NEXT I
170 PRINT "(SEE LINE 140)"
180 DIM DI(4),GO(4)
190 FOR I=1TO4:DI(I)=0:GO(I)=0:NEXT I
200 DATA "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"
210 DIM HX$(15):FOR I=0TO15:READ HX$(I):NEXT I
220 DATA "0054","0055","0056","0057","0058","0059","005A","005B"
230 DIM AV$(7):FOR I=0TO7:READ AV$(I):NEXT I
240 S9=1:M9=1
999 STOP
1000 ' motor 1 at power level 8
1010 PRINT #1,"z5555005E";
1020 GOSUB 1200
1030 PRINT #1,"z0010005D";
1040 GOSUB 1200
1090 RETURN
1100 ' set absolute power level for a motor
1110 ' p9 = aboluste power level 0-15
1119 ' m9 = motor number
1120 PRINT #1,"z";PO$(P9);PW$(M9);
1150 GOSUB 1200:RETURN
1200 'read and print return value
1210 A9$=INPUT$(1,2):PRINT A9$;:IF A9$=">" THEN PRINT ELSE 1210
1290 RETURN
1300 'calibrate motor
1310 PRINT "Calibrate Motor"
1312 INPUT "Which motor (1-4)";M9
1315 PRINT "Press the up or down arrow or space."
1320 P9=0
1330 PRINT "Power Level: ";P9
1340 GOSUB 1100
1350 A9$=INKEY$:IF A9$="" THEN 1350
1360 'PRINT ASC(A9$)
1370 IF A9$=CHR$(30) THEN P9=P9+1:GOTO 1330 ELSE IF A9$=CHR$(31) THEN P9=P9-1:GOTO 1330
1380 RETURN
1400 ' relative motor speed
1410 ' m9=the motor
1420 ' l9!=level (between 0 and 1)
1425 IF L9!>1 THEN PRINT "l9! should be <=1, not ";L9!:STOP
1426 'PRINT INT(L9!*HL(M9)+.5)
1427 'PRINT PO$(L9!*HL(M9)+.5)
1430 PRINT #1,"z";PO$(L9!*HL(M9)+.5);PW$(M9);
1440 GOSUB 2300
1490 RETURN
1500 'reset til ">"
1515 PRINT #1, "sssssssss";
1517 A$=INPUT$(10,2)
1520 A$=INPUT$(1,2)
1525 PRINT A$;
1527 IF A$<>">" THEN 1520 ELSE PRINT
1590 RETURN
1600 ' turn on/off a motor
1610 'm9 = the motor to turn on
1620 GO(M9)=G9
1630 GOSUB 1700
1690 RETURN
1700 'tell controller of go/di
1710 T9=0:FOR I9=4 TO 1 STEP -1:T9=T9+T9+DI(I9):NEXT I9
1715 V9=0:FOR I9=4 TO 1 STEP -1:V9=V9+V9+GO(I9):NEXT I9
1720 PRINT #1, "w00";HX$(V9);HX$(T9);"005D";
1730 GOSUB 1200
1790 RETURN
1800 'change direction
1810 'm9 the motor
1820 'd9 0=forward, 1=backward, -1 toggle
1830 IF D9>=0 THEN DI(M9)=D9 ELSE DI(M9)=1-DI(M9)
1840 GOSUB 1700
1890 RETURN
1900 'digital input
1930 A9$="1003":GOSUB 2200
1940 PRINT B9$
1950 RETURN
2000 ' reset
2010 PRINT #1,"sssssssss";
2020 A$=INPUT$(11,2):PRINT A$
2040 RETURN
2100 ' read one char at a time
2130 PRINT "press keys, then press space"
2140 B9$=INKEY$:IFB9$="" THEN 2140 ELSE IF B9$=" " THEN RETURN
2150 A9$=INPUT$(1,2):PRINT A9$;
2160 GOTO 2140
2200 'read byte
2210 'a9$=address string
2220 PRINT #1,"r0000";A9$;
2230 T9$=INPUT$(10,2)
2231 'PRINT T9$
2235 B9$=INPUT$(2,2):PRINTINPUT$(1,2)
2240 RETURN
2300 'read 11
2310 PRINT INPUT$(11,2):RETURN
2400 'reset on digitla input
2430 GOSUB 1900:IF B9$="FF" THEN 2430
2490 RETURN
2500 'read sensor
2510 's9= sensor number
2530 A9$=AV$(S9)
2535 GOSUB 2200:PRINT B9$
2540 GOTO 2535
2590 RETURN
2600 'pause
2620 FOR I9=1TO U9:NEXTI9
2630 RETURN
3000 'keyboard control of motor
3010 M9=1
3020 PRINT "motor #";M9
3030 A9$=INKEY$:IF A9$="" THEN 3030
3040 T9=INSTR("zxc",A9$): IF T9>0 THEN D9=T9-2:PRINT "Direction=";D9:GOSUB 1800:GOTO 3030
3050 T9=INSTR("as",A9$):IF T9>0 THEN G9=T9-1:PRINT "On/off=";G9:GOSUB 1600:GOTO 3030
3060 T9=VAL(A9$):IF T9>0 THEN L9!=T9/9:PRINT "Power Level=";L9!:GOSUB 1400:GOTO 3030
3070 T9=INSTR("qwer",A9$):IF T9>0 THEN M9=T9:PRINT "Motor=";M9:GOTO 3030
3080 IF A9$="k" THEN GOSUB 2400:GOTO 3030
3090 IF A9$="t" THEN U9=2000:GOSUB2600:GOTO 3030



-- 
Carl Kadie -- I do not represent any organization; this is just me.
 = kadie@cs.uiuc.edu =
