Cosmik42

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

Recommended Posts

Hi,

as far a I know the program only runs on WIN10.

It is not designed for exhibitions, as there is no feature to filter the devices, so you wold see all of the BT devices form other users  around you.
I've tried that on two exhibitions, and it wasn't succesful. The results are unpredictable.

And with a programm in some box without any display you have no chance to control something in case of any unexpected situations (which are quite normal, think about empty batteries...)
I recommend a microcontroller like a raspberry or similar, I' ve shown this as an example with a fully automated layout on some exhibitions.

 

 

 

 

Share this post


Link to post
Share on other sites

Bummer!

That would be a feature request then. Since @Lok24 says it can be achieved with a raspberry (a link would be cool, pictures even cooler!) could this also be implemented in the W10 program?

Share this post


Link to post
Share on other sites

Hi,

here is a link to my layout controlled by a raspberry, with a short video

2 locos, one remote decoupler in a waggon, crossing, 2 signals, 3 switches - and the minfig :wink:

And Sound!

fully automated Layout controlled by Raspberry Pi

and the control

Control

I showed that last year at two exhibitions, four days in total. Worked fine! (except ampty batteries ....)

Edited by Lok24

Share this post


Link to post
Share on other sites

Hm then it is probably more a thing of the software on sbrick and pfx brick themself. TBAP is the only possibility to be able to control sbrick or pfx with the pup controller so far. Dont like havinf to use my smartphone to play with my lego at convention to be honest.

Edited by Ragni Norgrimson

Share this post


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

TBAP is the only possibility to be able to control sbrick or pfx with the pup controller so far.

Not at all, my Raspberry/python uses the PoweredUp handheld to control two locos with powerdeUp Smart Hub and 6 PF-Motors on two SBricks  (switches, signal, crossing), all with only one handheld.

I posted pictures here some time ago.

There are no restrictions at all, all protocolls are public.

Last exhibition in June I had that with me.

 

1 hour ago, Ragni Norgrimson said:

Dont like havinf to use my smartphone to play with my lego at convention to be honest.

That was my idea too, but it is really the most comfortable way to have a slider on the screen.

 

Edited by Lok24

Share this post


Link to post
Share on other sites

Cosmik42s BAP is a really nice software and perfect for home use. Its ideal to run the garden LEGO railway.

At the moment the lack of an excluding/including function of designated BT devices might be a drawback, but the operation at exhibitions is not a standard case. I'm sure its not to difficult to add such functionality to the software, if Cosmik42 have the time to do this and thre is common demand ...

But it has even now really undeniable advantages: First: It's ready to use and available for everybody. Just download, install and use it. We need no special hardware or software, even no more software knowledge than run a Win10 program. And Win10 is a standard on mordern notebooks independent if you like it or not (I for myself do not so much, but I can live with it) 

Then BAP functionality can be extended by inserting small program blocks in C#, if you have some programming knowledge. I for myself make experients with Arduino communications using the serial port and it works fine. And basic functionality like programming the color sensor for instance can be performed without any programming. A couple of weeks I presented my solution for working signals in this thread ..

Of course own hard- and software solutions are undisputable mor satisfiying for the skilled maker. So it#s a matter of personal preference what system you use. I for myself like playing with LEGO parts and like BAP for its readyness.

Share this post


Link to post
Share on other sites

And, as another  plus: you have a dashbord showing what happens, that's really helpful.

Connection between Handheld, BAP and Hubs is fine, as well.

What I didn't find out yet:
- if you can read the angle of a motor using "raw value"
- how to access the Hub-List via global code
- use a project on another PC

But my konwledge of C# is near to zero....

 

 

Share this post


Link to post
Share on other sites

I am lost a bit.

How can I configure my hub with 2 train motors to be controlled by one handset.

Update:

I think I got it. So brilliant. Thank you so much for that app :classic:

Edited by TuffTuffTuff

Share this post


Link to post
Share on other sites

Hi all,

first of all: I really appreaciate the idea of @Cosmik42 to built a tool that is easy to handle without any knowledge of MAC-addresses or other special skills.

But as discussed, in some cases it might be useful to to assign the addresses and dedicate them to specific hubs.

Please find the global code for such a scenario below.

