evank

A challenge! Lego 9750 "Interface A" hacking

Recommended Posts

Here's something weird. In the Lego-provided IBM (9771) code (http://www.brickhacks.com/ibmbasic.php), the check-out lines are:

10000 P=925
10010 OUT P,21
10020 IF (INP(P) AND 63)=21 THEN OUT P,0 ELSE ERC=4 : GOTO 20000

In 10010, I have to wonder: why is the test value 21? What's special about that number?

Edited by evank

Share this post


Link to post
Share on other sites
8 hours ago, evank said:

In 10010, I have to wonder: why is the test value 21? What's special about that number?

Yes, that code is in the manual for 9771 - I have that at home.

Nothing, really nothing is special about that number. In binary notation, 21 dec (15h) is 010101 - some geek found it cool to test the presence of 9750 by alternately turning its 6 outputs on and off. On the other hand, that pattern stands out a bit when testing new hardware. I found it useful when making my serial-to-parallel Arduino thingy; when the pattern shows up on 9750, you know that at least the out command worked. Checking for the response by masking off bit 6+7 (AND 63 dec, 3Fh, bin 00111111) and getting the same number back, tells you the in command worked as well.

They do that in TCLogo as well:

1481:0A29  mov  al,15                  ;load 15h = bin 0001 0101 into al
1481:0A2B  out  dx,al                  ;write bin 0001 0101 to serial port
1481:0A2C  in   al,dx                  ;read serial port into al
1481:0A2D  and  al,3F                  ;al = al AND 3F (bin 0011 1111)
1481:0A2F  cmp  al,15                  ;compare al to 15h = 0001 0101

You can use any other number for testing, this 010101 pattern is maxing the probability that one or more lines on the data bus are not working.

I guess. Maybe it is also just for fun. Programmers ... :pir-laugh: maybe 42 (101010 bin) was simply too obvious ... 

Best,
Thorsten

Share this post


Link to post
Share on other sites

I see your point about a nice-looking test pattern. I just figured it would be 63 (all on) or, as you noted, 42 - now THAT would be appropriate! Lego engineers clearly had a sense of humor. To check the connection of the 9751, your code must send a text string to Interface B: "Do you byte, when I knock?" and confirm the interface's reply, "Just a bit, off the block." The weird part is, the text string is mentioned in one of the 9750 manuals! (I forget which one right now. Just got out of bed. I'll check later.)

Share this post


Link to post
Share on other sites
3 hours ago, evank said:

Lego engineers clearly had a sense of humor.

I agree. In the beginning ... it already seems to have faded in the late 1990's. To "unlock" the firmware in the RCX, you had to provide that phrase as well ...

