maehw Posted February 26, 2024 Posted February 26, 2024 (edited) Hi all, I never had an RCX when I was young back then when the first Mindstorms generation was release (1998), but these days I have got me some hardware to play with. I have this idea of reviving the yellow LEGO Mindstorms RCX brick. I've researched the web and found that most people will either set up a Windows Virtual Machine with an old version and run the original LEGO RIS RCX Code IDE or use a Windows Machine and use Bricx Command Center (BricxCC) and program in NQC. However, there seem to be issues with Windows 64-bit drivers for the LEGO USB IR tower. ("That beautiful communication hub for all RCX1.0, 1.5, 2.0, Scout, Spybotics, MicroScout, CodePilot bricks one is truly dead since 64 bit operating systems have taken over." - @Toastie, 2018) People have been using the LEGO serial IR tower instead or done something on their own (e.g. tinkering with hardware and Arduino code to get their own DIY IR tower working). Tired of setting up those Windows machines? Not all people have the knowledge to hack around with things... or try alternatives like running an NQC compiler from Linux or Mac OS. So.. I came up with the idea of... Programming the 1st generation LEGO Mindstorms RIS (yellow RCX brick) from the webbrowser What follows is a technical block diagram of the toolchain to accomplish this. The idea is to compile NQC code in your webbrowser and to download your compiled code to the RCX where it is executed - without any installation. We may even think out of the box and imagine block based programming with Blockly (you know Scratch? you're familiar with Blockly) and generating NQC code... Of course, there are some technical shenanigans required here, but I have proof that the basic concept is feasible: NQC compiler can be compiled as Web Assembly (WASM). See also: https://github.com/maehw/WebNQC(this should run in every modern browser) The actual relevant bytecode chunks from LEGO's proprietary .rcx file format can be extracted.(thanks to NQC's RCX library; also thanks to LEGO for documenting the opcodes) The bytecode chunks (tasks/subroutines, etc) can be downloaded to the RCX brick using a IR serial tower (infrared serial link). This can be accessed with JavaScript in webbrowsers like Chrome, Edge and Opera (unfortunately not Firefox) using the Web Serial API.(thanks for everybody working on that before, especially also BricxCC which allowed me to sniff on the communication; and also LEGO for documenting the protocol) The WebUSB API is a thing, so we may also get this wokring with the LEGO USB IR tower. I've also worked on a low-cost DIY IR serial tower that consists of a an IR LED, an IR receiver, an 8-bit microcontroller, some current-limiting resistors and two LEDs (power, activity), wires + a breadboard (of course, this could be a tiny PCB) + a USB/TTL UART converter (cable) for around 10 € (see thread on Mastodon, continued there): (No 9V battery required, it can be powered by 5V VCC (and probably alternatively also 3.3V) from the USB/serial converter. And only the default driver for the USB/serial converter. You can probably also use this "hardware frontend" part with your Arduino, Raspberry Pi or other embedded hardware... as it simply connects to a TTL serial/UART) I've so far been able to: Program the firmware (.lgo files in Motorola S-record file format (SREC)) using my DIY IR serial tower with the command line utility firmdl3 (disclaimer: all transfers only work reliably using 2400 baud) Program the firmware using my DIY IR serial tower from the webbrowser (Web Serial API) Remote control the RCX from the the webbrowser (using Web Serial API), like playing sounds, reading ROM/firmware versions, ... - everything is possible Run the NQC compiler in the webbrowser - to compile NQC code (.nqc) into RCX image binary files (.rcx) Download programs using my DIY IR serial tower from the webbrowser (again Web Serial API) This should work platform-dependently... on Windows, Linux, Mac OS.. probably also Android (haven't tried to plug the DIY IR tower via an USB OTG cable). If I see interest in any of this, I might keep working on it - and maybe set up a demo website so that you don't have to compile these things locally and run them on a local webserver (which I guess is the current barrier to entry). This looks very technical and ugly, but could get a nice UI. (Take another peak here, here and here.) Feel free to ask, if you'd like to get more insights. You have hacked around with the LEGO RCX in those last 25 years? I'd be keen to know! If you have any cool RCX projects (.rcx files or .nqc files lying around, model build instructions, sensor reverse engineering, ...) that I should try, let me know! (I also have ideas about "decompiling" old .rcx files into NQC code... and optionally Blockly in turn.) You have other ideas? Sure, share them with me! Edited April 22, 2024 by maehw Added the URL/project name to this post's title Quote
maehw Posted April 14, 2024 Author Posted April 14, 2024 (edited) Hi all, my last post may have been very technical - maybe too technical? I am happy to announce that I've just released version 0.1.0 of the web-based IDE which I called WebPBrick. I'd be happy to see people explore the IDE here: https://webpbrick.com/ide/ As the project is open source, you can also find the source code on GitHub: https://github.com/maehw/WebPBrick README? Try this one: https://github.com/maehw/WebPBrick/blob/main/CHANGELOG.md CHANGELOG? Try this one: https://github.com/maehw/WebPBrick/blob/main/README.md The LEGO Serial IR Tower should work out of the box - unfortunately, I am still having difficulties with the LEGO USB IR Tower. It would be cool if you could help me spread the news about WebPBrick! Cheers Edited April 14, 2024 by maehw Quote
mar11 Posted September 14, 2024 Posted September 14, 2024 (edited) First of all! Many many thanks for what you are doing, I was looking for such easy tool to RCX for a long time. So far I have an issue with connecting to my Serial IR tower(This one that come with 9V battery) I am using 9pin to usb cable adapter to connect it with my computer, but it doesn't work. Do you have any ideas? Will it be possible in near future to connect USB IR Tower as well? Edited September 18, 2024 by mar11 Quote
Toastie Posted September 15, 2024 Posted September 15, 2024 Damit! This thread - as per usual - just drowned in the "Technic" forum. This is simply - bad. Either one pays attention every hour to new entries on this forum - or such entries are simply swamped with TC's, super duper cars, trial trucks, whatever. Man. I need to catch up on this @maehw!!! Thank you very much for sharing! Best wishes, Thorsten Quote
mar11 Posted September 17, 2024 Posted September 17, 2024 (edited) I bought new Serial to USB adapter and now i can connect to WebPBrick. Unfortunately now I can't download firmware as it stops after a few seconds - it always stops at different block number: Connected to serial device (baudrate: 2400).🔗 Communication working, RCX is alive!ℹ️ ROM version: 3.1, Firmware version: 0.0❌️ Firmware version '0.0' indicates that currently no firmware is loaded into RAM. Firmware download request confirmed. 🧮 Firmware size in bytes: 24944 Firmware size exceeds 19 kBytes. Limited checksum calculation to first 19 kBytes. 🧮 Calculated firmware checksum: 0x2F8E 🥾 Entered boot mode.🐌 Began firmware download... 🧱 Calculated 1248 firmware blocks to download.⏳ Successfully downloaded firmware block 1/1248 (0.1 %)⏳ Successfully downloaded firmware block 2/1248 (0.2 %)⏳ Successfully downloaded firmware block 3/1248 (0.2 %)⏳ Successfully downloaded firmware block 4/1248 (0.3 %)⏳ Successfully downloaded firmware block 5/1248 (0.4 %)⏳ Successfully downloaded firmware block 6/1248 (0.5 %)⏳ Successfully downloaded firmware block 7/1248 (0.6 %)⏳ Successfully downloaded firmware block 8/1248 (0.6 %)⏳ Successfully downloaded firmware block 9/1248 (0.7 %)⏳ Successfully downloaded firmware block 10/1248 (0.8 %)⏳ Successfully downloaded firmware block 11/1248 (0.9 %)⏳ Successfully downloaded firmware block 12/1248 (1 %)⏳ Successfully downloaded firmware block 13/1248 (1 %)⏳ Successfully downloaded firmware block 14/1248 (1.1 %)⏳ Successfully downloaded firmware block 15/1248 (1.2 %)⏳ Successfully downloaded firmware block 16/1248 (1.3 %)⏳ Successfully downloaded firmware block 17/1248 (1.4 %)⏳ Successfully downloaded firmware block 18/1248 (1.4 %)⏳ Successfully downloaded firmware block 19/1248 (1.5 %)⏳ Successfully downloaded firmware block 20/1248 (1.6 %)⏳ Successfully downloaded firmware block 21/1248 (1.7 %)⏳ Successfully downloaded firmware block 22/1248 (1.8 %)⏳ Successfully downloaded firmware block 23/1248 (1.8 %)⏳ Successfully downloaded firmware block 24/1248 (1.9 %)⏳ Successfully downloaded firmware block 25/1248 (2 %)⏳ Successfully downloaded firmware block 26/1248 (2.1 %)⏳ Successfully downloaded firmware block 27/1248 (2.2 %)⏳ Successfully downloaded firmware block 28/1248 (2.2 %)⏳ Successfully downloaded firmware block 29/1248 (2.3 %)⏳ Successfully downloaded firmware block 30/1248 (2.4 %)⏳ Successfully downloaded firmware block 31/1248 (2.5 %)❌️ Download error during block #32, retrying... Edited September 18, 2024 by mar11 Quote
maehw Posted September 22, 2024 Author Posted September 22, 2024 (edited) Thanks @Toastie! It seems that I don't have forum post notifications active. Hey @mar11, thanks for trying! Great that you made an attempt and tried WebPBrick! Have you tried to cover the infrared connection (e.g. by a sheet of paper)? I guess that you are in a "noisy" environment regarding light emissions. You can also play around with distance and angles. The mechanism is not very robust at the moment - however there should be a retry mechanism implemented. But maybe that one is not robust enough and should allow for even more retries. Hope to hear from you again. Cheers! Edit: PS: I had little progress with the USB IR tower. IIRC, you can checkout the git repository and try https://github.com/maehw/WebPBrick/blob/main/src/communication/webusb.htm. It seems that I am losing some data here. I need someone to team up with me as it gets pretty tedious and frustrating working alone on it. Edited September 22, 2024 by maehw Quote
Bliss Posted Tuesday at 08:18 PM Posted Tuesday at 08:18 PM (edited) @maehw, I just discovered your work here. That is great! I tried both Blockly NQC and WebPBrick IDE. Is it me or there is no "UNTIL" in the blockly? in NQC, I had the following line: until(Message() == 11 ); . And I do not find a matching block for until. I had to use repeat until which is not the same... Edited Tuesday at 09:09 PM by Bliss Quote
maehw Posted Tuesday at 08:55 PM Author Posted Tuesday at 08:55 PM Hi @Bliss, thanks for your reply! There's not a broad user basis... so I haven't gotten too much feedback so far. Thanks for letting me know. About `until`: Yes, there's the block `repeat while/until <condition>`: You say "And I do not find a matching block for until. I had to use repeat until which is not the same... " - in my understanding, it is. You simply leave the loop's body empty. But yeah, we could add another block that does not provide a loop body... so that you cannot plug something in here (you don't have to, though). Also, from the NQC documentation: NQC also defines the until macro which provides a convenient alternative to the while loop. The actual definition of until is: #define until(c) while(!(c)) In other words, until will continue looping until the condition becomes true. It is most often used in conjunction with an empty body statement: until(SENSOR_1 == 1); // wait for sensor to be pressed It seems that my BlockNQC generator does not make use of that macro. Out of curiosity, I've thrown both versions into WebNQC: task main() { while (!(Message() == 11)) { } } task main() { until (Message() == 11) { } } They both compile to the same byte code (which totally makes sense as a macro will be replaced by the preprocessor already): ↪️ nqc version 3.2 r2 (built Jul 5 2024, 02:23:32) ↪️ Copyright (C) 2005 John Hansen. All Rights Reserved. 🕵🏻 Compiled NQC code successfully using WebNQC. 🕵🏻 Binary output length: 41 🕵🏻 Binary output as HEX: 0x52 0x43 0x58 0x49 0x02 0x01 0x01 0x00 0x01 0x00 0x03 0x00 0x00 0x00 0x0E 0x00 0x13 0x07 0x02 0x07 0xE1 0x87 0x95 0x82 0x0F 0x0B 0x00 0x00 0xFA 0xFF 0x00 0x00 0x00 0x00 0x05 0x00 0x6D 0x61 0x69 0x6E 0x00 🕵🏻 Compiled NQC code successfully using WebNQC. 🕵🏻 Binary output length: 41 🕵🏻 Binary output as HEX: 0x52 0x43 0x58 0x49 0x02 0x01 0x01 0x00 0x01 0x00 0x03 0x00 0x00 0x00 0x0E 0x00 0x13 0x07 0x02 0x07 0xE1 0x87 0x95 0x82 0x0F 0x0B 0x00 0x00 0xFA 0xFF 0x00 0x00 0x00 0x00 0x05 0x00 0x6D 0x61 0x69 0x6E 0x00 There's at least one other user - a teacher from Brazil - who's trying to get the serial communication working. They've been trying to build the DiyIrTower. I guess you're using the original LEGO IR Serial tower + the adapter, right? Two things you can do: - Try https://test.webpbrick.com/ide/index.html and see if it behaves differently - Go to browser tools > web developer tools and inspect the console log. Those provide very detailed communication logs, i.e. every transmitted/received messages with all their bytes. This may help... however also consume a significant amount of time to narrow this down. It may be a problem with the USB/serial adapter picking up some noise... leading to UART framing or parity errors. But it could also be something else (UART timing?). The firmware download currently isn't very stable, unfortunately. I think the same retry mechanism as the one of Bricxcc should be used as it seems to work very reliably. Thanks for trying out this project! :) Quote
Toastie Posted Tuesday at 09:04 PM Posted Tuesday at 09:04 PM @Bliss and @maehw the moment I have time to breathe, I am very happy to jump on all this. My problem is sort of looking (not yet trying) a moving target type thing. Just to be sure: Your web versions do naturally change over development time (which can surely be eternal ;) but I just use a browser (Chrome, correct?) and access the corresponding websites, and I am good to go. Is that true? Do any of you envision a downloadable "program" to use it web independently? Sorry for being such an ignorant. All the best and thank you for all your efforts!!! Thorsten Quote
maehw Posted Tuesday at 09:17 PM Author Posted Tuesday at 09:17 PM 7 minutes ago, Toastie said: Your web versions do naturally change over development time (which can surely be eternal ;) but I just use a browser (Chrome, correct?) and access the corresponding websites, and I am good to go. Is that true? Do any of you envision a downloadable "program" to use it web independently? You're right. But this is basically only a static website. So you should totally be able to run this locally if I currently don't miss anything. But the idea here was to have a tool working in a web browser - so that it's OS independent aka cross-platform. A driver behind this was curiosity for the "new" technology behind it (WebSerial, Web Assembly/ASM and theoretically WebUSB). But: this technology also has its drawbacks because its requires a browser supporting these technologies and for WebSerial this seems to be limited to Chromium-based web browsers. And Chrome is some Google foo. Code is FOSS on GitHub - see feel free to download, modify, etc. -- https://github.com/maehw/WebPBrick (might move or be mirrored to Codeberg some day). And yeah, there's a version hosted by myself which runs under the domain webpbrick.com -- and there's no guarantee for that service to exist forever. Afair there's another user trying to build a universal pbrick tool in Python but I haven't looked at it yet. Quote
Bliss Posted Tuesday at 09:18 PM Posted Tuesday at 09:18 PM (edited) About my problem with the Serial connection, the port with the CH340 adapter was already opened with my other web serial project... So the CH340 adapter is working just great and I manage to use web pbrick IDE to download the program to the RCX successfully. The prolific adapter for some reason gives me problems but anyway, I use it now for the Interface B. It would be neat to have a wait until block but the repeat until empty loop is working very well. That's too bad not much people use RCX anymore cause web Blockly RCX makes programming the yellow brick so much easier and intuitive and time saving! I think Interface B is even less popular now and I feel a bit lonely sometime :-) while developping drivers and IDE for it. Some website are "installable" when you see at the right of the address bar this icon: . This is not the case with @maehw websites and neither with my blockly project. I'll look after what it takes to make a website "installable"... Thanks @maehw for this great peace of work! I will look at your code as I want to have a bottom bar like yours :-) Edited Tuesday at 10:42 PM by Bliss Quote
AJB2K3 Posted Wednesday at 06:04 AM Posted Wednesday at 06:04 AM (edited) This Is the problems I found with my cross platform offline version. Trying to build the online version ment rolling out webusb which has its issues. @Bliss Thats why I chose to only open the port when running code otherwise you get access blocks/crashes. As bliss once said, my version is a dependency nightmare as its built for python and trying to find and install the correct dependencies in a pain and only getting worse as I add more function. In order to access the devices I am using both pyserial to access devices using a USB adapter but then have to use a the low level pyusb to access devices using PID and VID USB devices as they don't have working USB drives. A point of note about the Wedo1.0 hub - Apparently it doesn't act as a typical serial device but instead acts as a USB HID device. Even with the dependencies and knowledge I still cant get the USB tower to operate. Edited Wednesday at 06:05 AM by AJB2K3 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.