BrickHacks

8-bit robotics and the official home of the Lego Chevy 454 V-8

In memory of Dan Roganti

About, Notes, YouTube, Instagram



Programming the 9750 interface in Logo II

Prerequisite: you should have a working knowledge of Lego TC Logo or any other common Logo implementation for the Apple II.

Note: I do not plan to learn or use Logo II. I am posting about this language only because it was endorsed in the set 9700 documentation.

The following is quoted directly from pages 4.18-4.18 of the Lego Lines manual.

Initialization

To initialize the Lego interface, and set the variable Lego port to the correct address (assuming slot 2), use the following procedure. Writing to this address is accomplished with the deposit command.

TO lego_init
make "lego_port 49280+5*16
.deposit :lego_port+3 1
.deposit :lego_port+2 63
.deposit :lego+port+1 0
.deposit :lego_port 0
END

Reading data

Reading data is a matter of reading the lego_port address and determining whether bits 7 and 6 have been turned on. Reading the address is accomplished with the examine command. The output of the following procedure are "bit7 and "bit6 (1=on).

TO lego_in
local :x
make "bit7 0 make "bit6 0
make "x .examine :lego_port
if :x>127 [make "bit 7 1]
make "x :x-128* :bit7
if :x>63 [make "bit6 1]
END

Writing data

To write data, the bits to be written are first identified. These bits are then converted to a decimal number to be sent to the address. The syntax for the procedure is:

lego_out [list]

where list is a list of numbers (from 0 to 5) which correspond to the bits to be turned on. The remaining bits will be turned off. For example, the command:

lego_out [1 3 4]

will turn on bits 1, 3, and 4, and the rest off.

The procedure makes use of another procedure, power, in the conversion routine. In the long IF line, the exclamation mark at the end of the line indicates that it continues on the next. You should not type this in.

TO lego_out :bits
local ["x "byte]
make "byte 0
if not empty :bits [repeat count :bits !
[make "x first :bits make "bis butfirst :bits !
make "byte :byte + power 2 ;x]]
.deposit :lego_port :byte END

TO power :base :index
local :x
if :base=0 [op 0]
make "x 1
if or :base=1 :index=0 [op 1]
repeat :index [make "x :x*base]
END



Home - History - Universal Buggy - Computers - Interface A - Connections - Peripherals - Code - Analog - Beyond - Lego Chevy V8

Copyright: Evan Koblentz, 2018-2025