AJB2K3 Posted Tuesday at 06:32 PM Posted Tuesday at 06:32 PM 17 hours ago, Bliss said: Hello all, So here it is, a first draft of an attempt to make my own Online Blockly programming environment for multiple Lego Interface B's. The requirements? Well no need to install any softwares like python etc but you still need: A Windows PC with Internet access (I don't know if this would work on a Mac, but for a Linux, why not?) A Chromium browser latest version (Chrome or Edge, I used Chrome) usb ports available with USB to RS232 adapters (qty depends how many Lego Interface B you want to try at the same time) Link to my Lego-Blockly page Example Projects to download It seems to work well with one Lego Interface. I can't test multiple. So if anyone could report please? Thank you in advance. On the TOP bar, Connect Lego interface B will open the serial port selector and connect. Once connected you should see LegoB1 - Active in the Device Area on the right. If you press again on Connect Lego interface and select another serial port, you should get LegoB2 - active. (NOT TESTED). Also, you have some logs in the Chrome Console Debug console. Use F12 to open Chrome Console. Check "Debug: Log Device Packets" to see all 19 bytes packets read from Lego Interfaces in the Chrome Console. It takes ressources, so do not leave this checked all the time. Save Project Button does not ask for file name. It saves to defaut file name with a number incrementing in your default download folder. Use the Load Project button to Load json file previously saved. I included an Examples folder in my GiHub that you can downloads and "Load". Please Connect you Interface before loading otherwise, the Device Slot in blocks will show No Device Connected... Press Run to execute a flow, Press Stop to end the program (if in a repeat true, this becomes handy) Press Clear to wipe out the Blocky area. It will ask for confirmation. On the Toolbox on the left, the 2 last category are my custom additions (Not part of the Blockly standard toolbox) The few examples I included in my Github should help to understand how it works. To test with 2 Lego Interface B's, once connected, you could load example LegoB_Out_Follow_Inp: And change the 2 Out block for LegoB2. So Touch Sensor on LegoB1 port 1 pressed, should Activate Output 1 (A) on LegoB2 and Deactivate when touch is released. I also implemented an Output Commands Cache that make sure not to send the same command more than once at a time. So in the previous example where an output follow the status of a touch sensor, we can also make the following Flow: Normally, this flow, when the touch sensor is NOT pressed, would send the command OFF to Output 1 (A) every 0.05 sec but the internal code cache the last command to each port so it sends a same command only once through serial. This allow more flexible coding like industrial PLC (Programmable Logic Controller) code with a scan time :-) There is no cache on Reverse command neither on the ON For Time command. Use those with caution if using the PLC type approach. No problem with Wait Until. BE CARREFUL with using repeat while true block, without the Wait until or Wait time Blocks, you will hang the page... This is a first draft as I said, I will probably add some blocks and features. Do not hesitate to report bugs. Special Thanks to Copilot for the Big Help Works great on chrome in OSX. Still waiting on my second interface Quote
Bliss Posted 23 hours ago Author Posted 23 hours ago I'm starting to have quite some fun programming my Lego Interface B with Blcoky lol. I'm also having lots of fun designing new blocks for more functionalities. So make sure to hard refresh the Lego Blocky web Page (Ctrl-Shift-R on Chrome in windows 11) once in a while to get the changes. Yesterday I added the One Shot Rising and Falling blocks in the Control+Wait Category. And I added the "NOT" block in the Logic Category. Also, I added in the github folder, some examples projects to load in blockly. If you intend to leave your blockly projects running for a while, do not forget to disable your power management or set it to "Performance" (Win 11) because, Power Saving mode de-activates USB ports... There might be some energy saving parameters in the browser as well but might be more important if you run on batteries... Stay tune for more Additions to the Blockly online programming for Lego Interface B (I'll also probably add eventually the RCX communication) Quote
AJB2K3 Posted 21 hours ago Posted 21 hours ago (edited) I wish I could understand bit masking because in my blockly it reads once then show the same value but in raw python it shows the changes in value. I got a second interface now just no mains to plug it in! Edit: Solved it, AI slop strikes again, There was some random code that was added by Gemini that was braking the sensor read but not just that, I defined the wrong port numbers! Edited 9 hours ago by AJB2K3 Quote
Gunners TekZone Posted 9 hours ago Posted 9 hours ago (edited) OK, I finally jury rigged a 3 device multi-Interface-B setup. I rarely use block type programming but it is simple enough, so I successfully toggled ports one ON and OFF, in alternating fashion, on LegoB2 & B3 with each button press on LegoB1. I have noticed that if one of the interfaces is temporarily disabled (due to loose serial connection) then everything stops. Stopping and restarting the sketch will not work. It requires disconnecting/reconnecting ALL Interfaces in order to get back to operational condition. And in the case of one of my Interface-Bs, whenever there is a device issue, even if it is a different one, it throws a BufferOverrunError: And I have to physically disconnect and reconnect it on the USB hub, else it usually connects as the next device number up (AKA LegoB4 when it is normally B3). But as that particular Interface-B is one that I surgically replaced it's internal Serial circuitry with an internal TTL/USB device... who knows... it might be a bit quirky? I'll have to swap them around and see if this issue follows the device or stays with the last one connected. Anyhow, that is all I can work on tonight. And @Bliss I will probably DM you with further troubleshooting posts for the time being, and limit my public posts re: this testing, for more relevant announcements. Edited 9 hours ago by Gunners TekZone 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.