Cosmik42

Control all your Powered Up & Power Function (SBrick) devices with a single software

Recommended Posts

First and most important: We all are so grateful that you sacrified your evening to solve the motor problem :sweet:

It is a full success!

With the PUP hub all kindes of motors (simple medium, train and Boost external) works perfect together with the colour/distance sensor. This is true for the latest version of the PUP hub firmware. Since I've updated all (!) of my PUP hubs I cannot test it with elder versions anymore. I'm convinced elder firmware versions will die out rapidly,so I see no problem.

This is important because the small PUP hub fits into a lot of locomotive designs, the Boost hub do not. Now it is possible to combine a sensor with a train or simple medium motor and get a functionality comparable to Duplo. Particular a working signal solution is coming up.

I repeated the test with two PUP hubs in parallel. No problems anymore. We are able to run several trains at the same time.

Today afternoon I will get more colour/distance sensors bought in the LEGO online shop, then I will test several parallel motor/sensor combinations and post the results here.

The move hub works in all configurations.

It seems the 1.3 alpha can loose its alpha status very quick.

Many many many thanks to you Cosmik42

Share this post


Link to post
Share on other sites

Second test run:

Setup: four PUP hubs, all with the colour/distance sensor at Port B and two hubs with train motors at port A and the two other hubs with simple medium motors at port A. LEDs set to green, yellow, red and blue.

Result: Each hub runs alone in pairs, in triples or all four together. Each hub can be enabled and disabled individually without any flaw. In all combinations the clour/distance sensors delivered correct and reproducable results. This is equivalent to operate up to four trains at the same time.

Conclusion: Absolute functional for sensor controlled multi train operation. That's what we have dreamt of ... The official LEGO app is not able to do this as far as I know. If no severe issue is found, the alpha status can be removed.

(Minor) restriction: I can only run test with the actual firmware version of the PUP hub. To be safe just update first the firmware of your hubs.

Share this post


Link to post
Share on other sites
Just now, Giottist said:

Second test run:

Setup: four PUP hubs, all with the colour/distance sensor at Port B and two hubs with train motors at port A and the two other hubs with simple medium motors at port A. LEDs set to green, yellow, red and blue.

Result: Each hub runs alone in pairs, in triples or all four together. Each hub can be enabled and disabled individually without any flaw. In all combinations the clour/distance sensors delivered correct and reproducable results. This is equivalent to operate up to four trains at the same time.

Conclusion: Absolute functional for sensor controlled multi train operation. That's what we have dreamt of ... The official LEGO app is not able to do this as far as I know. If no severe issue is found, the alpha status can be removed.

(Minor) restriction: I can only run test with the actual firmware version of the PUP hub. To be safe just update first the firmware of your hubs.

Thanks for running all these tests! I will test it on non upgrade devices on Friday, once I am back home!

Share this post


Link to post
Share on other sites
1 hour ago, Cosmik42 said:

Thanks for running all these tests! I will test it on non upgrade devices on Friday, once I am back home!

I just finished testing with my non-upgraded Hubs No.4, I connected 11 of them and all worked as before so nothing is broken, at least with train motors, WeDo 2.0 motors and LED's.

I upgraded one hub and it works along side the non-upgraded hubs so all looks well to me.

Edited by bogieman
add new info

Share this post


Link to post
Share on other sites
39 minutes ago, bogieman said:

 I connected 11 of them and all worked as before so nothing is broken ...

11 hubs in parallel? Really? You encourage me to repeat the test with all my 6 hubs and 4 Sbricks ... I assume the limit is the channel number of the used BT controller. Mine is the build in controller of a Gigabyte Brix.

Share this post


Link to post
Share on other sites
1 hour ago, Giottist said:

11 hubs in parallel? Really? You encourage me to repeat the test with all my 6 hubs and 4 Sbricks ... I assume the limit is the channel number of the used BT controller. Mine is the build in controller of a Gigabyte Brix.

I'm using a USB Bluetooth 4.0 adapter based on a Broadcom chip. 12 is the maximum I can connect - if I try to add a 13th they all disconnect.

Share this post


Link to post
Share on other sites

Hi @Cosmik42

just made an update on may both SmartHubs (No.4) and made some tests with 1.3 alpha, found no malfunctions.

Thanks a lot.

Share this post


Link to post
Share on other sites

Awesome work Cosmik!

 

I recently got hold of quite a lot of WeDo 2.0 hubs at a very good price. What’s the latest on support for those? Any limitations vs Boost/PUP?

