Jump to content

Bliss

Eurobricks Citizen
  • Posts

    184
  • Joined

  • Last visited

Everything posted by Bliss

  1. Well, my mind have seen first a flower but it would have been grey, maybe it would have seen a gear ;-) I made a BIG change for the output port letters haha. (Not that big after some digging). Thanks @Gunners TekZone for "insisting" haha. I also think it is better that way and also, it does not affect at all the possibility to use variables and numbers.
  2. That's about it. An Android phone or tablet using wifi to access my Lego Blockly Web Page with chrome and use the BT to RS232 adapter that makes com port available to the phone. The BT to RS232 is plugged to the Interface B. On the web page, then press connect and select the com port from the BT adapter and it will connect to the Interface B. This has to be proven to work on Android. IT IS WORKING ON MY LAPTOP (Win11) that has BT... I will have an android phone to test this Sunday. Can it do Multiples Interface? I guess so if you have multiple BT to RS232 adapter :-)... Here is my DIY BT to RS232 adapter that works with my PCs... You probably have all components except the BT to TTL maybe (HC-05 or alike, this one is a JDY-31-SPP) The RS232 port of the TTL-RS232 adapter goes to the interface B. That eliminates the USB/RS232 adapter plugged to a PC. It make the Interface wireless somehow but the program is still running on a PC, not an ESP32 like the last year project... But I di not test it for very long with my PC and I don't know if this wireless method is reliable...
  3. I was being asked on github by @Wapata if this would work on an android phone or tablet... iPhone do not allow webserial :-( So, for Android, I read that it could work with a USB OTG Adapter (On The Go) + Serial USB/RS232 adapter but they also say there are limitations... But google also say that could work better with a Bluetooth to RS232 passthru adapter... I do not have a complete BT / Serial adapter But I found out I ordered in 2023 some BT FTDI board like HC-05, JDY-21 etc... And for the ESP32 project to hook to Interface B, I had to get some TTL to RS-232 adapter... I got some spare too... So I connected the BT / Serial TTL to the TTL - RS232 adapter to make a BT / RS232 adapter and plugged the RS232 port to the Interface B. I opened the Add BT Device on my computer and saw the JDY-21 device and paired it (passkey is 1234 with these little boards). This automatically added Com ports... So in my Blockly page, I click connect, and select the COM Port generated by the BT / Serial board and to my surprised it worked! So I was able to control the Interface B Wireless through BlueTooth! I'm gooing to borrow some old Android phone from my nefew Sunday and let you know if it can work from an android device with chrome and BT...
  4. @Gunners TekZone, you could use letters for output if you can't live without it by creating variables... or The last example is here: https://github.com/BlissCA/lego-blockly/blob/main/Examples/legoB_OutLetters.json
  5. Hello @Gunners TekZone, and thanks for testing. Blockly is very EASY but still need some training :-) I'm using the official Blockly source V12 from google which has been transfered to RaspberryPiFoundation... I do not want to use labeling A, B, C, for outputs because with numbers, it allows to easlily use a variable in a loop. For example: To check of input is off, you can use a NOT in the Logic category. And by the way, on the IF block, there is a small Blue flower like icon on the top left corner., you can click on it and from the window that appear, you can add ELSE and ELSIF to your IF Block. You will also find One Shut Raising and Falling blocks in the Category Control that can make better programming... For example: This program will continuously print input is off while Input 1 is not pressed. It will continuously print input 1 is ON while pressing the touch sensor. This program will print the touch sensor status only once on every change. By the way, You can check the status of the Red Stop button on the interface B using Input 0:
  6. Hello, I added some communication error proofing, better Device name re-allocation etc... that should take care of some behaviors observed by @Gunners TekZone. I cannot test multiple Interface B but if a program is running and one device disconnects by itself, it should stop the program, clear the device and let the other good device connected. It should allow you to reconnect a device using the Name that was previously freed up... Let me know. P.S. I also added some multi port output command blocks... https://blissca.github.io/lego-blockly/index.html
  7. ESP32 boards have often different FTDI chips that requires different drivers. Sometime I even had to revert to older driver version... So web serial with ESP8266 and ESP32 boards can be painfull sometime. With my interface B, I do not have any serial disconnection from web serial using a very good USB/Serial adapter. (I have another one adapter I bought from local electronic store last year and I did not yet succeeded to maintain a reliable connection with it no matter if it's from the web or not). At the moment, I'm using Win11 on a I7 14e gen small form factor Lenovo Thinkcenter. I have 2 chrome instance with multiple pages opened on each. Everything runs smoothly. But the Idea here is to have an environment easy to use with NO big installation needs and get you up and running with your old interface B project in no time. For me it looks pretty solid but I know I have good hardware (I7 14e gen, Interface B, USB Adapter). So it's reliable for me to have great fun for sure. I do not expect it to be a plateform to make projects that must run 24h/day 365D/year... But if it fails more dans 2 times per hour, it is not acceptable for me either. Now, for multiple interface, the reliability has to be confirmed. Also I wonder if the CPU capability may be a factor... @Gunners TekZone , can you describe the hardware you use (PC CPU, OS version, )? And can you test with 2 interfaces only and see if keeps running for a while without fails?
  8. @Gunners TekZone, Thank you for your help testing multiple Interface. We now need to determine if the lost of interface(s) is due to unstable hardware of if it is caused by the limitation of running in a browser window. With only one interface here, I let it run for few hours without problems. I had as I said to disable power saving on the computer of course... the Stop button stops the running program, it does not disconnect. But when you press stop, it tells you in the status window that it does stop the comm. with the Devices... If the comm fails by itself somehow, you have no choice other than press the disconnect all to clean everything and use the connect again. (Disconnect resets the numbering of device name to 1 like LegoB1) The connection must pass though the web serial connect popup window. I will still look if there could be some improvement on this side. But the best is to use healthy interface(s). ALSO Very important, if you use Repeat Until TRUE loop, YOU MUST use a Wait Time inside the loop (generally at the end) like Wait 0.05 sec. Otherwise, you MAY hang the page and communications will eventually fail. (However, I did some output caching to avoid sending same commands consecutively... So this should avoir the com port flooding)
  9. Hello all, By the way, just to let you know, I updated the thread: I added a full online Blockly interface for the Lego Interface B (It's suppose to be multiple interfaces but not tested as I do not have 2 Interfaces). You only need a PC Windows, or Linux, or OSX with a chromium browser, USB port(s) with serial adapter and Interface B. NO python, No C++, No special addons, extensions, etc... It's fully working from the browser. I'm looking for a tester that has multiple interfaces to try this online blockly :-) . Thank you!
  10. 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)
  11. 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
  12. In Thonny, throwing your four lines in one shot will work. But in windows command prompt, Python3 command to enter the Python prompt, if I do the same, those four line all together, it will not show the inp(1).val. But executing one line at a time will. Inp(x).yyy are properties... Not methods. I just happened to try python command prompt in a DOS window for the first time lol. Always used the prompt in Thonny directly. In Thonny, I can see that it is using Python 3.10 by default. In the Command Window, it's Python 3,14 and I see that it does not behave exactly the same. The .close() method does not seem to close everything properly. I'm goint to have a look to this and update... EDIT: Finally I just removed the __del__ method in legob.py... I updated in dropbox and github.
  13. @Toastie, I'm a very persitant person and before I abandon a project, it takes a lot and I admit that @AJB2K3 solution is not obvious to install. I kept going because I have spare time these days. There are lot of dependencies Python, QT6, Node.js etc... Not for the faint of heart. But it's in early development so I don't know. And maybe an install pkg or executable (.exe) may be done out of this? Because for now, it's not easy to implement. Blocky programming is easy to learn, cause it's visual, but if you want to make a serious project with many Interface B, it can become ugly. I still believe that Direct Python with LegoB and LegoRcx Module is the easiest. But I saw the JavaScript project of a Member in the Lego ControlLab thread and I thought that it could be intersting to have an IDE to program Lego Bricks directly from a website, with NO Install required. Well, you still need a PC, Serial Adapter, and... Internet (Chrome or Edge only). So I thought it might be possible to integrate Lego Int B to known online Blocky alike tools like Scratch, Microbit, Snap!, MBot... But after evaluating and even tried with Snap!, I abandonned and started my own web based blockly project. I hope to be able to present a draft very soon. I'll need some beta tester ;-) Since I have only one RCX, and one Lego Interface B. (It supposed to be Multi interface). At the moment, the communication with continuous reading of the 19 bytes packets runs well from the browser javascript but I don't know how it is going to be with multiple interfaces...
  14. Thanks @AJB2K3, I just tested with the Lego Interface B, not the RCX and it is connecting, and I used the motor A forward and it is working. But the whole interface B stops by itself after few seconds. I guess you did not implement yet the Keep Alive... It looks promising. Needs more function blocks like timers etc.
  15. It starts better now, I can see the white area in the IDE and the Grey Bar on the Left side but when I click on an item on the left bar, like INTERFACE_B or SIMPLE RCX etc, I get errors in the cmd window: When I click on INTERFACE_B: js: Blockly.Workspace.getAllVariables was deprecated in v12 and will be deleted in v13. Use Blockly.Workspace.getVariableMap().getAllVariables instead. js: Uncaught TypeError: Invalid block definition for type: interface_b_init when I clicked in the white area: js: Uncaught Error: FocusManager state changes cannot happen in a tree/node focus/blur callback. When I clicked on SIMPLE RCX: js: Uncaught TypeError: Invalid block definition for type: rcx_init Clicked on PYSERIAL: js: Uncaught TypeError: Invalid block definition for type: serial_close Clicked on LOOP: js: Uncaught TypeError: Invalid block definition for type: wait_seconds Clicked on LOGIC and MATH, TEXT, VARIABLES does not give errors and I can wee some blocks on the right... But eventually, after I clicked many times on the ones that gives error I get no matter on what I click: js: Uncaught Error: Block not present in workspace's list of top-most blocks.
  16. @AJB2K3, I think I got all requirements alright Python 3.14, QT6, pySerial, Node.js. In the Command Windows that I run as an Admin, after I lunch the Python3 main.py, I get the following message: js: Uncaught ReferenceError: QWebChannel is not defined. In the Index.html, you have: <script src="javascript/qwebchannel.js"></script> <script src="javascript/blockly_compressed.js"></script> <script src="javascript/blocks_compressed.js"></script> <script src="javascript/python_compressed.js"></script> <script src="javascript/en.js"></script> <script src="blocks/blocks.js"></script> <script src="blocks/generator.js"></script> <script src="javascript/app.js"></script> but qwebchannl.js, en.js are not in the javascript folder. blocks folder does not exist in your project on github. However I can see these missing blocks folder is in the ULI.zip that is present in you main github project. I don't think it is the proper way to use github as the main code project should be the one up to date... But I can't find the location of en.js and qwebchannel.js... Archive.zip seems to have all needed files though?
  17. In your github, I clicked on <> Code and selected Download Zip which downloaded a file named ULI.ZIP which contains all you MAIN project folders and files even some zip files like uli.zip and archives.zip which I do not need... So this does not work in windows 11 latest python 3.14. But I guess the idea will be to access you IDE from the Web eventually? I tried to open the index.html into a browser (Chrome) and the IDE appears too but the IFACE_1 always shows "Scanning..." and the combo box has nothing inside. Actually there should be a "Connect" button that opens the webserial popup to select a com port...
  18. @AJB2K3, I tried to run you project (Python3 main.py and have encountered many problems like having all the dependencies installed like PyQt6-WebEngine etc. So now I have a window that appears but I don't have the white area and grey menu bar on the left as in your screen caps. On the right, I do have the Interface and port scanning etc but this does not work and sometime, when I click the combo box, which I guess should present a list of com ports, shows a white area that grows infinitely. But it does not show any ports. Am I missing something? I'm on Windows 11. Thanks
  19. I finally created 2 gitub repo's for the "PC" version of the Lego IntB and RCX python modules and examples. I added the link to these repos in the first post of the thread: Lego RCX, Int B Programs I might as well create some Repo's for the ESP32 Mycropython eventually
  20. I tested few sync logics with the checksum to see it can recover from desync and it does not work all the time depending on input values (if all zeros for ex). So it is not perfect unless someone has a better algorithm that works in every situation. So the best according to me is to ensure we have enough processing power to never miss a stream of data :-)
  21. It is bit 4 indeed. 0x10 or binary 00010000 for the red stop button status.
  22. @AJB2K3, I fixed the legorcx.py in the dropbox and updated the readme as well. Now you can just issue the command r.LastCmdSerStr. No need to use print(). Example: >>> r.mot(r.A).pow(6) >>> r.LastCmdSerStr() b'\x55\xff\x00\x13\xec\x01\xfe\x02\xfd\x06\xf9\x1c\xe3' >>> r.snd(2) >>> r.LastCmdSerStr() b'\x55\xff\x00\x51\xae\x02\xfd\x53\xac' >>> r.mot(r.A).on() >>> r.LastCmdSerStr() b'\x55\xff\x00\x21\xde\x81\x7e\xa2\x5d' >>> r.mot(r.A).off() >>> r.LastCmdSerStr() b'\x55\xff\x00\x29\xd6\x41\xbe\x6a\x95'
  23. @AJB2K3, indeed, something in my code, l'll try to fix and let you know... Thanks for the report.
×
×
  • Create New...