All Objects are defined first, then the dedicated MAC-Adresses.
(Please feel free to do this in C# lists, it's just to show how it works)

After that we have "start", which does all the work.

So you have to insert in every event code the command
start(Hub);

Thanks for your interest.

And many thanks to Vincent for that really useful software :thumbup:

 

// define the Hubs
public static Hub Lok1;
public static Hub Lok2;
public static Hub Handset;

// define the addresses
public static string Lok1_adr = "00:16:53:af:77:c3"; 
public static string Lok2_adr = "90:84:2b:10:79:0a"; 
public static string Handset_adr = "a4:34:f1:ce:5c:45";

// ----start----------------------------
static void start(List<LegoTrainProject.Hub> HubList)
{
// Show all Device-IDs
log("All Device-IDs");
log("-------------------");
for (int i=0;i<HubList.Count;i++)
{
    log(HubList[i].DeviceId);
}
// Show all Conncted and assigned Hubs
log("Assigned Hubs");
log("-------------------");
for (int i=0;i<HubList.Count;i++)
{
    if (HubList[i].IsConnected)
    {
        int p = HubList[i].DeviceId.IndexOf("-")+1;
        string MacAdr = HubList[i].DeviceId.Substring(p);
        string name = "Not assigned";
        if (MacAdr==Lok1_adr){Lok1 = HubList[i];name="Lok1"; }
        if (MacAdr==Lok2_adr){Lok2 = HubList[i];name="Lok2";;}
        if (MacAdr==Handset_adr){Handset = HubList[i];name="Handset";} 
        log(String.Concat(name, "  " , MacAdr, " from Hub No "),i);
  }
}
log("-------------------");
}

// ---Log-----------------------------
static void log(string a="", int i = 99999)
{
if (i == 99999)
{
    MainBoard.WriteLine(a); 
}
else
{
    string tt = Convert.ToString(i);
    MainBoard.WriteLine(a+ " "+ tt); 
}
}

 

Edited by Lok24

Share this post


Link to post
Share on other sites

Hi all,
Technic Hub and motors work without any problems, but hub shows no sliders.

technichub.jpg

Attached one L and on XL , within code you can use them easily

 

 

Share this post


Link to post
Share on other sites

I've just started looking into using @Cosmik42's Brick Auotmation Project. I had a bit of a stumble as I had renamed my SBrick and hence was encountering the "connected but discarding" issue but renaming it back to SBrick remedied that. I've also successfully connected to my EV3, which fortunately didn't matter that I had renamed it.

I next tried connecting to an NXT but I have been unsuccessful in doing that. I was wondering whether anyone has successfully managed to connect to an NXT? If so, would you be willing to post what you had to do to get a successful connection?

Regards,

David

Edited by djm
typo

Share this post


Link to post
Share on other sites

Hi David,

I am not sure, but I believe @Cosmik42's software communicates with Bluetooth Low Energy (BLE) devices only, whereas the NXT uses some sort of Serial over Blueltooth protocol, which seems to be entirely different. At least this is what I learned, when starting to program with the BLE hub device types.

Best
Thorsten 

Share this post


Link to post
Share on other sites

Hi everyone,

I sincerly apologise for having been away for so long. 
On the pro side of things I am the CEO of a company that is a major growth, and have left me with no mental and physical time to engage with this project.

However, I plan on spending Sunday 18th all day to catch up with it:

 - Implement MAC-Address limitation.
 - Clean it up and share it with the community.

I am sure that once my code is available to all, the community can take it to the next level.

As for NXT, it is not implemented and Jetro is right, I connect to EV3 via standard bluetooth.

Thanks for your patience!

Share this post


Link to post
Share on other sites
15 hours ago, Cosmik42 said:

Hi everyone,

I sincerly apologise for having been away for so long. 
On the pro side of things I am the CEO of a company that is a major growth, and have left me with no mental and physical time to engage with this project.

However, I plan on spending Sunday 18th all day to catch up with it:

 - Implement MAC-Address limitation.
 - Clean it up and share it with the community.

 

I hope you're not too busy to play with your LEGO!

A question regarding the EV3 and using multiple touch sensors. When I have one touch sensor plugged in (port 1), it recognizes the sensor and shows me the "raw" data value. I can see the raw data value changing as I press the sensor down and release it. However, when I plug a second touch sensor into the EV3 (port 2) , although it shows me the raw data value, it does not show any change in the value when the button is pressed or released. The touch sensor is not faulty as if I have the second sensor connected to port 2 and nothing connected to port 1, the change in raw data value is visible when the sensor is pressed/released. So my question is whether BAP supports multiple touch sensors in an EV3 and whether or not anyone else has successfully used this set-up?

I'm hoping to use multiple touch sensors of this ilk, for controlling monorails:

640x654.jpg

Regards,

David

Edited by djm
Added the question!

Share this post


Link to post
Share on other sites

It appears that the latest firmware release from LEGO for the Boost Hub (2.0.00.0017) has remapped the port IDs. When I connect BAP to my Boost Hub, Port C in BAP turns the B port motor and port D in BAP is the Boost Hub C port. There is no access using BAP to Boost hub's A and D ports.

David

Share this post


Link to post
Share on other sites

You can add a 88010 Handset and assign the machines etc to the buttons.

Last exhibition I had one(!)  handset, two locos and six PF motors for switches, crossing and signals with me, all driven by BAP (with the assigment of MAC, as shown above)

Share this post


Link to post
Share on other sites
On 8/14/2019 at 1:00 AM, TheLarry98 said:

Can you also please add support for the new Technic Hub.

I have ordered that 4x4 set to get my first Control+ hub. Should have it this week and will try to implement before next Saturday.

On 8/14/2019 at 11:16 AM, djm said:

It appears that the latest firmware release from LEGO for the Boost Hub (2.0.00.0017) has remapped the port IDs. When I connect BAP to my Boost Hub, Port C in BAP turns the B port motor and port D in BAP is the Boost Hub C port. There is no access using BAP to Boost hub's A and D ports.

I confirm this is fixed. Will release in 1.4!

Edited by Cosmik42

Share this post


Link to post
Share on other sites
On 8/12/2019 at 11:40 AM, djm said:

A question regarding the EV3 and using multiple touch sensors. When I have one touch sensor plugged in (port 1), it recognizes the sensor and shows me the "raw" data value. I can see the raw data value changing as I press the sensor down and release it. However, when I plug a second touch sensor into the EV3 (port 2) , although it shows me the raw data value, it does not show any change in the value when the button is pressed or released. The touch sensor is not faulty as if I have the second sensor connected to port 2 and nothing connected to port 1, the change in raw data value is visible when the sensor is pressed/released. So my question is whether BAP supports multiple touch sensors in an EV3 and whether or not anyone else has successfully used this set-up?

I'm hoping to use multiple touch sensors of this ilk, for controlling monorails:

640x654.jpg

I will try to repro your issue. There shouldn't be any issue for this kind of scenario so I need to investigate.

Edited by Cosmik42

Share this post


Link to post
Share on other sites

Alright V1.4 is out!

 - Includes a way to limit the devices capable of connecting :
  * Only devices from a project.
  * Only devices from a global list.

68745937_10156085332156090_2051931852708

 - I fix the latest Boost Hub firmware update issue by fixing the correct port Ids for that version.
 - Self-Driving Tutorial images have been fixed.

Link to the latest version: https://www.dropbox.com/sh/pvwv4czhueadlb3/AAAif-h-vPGz7Q1w3iwZMFkVa?dl=1

 

Edited by Cosmik42

Share this post


Link to post
Share on other sites

Dear all,

I like to add a screen shot to explain my problem, but how to make a picture with about 0,03MB where you are able to see something?

So will will try to explain with pure text.

I currently try to understand how the self driving modul is working. I started with a simple scenario, 2 trains and 3 sections (0,1,2) and without any switch. To detect the end of my sections I am using 3 wedo 1 motion sensors which are linked with several sbricks. The two trains are runnung with 2 powered up hubs.

My sensors are showing always a distance value of 4. If a train is passing the sensors the value goes down to 0 for a short moment. Afterwards they show again the value 4.

The first train has the start position in sector 0, the second has the start position in sector 1.

I defined the path 0, 1, 2 , 0.

I expect that the second train drives to sector 2 because this one is free. When this train leaves sector 1 I expect that the first train drives to sector 1 because this one is free now... and so on.

See below the messages I got...No train was started...

In any case I suppose I miss something... How can the software know that distance 0 means that a train is passing the motion sensor and the distance 4 means that there is currently no train passing?
So I expect I have to add somewhere something more to the software? 

What do I have to do to get the trains running?

 

 

After starting the selfdriving mode and clicking on the two green start buttons of the two trains I get the follwing messages:

After a view seconds I stopped again because no train started.

 

All Sensor Events for Self-Driving are active.
Anti-Collision is active over 3 sections!
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event discarded - Unknown train on Section 1, nothing done
HUB NO.1 self-driving path is set to New Path! Resuming from Section 2
HUB NO.1 - stopped because Section 0 is occupied
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
HUB NO.4 self-driving path is set to New Path! Resuming from Section 0
HUB NO.4 - Next section is not cleared! We slow down
Could not set Motor Speed to 40 for HUB NO.4 because no default port are setup
HUB NO.4 - Allowed to move to Section 1
HUB NO.1 - stopped because Section 0 is occupied
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - stopped because Section 2 is occupied
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - Event discarded - Waiting to for next section.
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - Event discarded - Waiting to for next section.
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - Event discarded - Waiting to for next section.
HUB NO.1 - stopped because Section 0 is occupied
HUB NO.4 - stopped because Section 2 is occupied
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - Event discarded - Waiting to for next section.
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event #3 triggered - SBrick V on port C has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 has cleared section Section 0
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.1 - Event discarded - Waiting to for next section.
HUB NO.4 - Event discarded - Waiting to for next section.
HUB NO.4 - stopped because Section 2 is occupied
HUB NO.1 - Next section is not cleared! We slow down
Could not set Motor Speed to 40 for HUB NO.1 because no default port are setup
HUB NO.1 - Allowed to move to Section 0
Sensor Events for Program 'Self-Driving' are stopped.
HUB NO.1 path has been cleared and train is stopped
HUB NO.4 - Attempting to clear path and stop train, but waiting for lock to finish
HUB NO.1 has cleared section Section 2
HUB NO.4 - wait is aborted!
HUB NO.4 path has been cleared and train is stopped

 

 

Share this post


Link to post
Share on other sites
4 minutes ago, Didicas said:

Could not set Motor Speed to 40 for HUB NO.1 because no default port are setup

This seems to be your problem. Click configure on your train, switch to Train Motor. If it is already like this, switch to something, close, reopen and switch again to this setting. Let me know.

Share this post


Link to post
Share on other sites

The train motor was already selected. I took another selection, reopened and selected the train motor again.

When I start now the train starts driving and stops immediately.

On the message list below I read very often "Unknown train on Section 2, nothing done".

Why does the software assums that there is a train?

What about my detail question? How can the software know that distance 0 means that a train is passing the motion sensor and the distance 4 means that there is currently no train passing? Or is it always like that?
So I expect I have to add somewhere something more to the software? 

 

Obviously there is still something I do not understand...

 

All Sensor Events for Self-Driving are active.
Anti-Collision is active over 3 sections!
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
Event discarded - Unknown train on Section 2, nothing done
HUB NO.4 - Event discarded - Train is not running
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
Event discarded - Unknown train on Section 2, nothing done
HUB NO.4 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 3
Event #2 triggered - SBrick H  on port B has a distance below 4
Event discarded - Unknown train on Section 2, nothing done
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.4 - Event discarded - Train is not running
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 3
Event discarded - Unknown train on Section 2, nothing done
HUB NO.4 - Event discarded - Train is not running
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Train is not running
Event #1 triggered - SBrick R on port C has a distance below 4
Event #3 triggered - SBrick V on port C has a distance below 3
HUB NO.1 - Event discarded - Train is not running
Event discarded - Unknown train on Section 2, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
Event discarded - Unknown train on Section 2, nothing done
HUB NO.4 - Event discarded - Train is not running
HUB NO.4 self-driving path is set to New Path! Resuming from Section 1
HUB NO.4 - Next section is not cleared! We slow down
HUB NO.4 - Allowed to move to Section 2
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - stopped because Section 0 is occupied
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 3
Event #2 triggered - SBrick H  on port B has a distance below 3
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
HUB NO.4 - stopped because Section 0 is occupied
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 3
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 has cleared section Section 1
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
HUB NO.4 - stopped because Section 0 is occupied
Event #3 triggered - SBrick V on port C has a distance below 3
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event #1 triggered - SBrick R on port C has a distance below 4
Event discarded - Unknown train on Section 1, nothing done
HUB NO.1 - Event discarded - Train is not running
Event #3 triggered - SBrick V on port C has a distance below 4
Event #2 triggered - SBrick H  on port B has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Event discarded - Unknown train on Section 1, nothing done
Event #1 triggered - SBrick R on port C has a distance below 4
HUB NO.1 - Event discarded - Train is not running
Event #2 triggered - SBrick H  on port B has a distance below 4
Event discarded - Unknown train on Section 1, nothing done
Event #3 triggered - SBrick V on port C has a distance below 4
HUB NO.4 - Event discarded - Waiting to for next section.
Sensor Events for Program 'Self-Driving' are stopped.
HUB NO.1 path has been cleared and train is stopped
HUB NO.4 - Attempting to clear path and stop train, but waiting for lock to finish
HUB NO.4 - wait is aborted!
HUB NO.4 path has been cleared and train is stopped

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.