Share this post


Link to post
Share on other sites
On 2/3/2019 at 6:31 PM, Lok24 said:

But color detection is strange?

Hi,

I found an article that examines the problems with color recognition at ramblingbrick.com

Share this post


Link to post
Share on other sites

Hi there, more to report while playing with the Brick Automation Project:

Just tried to test the combination of a train motor at port A and the colour sensor at port B to get a signal functionality. The colour sensor looks own with an average distance of 10 mm to the sleepers. Here my true barebone setup:

47040527694_7ae67b594d_z.jpg

To let stop a train in front of a red signal I put a red strip on the sleepers in some distance. At full speed 50 up to 70 cm are sufficient but I have to do more tests with real heavy trains ...

In the programm section BAP software a sensor event is advised to decelerate the train in 500 ms if the colur red is recognized between the rails.

32886308177_6741611b40_b.jpg

The test results are promising. Even at full speed only limited by motor power and the steep radius of original R40 curves 8 stud length for the signal strip is sufficient to be recognized. But only red and white are detected with enough reliability. My wooden flor is to often interpreted as "yellow", blue and green does not work.

A signal can be realized by a visible signal either mechanical or by LED in combination with a red signal strip aproximately 50 cm in front of the signal mast. This strip can be turned upside down showing a neutral colour if the main signal shows "go" or green light. Next step will be building the signal in real bricks.

Share this post


Link to post
Share on other sites

Hello @Cosmik42

I was at BrickBits 2019 convention last weekend and had your software with me.

As supected it was a complete desaster, starting the software I had up to six SBricks and some Smart Hubs in the panel within a second, none of them mine.
Without blocking all MAC-Adresses expect my own you can't use it for that. At home that's no problem, of course.

And without assigning names to the MAC-addresses you dont'n find the desired one.

BTW: Sensors don't react as expected. Conneting to Port A and controlling a motor on Port B works.
But: if you change connectors  A and B on the hub this if reflected in the panel, log shows proper values, but it's never triggered.

 

 

 

 

Share this post


Link to post
Share on other sites
1 hour ago, Lok24 said:

Hello @Cosmik42

... As supected it was a complete desaster, starting the software I had up to six SBricks and some Smart Hubs in the panel within a second, none of them mine. ...

Please keep in mind that Cosmik42 does his work for free. We can be grateful to him for this altruistic policy.

It is really hard for him (more common for all of us!) to foresee any circumstances. He appreciates our feedback, but a neutral report is most useful.

I'm sure there will be a solution to select individual hubs and to exclude others. I suggest an assignment of MAC adresses in a droplist to the individual  (coloured) hub which can be saved and reloaded. This might be much more flexible than the rigid SBrick solution.

Please be fair and regard the number of BT channels are limited at one place. I suggest max 3 channels at exhibitions per exhibitors so four can work in parallel.

1 hour ago, Lok24 said:

BTW: Sensors don't react as expected. Conneting to Port A and controlling a motor on Port B works. But: if you change connectors  A and B on the hub this if reflected in the panel, log shows proper values, but it's never triggered.

I just tested it: In the silence of my home there is no issue: My signal program works fine with the sensor at both ports A and B. Did you test it in presence of many other BT devices ?

Edited by Giottist
More suggestions ...

Share this post


Link to post
Share on other sites
1 hour ago, Lok24 said:

Hello @Cosmik42

As supected it was a complete desaster, starting the software I had up to six SBricks and some Smart Hubs in the panel within a second, none of them mine.
Without blocking all MAC-Adresses expect my own you can't use it for that. At home that's no problem, of course.

Sorry you had a bad experience with it. I never attend convetion and even though this was discussed previously, I indeed never provided a solution for it.

I will see what I can do.

Share this post


Link to post
Share on other sites

Hello @Giottist

I agree. And I am grateful for his work. And it is not a question of foreseeing.

We discussed this topic some months ago, and this is my feedback.
I at that time proposed a list like 'allowed_MAC=[x1,x2,x3....]' in the global code.

Another approach would be only to use the MAC-Adresses stored in the project, but with the disadvantage that you could never add a guest with his loco.
Please be aware that you can hardly distiguish the Hubs, the ones I saw all were namend SBrick", except mine....

Why shold there be a limitation to 12 BT channels? We' are going to have an exhibition in June with railway layouts only, there'll be dozens of engines.
I have a project here with 7 hubs.