"Start firmware download clears RAM from 0x8000-0xcc00. Unlock firmware requires "Do you byte, when I knock?" string to be located in firmware image starting before cc00; anything after cc00 is ignored, so the string does not have to be complete (!). Firmware execution begins at the address specified by start firmware download."
(http://www.mralligator.com/rcx/romref.html)

Hope you enjoyed a good, strong, black coffee this morning!

Best,
Thorsten

Share this post


Link to post
Share on other sites
On 7/29/2023 at 3:44 AM, evank said:

The challenge

Just to make sure this thread is not drowning in this Liebherr forum ... :pir-wink:

I am making progress getting into GFA Basic (for my Atari ST) - it looks rather promising. The parallel port of the ST is a nightmare though (signals destroyed by interrupt routines every such milliseconds, and no ACK line - crap! Have to live with strobe and busy ... and have to figure out, how GFA Basic deals with that via the inp() and out() function/command). The serial port is plain vanilla, but using it will violate the rules (no Arduino etc.), as a breadboard will be, well, large to make a serial-to-6+2 bit parallel port ...

Right now I am doing all this in the Atari Hatari emulator :pir-laugh:, but well, we'll see.

I love challenges. Ready Player One!

Best,
Thorsten

Edited by Toastie

Share this post


Link to post
Share on other sites

Update :pir-huzzah2:

Moved yesterday from "coding" (well, BASIC; GFA BASIC 3.6 though ... that language is powerful(!), I surely have to admit!) within the Hatari emulator to my real Atari 1040 STFM.

Took me a while to figure out the I/O mechanics on the serial port using "OUT serial_port,data" and "var=INP(serial_port)" - but got that to work today.

I have now an Atari ST controlling 9750 via its serial port and my Arduino Nano serial2parallel converter. So this is >NOT< an entry for the challenge, just an update, as the entire "controlling infrastructure" is done:

800x425.jpg

Yes, I know, this is nowhere being slick, but it works:

Left row: Inputs. Blistering fast readings of both inputs and updating counters (2nd line). 3rd line = input bits numbers. 4th line = io_status byte, always up-to date.

Center row: Outputs. T=toggle outputs on/off upon pressing numbers 0 to 5; P=pulse outputs with keyboard rep rate.

Right row: Mode. So far simulation (checking any program operating a robot via 9750 without actually turning the output ports on), and serial work. Parallel is to be done.

Commands recognized so far are: T=mode "toggle outputs" when pressing 0-5, P=mode "pulse outputs"; X=select I/O mode (sim, parallel, serial, space bar activates mode), R=reset counters.

To be added: A ... G=User programs; corresponding subroutines are easily coded.

My guess with the weird Atari parallel port is, that a modified 9771 circuitry will do the trick. No need for address decoding; this is done in GFA BASIC by selecting LST: as output and input port (yes, the Atari can read the 8 bits of its parallel port - sweet! However, latching the Atari's parallel port 8-bit outputs is required; and I need to figure out what happens to the strobe line when the Atari is reading the port.

We'll see.

Best,
Thorsten 

Edited by Toastie

Share this post


Link to post
Share on other sites

"Major":pir-wink: update (for the 8-bit nerds only, of course) :pir-huzzah2:

Yesterday I got it to work. Interface A (9750) controlled by an Atari 1040 STFM from 1987 (PCB says so) via its - a bit weird - parallel port and with a little help of:

  1. a 1987 5V (+12V, not used) power supply I used back then for powering two 5 1/4" floppy drives I added to my Schneider Joyce (PCW9256 from 1991, (https://de.wikipedia.org/wiki/Amstrad_PCW) 
  2. a 74LS273 (https://www.ti.com/lit/ds/symlink/sn74ls273.pdf?ts=1692440430516&amp;ref_url=https%3A%2F%2Fen.wikipedia.org%2F) from >way< before 1990, used, most probably resurrected from an old computer - found that one "in the basement", well 10 of them.
  3. 8 x 2.2 kOhm resistors.
  4. optionally, 8 x 1 kOhm resistors and 8 x 3mm LEDs - just for program development, when you either don't have 9750 (which features corresponding LEDs) or want to program "offline"
  5. GFA BASIC 3.6 using only commands from GFA BASIC 3.0 from 1988. 

@evank: Are these conditions matching with the rules of the 9750 hacking challenge? If so, I'll prepare a full report on this :pir-huzzah2:

All the best,
Thorsten

 

Share this post


Link to post
Share on other sites

@Toastie this sounds good to me! I have an idea for a (shhhh!) secret project :classic: ... I'll send you a private message.

Edited by evank

Share this post


Link to post
Share on other sites

OK, full report is out :pir-huzzah2: in the Mindstorms Forum. No, I meant the Technic Forum, of course :pir-laugh:. Cross posting is strongly discouraged on EB, so I leave it with the link to that thread as it will drown there in a couple of hours

So this is my second entry for the challenge!

More importantly: When rummaging through my salvaged electronics parts and pieces, I found this:

640x297.jpg

As all of you know, this is a ZX Spectrum main board connector - in MINT condition! I have two Spectrums and did quite a bit of programming and made hardware additions for them back in the days, some 35 years ago. And recently ... so now that the Atari is done, I am considering to get one Speccy in touch with 9750. On the connector, there is everything: Address, data, control lines, power ... and I do still speak a bit of Z80 assembly ... hmmm.

The Speccy has a totally messed up address management, but that is so well documented, I'll find two unused I/O addresses ...

TLG endorsed system, as per @evank are:

  1. Apple II (CPU: MOS 6502, 8-bit)
  2. BBC Micro (CPU: MOS 6502, 8-bit)
  3. Commodore 64 (CPU: MOS 6510, a variant of the 6502, 8-bit)
  4. IBM PC (CPU: Intel 8086, internally 16bit, with 8-bit data bus)
  5. Philips P-2000 (CPU: Zilog Z80, 8-bit)

How many other non-LEGO endorsed systems from < 1992 were used for that purpose? I have added the Atari ST to this list, what else is there? There must be so many! The ZX Spectrum would be Z80/8 bit as well.

  1. Atari 1040 STFM (CPU: 68000, internally 32 bit, with 16-bit data bus)

All the best,
Thorsten

 

Share this post


Link to post
Share on other sites

I'm wondering about other systems such as the KIM and Ohio Scientific series (both 6502), TRS-80, and even an Altair.

Share this post


Link to post
Share on other sites

Hi Evan,

I studied the schematics of the Sinclair ZX Spectrum a bit and read some moldy magazines (the original paper versions, 1983-1985).

It turns out that 9771 with the help of a custom cable (Spectrum female card edge connector to female ISA BUS card edge connector) with no further electronics needed, should work well. All you have to do is getting the two connectors, solder that cable and that's it.

As I don't have another 9771 (and don't want to get that one card I have off from my XT), I can't try this almost pure LEGO approach. Would have been funny though when TLG had put 9771 into a slick (empty) black ABS box and then sold it off for crazy amounts of money to schools.

The native Spectrum BASIC has the command "OUT address, byte" and the function "byte = IN address". So we're all set.

Best,
Thorsten

Share this post


Link to post
Share on other sites

Lil' teaser :pir-laugh:

(I know, this audience is really small, but so is the world)

Finally, I got my Speccy to talk and listen to 9750. I tried the 8255 PIO first - total and utter failure - and then the 9771 approach on the Z80 bus - bummer as well. Why? 1) Stupid me. 2) - 9) see 1). 10) I need to edit the first post 9771/9750 thread regarding the decoding of 74LS373's - it is even better than I thought.

