HectorMB

Mindstorms App communicating with technic hub, trigonometric formulas and coordination between hubs.

Recommended Posts

Hello everyone!

I'm struggling with a rather complex project in which i need to coordinate several hubs (4). Given the current resources, I'm considering the following options:

-Use broadcasting communication with Pybricks. Nevertheless, in my hands, it not quite stable and I am not 100% successfull in transmitting the information between technic hubs. Nevertheless, it is an option to explore. I could run one program for each hub, but, as long as they have to be launched from different tabs, I would need also to find a way to coordinate them (my first approach is to start all the programs at a certain time, the same for all the hubs, few seconds after the inputs are given). Does anyone have some experience to share with broadcasting between technic hubs?

-Use the Lego tehnic app. As the project involved some calculations with trigonometric formulas -which are not included in the Lego app, unless I am mistaken, it remains one of my last options. Does anyone knows if it is possible to include trigonometric formulas in the Lego technic app?

-Use of the Mindstorms App. This app indeed includes trigonometric formulas AND hub-to-hub communication, which makes the ideal choice for this project. Unfortunately, I just have one mindstorm hub, so I am wondering if there is any way to manage a technic hub with the Mindstorms app. 

 

Many thanks in advance!

Share this post


Link to post
Share on other sites

Very cool project!

Have you ever used (Cornelius Munz') Legoino (https://github.com/corneliusmunz/legoino) running on an ESP32 Dev kit board (or any other board that features a ESP32 WROOM module; these cost about $10)? All you need to do, is plugging a USB cable into your computer and the board. The Arduino IDE can be used for programming. Which means that you have all the bells and whistles of C++ including all the functions you want to use (and many, many more).

You can sign up about 10 hubs of any PUp kind (2 port (City), 4 port (Technic) hubs as well as multiple PUp remotes to the ESP board. With activated notifications, each hub reports back to the control program changes of built-in or attached sensors (e.g. rotation readings from the tacho motors, key status of the remote), as you can do in PyBricks. And you can always poll such data at any time. The difference, though, is that the ESP controls everything the hubs are supposed to do, i.e., you have that control program in one place. Coordination of the hubs then works through the ESP board. The other nice thing is that you easily can hook up OLED displays via the I2C bus (using only 4 wires, including VCC and GND) as well to show some critical values. Or graphics. I mostly use the remote to set up the whole "experiment" (going to the initial positions etc.). One example is here: https://www.eurobricks.com/forum/index.php?/forums/topic/190786-br89-90-bb-10-tlg-and-turntable-99-tlg/&do=findComment&comment=3531548; there are 2 City hubs (turn table and BR89) and one PUp remote for manually getting the "system" into initial position (which I automated as well, but during development it was very helpful!)

I just finished another rather crazy project, including a Technic hub, PUp remote and - well 4.5V Technic Control stuff from back then - it all works.

And once your program is running fine on the ESP, just unplug it from the computer, plug in any 5V USB power supply, and it will do what you designed it for - no smart device required at all.

On my train layout, I am currently signing up 8 PUp City hubs - the ESP holds them together :pir-laugh:https://www.eurobricks.com/forum/index.php?/forums/topic/188584-mulpi-a-multiple-lego-remote-protocol-interface/

All the best,

Thorsten

 

 

 

Share this post


Link to post
Share on other sites

Many thanks for the comment, Thorsten! :) I have read about Legoino here and there, but I never knew what it was about really. It's of course a possible alternative for my project. The problem is that I have VERY limited experience with C++, therefore it would be quite challenging to learn almost from scratch on that sense. I don't have a lot of experience with Python neither, but it's way more friendly user environment. Nevertheless, I'm just starting my learning with Python...

I went further exploring the alternatives I have (I'll post soon the Lego project I'm working), and ended with this:

-broadcasting with Pybricks doesn't seem to be a real alternative. I cannot make it work in a proper way by now... :(. It remains as an alternative if I find a way to coordinate the different programs, but I also find that there's only a stopwatch function, not a real clock that would help me to, at least, launch all the programs simultaneously. 

-thanks to a video posted by Kbalage, I just learned about hidden blocks that are used for programming the Lego sets programs, that are normally hidden to the general use. I think that maybe in the program of the 42100 I might find some blocks that may allow me to use trigonometric functions... It maybe not, but it worth a try.

Let's see if I manage to end up with a solution! 

 

 

 

Edited by HectorMB

Share this post


Link to post
Share on other sites

I’m not familiar with what functions are available in LEGO Technic app, but if basic arithmetic (+,-,x,/) is available, then you can approximate any trigonometric function by series expansion. It’s a bit elaborate, but definitely doable and arbitrarily accurate. They landed the Apollo missions on the moon with this approach. 

Share this post


Link to post
Share on other sites

Many thanks @lcvisser! I thought how I could approximate the trigonometric functions. 

I also though that, if I manage to do the broadcast hub communication, I can run the program and calculations in a Mindstorms hub, and then transmit the results to the other hubs. It remains the issue that broadcasting is not very timely precise, which may be an issue...

 

Again, thanks for the help!

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.