To sensors: yes, it works fine, one sensor and one motor. But if you change - on the fly - the connectors it reports the color in the log, but doen't trigger an event.

 

Hi @Cosmik42, you provided the solution of disablig BT scanning, and I thought that would help, but then I can't attach my own devices.

Your argument was that users should not struggle with MAC, and I agree that very much, your solution is simple and elegant, no doubt.
But a lttle bit tricky if others are nearby :wink:

Please note that I'm really glad to have such a powerful tool, I just wanted to share may experience in the wilderniss....

Edited by Lok24

Share this post


Link to post
Share on other sites
5 minutes ago, Lok24 said:

Why shold there be a limitation to 12 BT channels?

The is no software (BAP side) limitation to the number of hubs. Only hardware/firmware.

Share this post


Link to post
Share on other sites

Correct, that's why I did not understand why 3 channels per 4 persons should be delimited, as @Giottist proposed

Share this post


Link to post
Share on other sites

Ah, perhaps I misunderstood the maximum number of occupied BT channels is limited to 12 by principle and not only by hardware. On the other hand, I curious about the idea for a work around ...

Share this post


Link to post
Share on other sites

Hi, the number of channels per device is limited by the storage of the BT-Device, if this is a dongle you in many casas have app. 12

Share this post


Link to post
Share on other sites
1 hour ago, Lok24 said:

We discussed this topic some months ago, and this is my feedback.
I at that time proposed a list like 'allowed_MAC=[x1,x2,x3....]' in the global code.

I remember that discussion well.

The first thing I did then was to restrict the BLE device scanning to known MAC addresses only.

@Cosmik42: As my program has a different philosophy than yours (static frame/control positions on the form, which in turn expands with number of user defined BLE devices allowed - vs. automatically growing with actually found devices (in order of detection), things need to be handled differently, I guess. You also talked about that somewhere. But: Wouldn't it be easy to read (an optional) plain text file at program start, which just lists the "allowed" MAC addresses to scan for? No file found = default behavior as of now, text file present and valid entries present = restriction to the listed devices. You would just need to add a friend's MAC address to the text file (using any plain text editor) and restart the program. There are countless other options of course and you will certainly come up with a nice and sharp solution!

Best
Thorsten  

Share this post


Link to post
Share on other sites

Your software is great and has some good functionality, although I got an issue:

I have some trouble getting the GetColor() function to work properly in the code editor. It says it puts the result into a string, but when I try to handle it as such a get loads of compiling errors.

Is there something I am looking over?

 

Share this post


Link to post
Share on other sites

Okay, I've gotten a little further, but I'm still getting errors about the getColor output (CS0103).
I'm not quite sure if I'm doing stuff correctly, I familiar with C, not the class structure of C#.

 

LegoTrainProject.Port.Colors    colour;
int                             speed;
int                             topSpeed = 30;

colour = Hub[0].GetColor("A");
speed  = Hub[0].GetSpeed("B");

if (colour == RED ){
    Hub[0].RampMotorSpeed("B", 0, 500);
    Wait(700);
    Hub[0].RampMotorSpeed("B", topSpeed, 700);
}
    
if (colour == YELLOW){
    Hub[0].RampMotorSpeed("B", 0, 500);
    Wait(700);
    Hub[0].RampMotorSpeed("B", topSpeed, 700);
}

My best educated guess is that LegoTrainProject.Port.Colors is defined as a typedef/enum like structure, but I cannot find where the proper outputs are defined.

Edited by UrbanErwin

Share this post


Link to post
Share on other sites

Here is what you are looking for (Port.Colors)

        public enum Colors
        {
            BLACK = 0,
            PINK = 1,
            PURPLE = 2,
            BLUE = 3,
            LBLUE = 4,
            CYAN = 5,
            GREEN = 6,
            YELLOW = 7,
            ORANGE = 8,
            RED = 9,
            WHITE = 10,
            NONE = 255
        }
 

Share this post


Link to post
Share on other sites

This sounds very promising! Wow! Like a dream became true!

I've not read all 19 pages of comments yet, but maybe you can give me some hint if the question already has been asked: 

Sbrick and also the pfx brick from my understanding are programable controlling bricks. Is it possible to programm them with the brick automation project an then run it with the pup controller without using a parallel device like pc or app?

Not sure if it is totally clear what I want to know. Its just that I want to program the bricks and functions at home and use them at exhibitions not needing to bring a pc with me. Dont have any laptop and my pc is rather chunky and heavy. Would be awesome to know!

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.