The ZX Spectrum is another computer (introduced 1982) now happily operating 9750. And yes, the magazine in the background is mine from 1984 and yes, this is a carved-out ZX printer case (with the 40 pin socket for the failed 8255 approach and a bread board in the back, along with 2 74LS373's and one 74LS02):

800x886.jpg

The coolest thing though is: I still speak a little Z80 machine code - and as said before, used to crack the copy protection of Spectrum games back in the days - in return for TTL chippies, people "had" to buy me :pir-huzzah2:

More to come.

#8bitisbetter!

All the best,
Thorsten

 

Edited by Toastie

Share this post


Link to post
Share on other sites

@evank

Hi Evan, all,

I believe having another entry for the 9750 hacking contest: The Sinclair ZX Spectrum, doing it with a little help of a couple of TTL chips from the late 1970's to mid 1980's. The Spectrum debuted in 1982; I got mine (the one now controlling #9750) in 1985. Should be all within the contest rules:

1280x540.jpg

(The 8 4.5V lamps signal a very important message ...)

Main post is in the Technic etc. forum, even with a stupid 20s video at the end:

Next thing to do is getting my ZX81 and #9750 together. Needs a little hardware tinkering again. Also ZX81 BASIC does not know OUT/IN, only PEEK and POKE, which means I need using the MREQ# Z80 CPU output instead of IORQ# (memory mapped).

All the best!
Thorsten

 

Share this post


Link to post
Share on other sites

@evank

Hi Evan, All,

just to keep things straight: As posted in the Technic etc. forum, I'd like to introduce another 8bit-wonder from the 1980's controlling (writing to and reading the outputs/inputs) the LEGO Interface A #9750: The Sinclair ZX81, which appeared in Germany in late 1981. I still have my "issue one" machine; fixed the power supply and 16kRAM pack in 2021. Two additional TTL chips were added to the ZX81 "main board" (well, it is only one board, and only a small one); the ZX Printer interface I made for the Speccy is fully compatible with the Zeddy's edge connector exposing the Z80 system bus:

1280x886.jpg

Top: Zeddy hooked up to the ZX Printer interface, which connects to #9750. Bottom: The Zeddy all set-up for playing with LEGO as well.

Here's the link to the main post - as usually with a 10s stupid video showing that the Zeddy actually speaks with 9750):

Here are my three contestants in this challenge in one picture; the monitor is hooked up to a 4-port video/audio switch shared by the three musketeers - and a C64, below the Atari. In the photograph, the Zeddy is hooked-up to #9750 and the screen shows that is had heard from Deep Thought:

1280x731.jpg

BTW, as said in the main post, there was this ad back in the days (1983); well here they are happy - and in color:

640x463.jpg640x392.jpg

All the best,
Thorsten

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.