Jump to content

Bliss

Eurobricks Citizen
  • Posts

    173
  • Joined

  • Last visited

Everything posted by Bliss

  1. 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.
  2. @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...
  3. 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.
  4. 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.
  5. @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?
  6. 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...
  7. @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
  8. 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
  9. 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 :-)
  10. It is bit 4 indeed. 0x10 or binary 00010000 for the red stop button status.
  11. @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'
  12. @AJB2K3, indeed, something in my code, l'll try to fix and let you know... Thanks for the report.
  13. I updated LegoRcx.py in the Dropbox link. I just added the LastCmdSerStr that you can use to print the last Serial Command String. Example: >>> from legorcx import RCX >>> r=RCX("COM17") >>> r.snd(2) >>> print(r.LastCmdSerStr) b'\x55\xff\x00\x51\xae\x02\xfd\x53\xac' >>> r.snd(2) >>> print(r.LastCmdSerStr) b'\x55\xff\x00\x59\xa6\x02\xfd\x5b\xa4'
  14. Hello @AJB2K3, I'm glad you managed to do something with the python module LegoB.py. This is my prefered way to make programs in a modern PC that communicate with Interface B. I used the dacta driver from Steven Shamlian and adapted it to the latest version of Python. His web page also has links (some still working) to old reverse engineered information about the byte protocol of interface B. https://www.shamlian.net/projects/dacta/ However, I think I prefer more to use an ESP32 microcontroller with micropython. It makes the Interface B an almost standalone solution. And with the wifi capability of ESP32 and the MQTT client, it makes the Interface B able to join IoT platforms...
  15. Just added the UIFlow2 Blocky version for M5Stack Devices in the drop box (Link also in post #1). I tested only on M5 Core2 ESP32 device. Not fully tested and it was very painful to make the custom block... Also, I find the blocky can be very ugly sometimes. UIFlow2 demo project LegoInterfaceB.m5f2 and also the Custom Block for Lego Interface B driver Lego9751.m5b2.
  16. I removed the "plc" version and replaced it with LegoB micropython V2 folder. I updated Post #1 too. Lego Interface B MicroPython ESP32 V2 Now I use MCU Timers for both the keep alive and Inputs Byte Frame readings... Using Timers creates constant periodic interrupts. (There are 4 of these Timers available on the ESP32) (Should have done this before...) So we can do slow sequences or non blocking fast logic (like an industrial PLC). The V2, i believe, is the simplest to use and I hope, the most stable version of the MicroPython ESP32 Lego Interface B driver. UPDATE 2025-02-05 9h47: I left the V2 running overnight with the MQTT demo and when I checked this morning it was stopped with an OS Error (Error from the umqtt.simple)... ESP32S3-zero mcu... (It seems stable with no mqtt demos) I will let the V1 running the whole day with its MQTT demo... UPDATE 2025-02-05 20h38: I left V1 MQTT demo running all day and no fail but maybe this version of mqtt has some auto reconnect feature. I'm trying LegoB V2 again since few hours with the umqtt.robust rather than umqtt.simple and it does not fail, but robust version of umqtt uses the .simple with some auto reconnects on fail... UPDATE 2025-02-06 01:06: The LegoB V2 eventually failed. Now it was a Checksum mismatch lf the LegoB continuous inputs reading... I suspect that when there is mqtt.robust auto reconnects, it takes ressources and bothers to reading on serial... idk... Anyway, I made (and uploaded in dropbox of the LegoB V2) another mqtt demo (demobv2_mqtt_2.py) that uses the same "mqtt_as" library that I used for the V1 LegoB. Now let's see if the LegoB V2 demobv2_mqtt_2.py will run overnight with no fail... UPDATE 2025-02-06 11h47: LegoB V2: demobv2_mqtt_2.py has run overnight no fail... This mqtt_as library is really solid...
  17. @Gunners TekZone I found out that the IoT MQTT app on the phone allows to backup the configuration. So, I just uploaded a backup (json) of my IoT MQTT Panel configuration. You will still need to configure your broker info. I don't know if the backup will work on an Android phone though...
  18. Indeed in every demo programs I offer, there are few settings to change (Described in the README). tx rx pin in the lego.start method and for the mqtt demo, the ip address of the broker. In addition, the secret.py should be updated as well for using the network features (MQTT and WebREPL)... If someone does not not need the network at all in his project, he does not need to replace the boot.py file and he only needs to copy the legob.py and his project file like demob.py or demob02.py that's all. No need to copy the boot.py, the lib folder, secret.py etc... The phone app IoT MQTT Panel is really just another alternative for those who wants to have a nice UI (User Interface or HMI Human Machine Interface) to control their Lego Interface B outputs from their phone a bit like the https://www.controllab.io/ which is using a webbrowser... I found myself this IoT MQTt Panel app very easy to setup and fun to play with. But since IoT MQTT panel is configurable, it is more flexible. You can also make Home Assistant Dashboard and custom "Cards" etc. Many solutions. Node-Red is great to test and make programs to interact between IoT devices... It a favorite for many in the IoT world. I update the demob_mqtt_v2.py to make all sensors avail to mqtt. I also put comments at the beginning to describe the topic to use. EDIT 2025-02-02 17h16: I made a correction in the demob_mqtt_v2 for the reset of rotation count and I also uploaded a demob_mqtt_plc_v1.py in the LegoB "PLC" version folder... The demob_mqtt_plc_v1 file uses the built-in umqtt.simple since there is no asyncio in this version... We'll see if it runs reliably... Have fun!
  19. ESP32 devkit are still the best. very stable. I like also the mini version of the ESP Wroom 32... The webrepl is really to use the Wifi to access the "Shell" so you can access remotely with no USB link to your ESP32... But it is slow. I think, for a particular project, someone will use the USB to test and when fully functionnal, the user will rename his final project file main.py so that it will be executed automatically when you apply power... Right now, I made provision to power my esp using the lego box power connector on the front but I do not use it because I prefer to use USB link to test. It is faster. But for a final project, I would disconnect the usb and use the 9vdc link to power the ESP... I'm glad you you managed to test the setup... I feel less lonely now ;-)
  20. Here is a preview of the UIFlow 2 blocky LegoB blocks and a working sample program. (nothing fancy motor port A follow state of Touch sensor input 1). (On a M5 Core 2 but same has worked on a M5Stick CPlus)
  21. I played a bit with the M5Stack ESP32 devices I have in hands. Notably the M5Stick CPlus. But I did not yet installed a bare micropython firmware in it. I was wondering if I could implement a LegoB Block in their UIFlow Blocky... I found out that their blocky thing is a bit limited and does not allow ASYNCH tasks really... ASYNCH allows to simulate some multitasking... (Micropython does not have real mutli-threading... not yet). So in blocky, you have a setup and a loop. But behind the scene they use micropython. They allow us to make our own Blocky custom blocks... I decided to try to make a LegoB blocky block that do not use asynchio... It works. I'm not finished implementing, but the basic works... If anyone is interested to my blocky LegoB code, let me know and I will finish implementing the methods and make it available in dropbox. That made me think it could be interesting to have a version of LegoB module that does not use ASYNCHIO as an alternative to the version using ASYNCHIO. So here it is: UPDATED 2025-02-04: LegoBv2 : LegoB Driver not using Asyncio. The main difference, is that your program is now responsible of the reading of the IO's. (see demob_plc01 et demob_plc02). It acts somewhat like an industrial PLC (Programmable Logic Controller which is my field of work). The code to achieve the same think as the multi tasking version seems bigger but for me it is more "logic" but I'm not objective cause I worked with PLC for over 30 yrs... So you always have to put your program in a FAST forever loop and ALWAYS include the lego.readinputs in the loop. And you have to think differently when you want to implement a sequence cause you cannot block the code for too long or you will miss input frames and might become totally un sync with the serial comm. demob_plc02 implements a sequence some how with delays between output commands... Let me know what version you prefer... The LegoB V2 is using Machine (ESP32 MCU) Timers to achieve separates tasks for KeppAlive and Read Inputs. Now the user program does not need to worry to much about timings...
  22. The M5Stack series of ESP32 products (Atom, Stick, Core) can be also a great options for those NOT wanting to solder... And their products are often LEGO compatible (HW Size, studs...) I will order for fun: ATOMIC RS232 Base TTL-RS232 ATOM Lite ESP32 IoT Dev Board I have a M5Stack Core2 already. M5Stack Core2 But I'm missing: RS232 Module 13.2 with DB9 Male Connector (Expensive, I will rather use Grove cable to a DB9 RS232/TTL converter module. But good to know it exists) Grove2Dupont Conversion Cable 20cm (5Pairs) I also have a M5Stick CPlus: M5StickC PLUS ESP32-PICO Mini IoT Development Kit . I might try it this weekend. I have grove connector cable with a bare end that I will adapt with dupont wires somehow... This small M5Stick has a small battery and a OLED screen and it also has some IR transmitter (maybe could interface the RCX?) and buttons and 6-Axis IMU, RED Led, RTC, Passive Buzzer, Microphone...
  23. Did you also buy some gender changer like: https://www.amazon.ca/DKARDU-Changer-Transfer-Adapter-Connector/dp/B09BQ4HF53 ? (Unless you aready have some...)
×
×
  • Create New...